Skip to content

Commit 581593c

Browse files
committed
Fix #1045
1 parent 25e6cb0 commit 581593c

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

proxy/core/connection/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def connection(self) -> Union[ssl.SSLSocket, socket.socket]:
5050

5151
def send(self, data: bytes) -> int:
5252
"""Users must handle BrokenPipeError exceptions"""
53-
# logger.info(data)
53+
logger.info(data)
5454
return self.connection.send(data)
5555

5656
def recv(
@@ -64,7 +64,7 @@ def recv(
6464
'received %d bytes from %s' %
6565
(len(data), self.tag),
6666
)
67-
# logger.info(data)
67+
logger.info(data)
6868
return memoryview(data)
6969

7070
def close(self) -> bool:

proxy/core/connection/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def connect(
4343
)
4444
self.closed = False
4545

46-
def wrap(self, hostname: str, ca_file: Optional[str]) -> None:
46+
def wrap(self, hostname: str, ca_file: Optional[str] = None) -> None:
4747
ctx = ssl.create_default_context(
4848
ssl.Purpose.SERVER_AUTH, cafile=ca_file,
4949
)

proxy/http/server/reverse.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ...common.utils import text_
2222
from ...common.constants import (
2323
DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT,
24-
DEFAULT_REVERSE_PROXY_ACCESS_LOG_FORMAT,
24+
DEFAULT_REVERSE_PROXY_ACCESS_LOG_FORMAT, HTTPS_PROTO,
2525
)
2626

2727

@@ -78,12 +78,18 @@ def handle_request(self, request: HttpParser) -> None:
7878
assert self.upstream
7979
try:
8080
self.upstream.connect()
81-
if self.choice.scheme == b'https':
81+
if self.choice.scheme == HTTPS_PROTO:
8282
self.upstream.wrap(
8383
text_(
8484
self.choice.hostname,
85-
), ca_file=str(self.flags.ca_file),
85+
),
8686
)
87+
# Update Host header
88+
if request.has_header(b'Host'):
89+
request.del_header(b'Host')
90+
request.add_header(
91+
b'Host', ('%s:%d' % self.upstream.addr).encode('utf-8'),
92+
)
8793
self.upstream.queue(memoryview(request.build()))
8894
except ConnectionRefusedError:
8995
raise HttpProtocolException(

tests/integration/test_integration.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ VERIFIED5=$?
165165
rm downloaded2.whl downloaded2.hash
166166

167167
read -r -d '' REVERSE_PROXY_RESPONSE << EOM
168-
"Host": "localhost"
168+
"Host": "httpbin.org"
169169
EOM
170170

171171
echo "[Test Reverse Proxy Plugin]"

0 commit comments

Comments
 (0)