Add 1 min timeout for no new data transferred
This commit is contained in:
parent
81fb82479a
commit
e186c7a85d
|
@ -376,18 +376,20 @@ 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:
|
||||
except (ConnectionResetError, socket.timeout):
|
||||
return
|
||||
if data == b'': break
|
||||
try:
|
||||
sock.sendall(data)
|
||||
except (ConnectionResetError, BrokenPipeError):
|
||||
except (ConnectionResetError, BrokenPipeError, socket.timeout):
|
||||
break
|
||||
|
||||
remote_sock.close()
|
||||
|
|
Loading…
Reference in New Issue