From ec184107aed12236900f82b9c49471b646af16fd Mon Sep 17 00:00:00 2001 From: Anorov Date: Thu, 20 Dec 2012 02:30:17 -0500 Subject: Update urllib3/packages/socksipy/socks.py Fix for HTTP proxy negotiation. --- urllib3/packages/socksipy/socks.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/urllib3/packages/socksipy/socks.py b/urllib3/packages/socksipy/socks.py index 407715e1..4cc987b9 100644 --- a/urllib3/packages/socksipy/socks.py +++ b/urllib3/packages/socksipy/socks.py @@ -324,10 +324,14 @@ class socksocket(socket.socket): else: addr = destaddr self.sendall(("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n").encode()) + # We read the response until we get the string "\r\n\r\n" - resp = self.recv(1) - while resp.find("\r\n\r\n".encode()) == -1: - resp = resp + self.recv(1) + resp = self.recv(4096) + while "\r\n\r\n" not in resp: + d = self.recv(4096) + if not d: + raise GeneralProxyError((0, "connection closed unexpectedly")) + resp += d # We just need the first line to check if the connection # was successful statusline = resp.splitlines()[0].split(" ".encode(), 2) -- cgit v1.2.1