Update server.py

This commit is contained in:
Namhyeon Go 2024-02-18 06:23:58 +09:00 committed by GitHub
parent 7e17fb7fe6
commit 288ae6b883
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -192,7 +192,19 @@ def proxy_server(webserver, port, scheme, method, url, conn, addr, data):
except Exception as e:
raise Exception("SSL negotiation failed. (%s:%s) %s" % (webserver.decode(client_encoding), str(port), str(e)))
# check request data
# Wait to see if there is more data to transmit
if len(data) == buffer_size:
conn.settimeout(5)
while True:
try:
chunk = conn.recv(buffer_size)
if not chunk:
break
data += chunk
except:
break
# check requested data
if proxy_check_filtered(data, webserver, port, scheme, method, url):
conn.sendall(b"HTTP/1.1 403 Forbidden\n\n{\"status\":403}")
conn.close()