Compare commits
No commits in common. "e186c7a85d7a3933876dc29a6a9309eeca4db478" and "8cbaa722b1746f77b3f32430d04123b9839490ad" have entirely different histories.
e186c7a85d
...
8cbaa722b1
1 changed files with 7 additions and 9 deletions
|
@ -227,10 +227,10 @@ def proxy(sock, host):
|
|||
del username
|
||||
del password
|
||||
|
||||
# Remove headers that don't need forwarding or are overwritten
|
||||
headers = dict((key, value) for key, value in headers.items() if not key.startswith(b'proxy-') and not key in (b'connection', b'keep-alive'))
|
||||
# Remove headers that don't need forwarding
|
||||
headers = dict((key, value) for key, value in headers.items() if not key.startswith(b'proxy-'))
|
||||
|
||||
headers[b'connection'] = b' close'
|
||||
# TODO: connection: close
|
||||
|
||||
# Split url into its constituents
|
||||
fields = url.split(b'://', 1)
|
||||
|
@ -245,7 +245,7 @@ def proxy(sock, host):
|
|||
elif b':' not in remote_host:
|
||||
port = None
|
||||
else:
|
||||
remote_host, port = remote_host.rsplit(b':', 1)
|
||||
remote_host, port = remote_host.rsplit(b':')
|
||||
try:
|
||||
port = int(port)
|
||||
if port < 1 or port > 0xffff: raise ValueError
|
||||
|
@ -376,20 +376,18 @@ def proxy(sock, host):
|
|||
|
||||
del request_data
|
||||
|
||||
# TODO: Timeout
|
||||
# TODO: Un-https links
|
||||
# TODO: Keep sending request body, if any
|
||||
print('', file=sys.stderr)
|
||||
sock.settimeout(60)
|
||||
remote_sock.settimeout(60)
|
||||
while True:
|
||||
try:
|
||||
data = remote_sock.recv(1024)
|
||||
except (ConnectionResetError, socket.timeout):
|
||||
except ConnectionResetError:
|
||||
return
|
||||
if data == b'': break
|
||||
try:
|
||||
sock.sendall(data)
|
||||
except (ConnectionResetError, BrokenPipeError, socket.timeout):
|
||||
except (ConnectionResetError, BrokenPipeError):
|
||||
break
|
||||
|
||||
remote_sock.close()
|
||||
|
|
Loading…
Reference in a new issue