You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Infinitive loop of requests with HTTP proxy in certain conditions #6828
Recently I came up to a few public proxies that were returning 407 status code with Proxy-Authenticate response header while also missing final CRLF to indicate end-of-headers. Curl with such a proxy will repeat the CONNECT request indefinitely.
Here is how to reproduce it:
#!/usr/bin/env pythonimportsockets=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address= ('localhost', 8787)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(server_address)
s.listen(1)
whileTrue:
connection, client_address=s.accept()
data=connection.recv(1024)
connection.sendall(b'HTTP/1.1 407 Authentication Required\r\n')
connection.sendall(b'Proxy-Authenticate: Basic\r\n')
# with this line it will work fine#connection.sendall(b'\r\n')connection.close()
Activity
jay commentedon Apr 1, 2021
Probably there should be a check that all the headers were received before deciding whether to retry the request due to auth.