]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix SF bug [ 599838 ] httplib.connect broken in 2.1 branch
authorJeremy Hylton <jeremy@alum.mit.edu>
Thu, 29 Aug 2002 20:12:26 +0000 (20:12 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Thu, 29 Aug 2002 20:12:26 +0000 (20:12 +0000)
Some IPv6-specific changes crept into the 2.1 branch when I backported
other bug fixes.

Lib/httplib.py

index 34ed2da57f5c508e999b60ddf337f8a397f22402..2b277e079941f0b3870d9396c6954360110eb6b8 100644 (file)
@@ -505,25 +505,10 @@ class HTTPConnection:
 
     def connect(self):
         """Connect to the host and port specified in __init__."""
-        msg = "getaddrinfo returns an empty list"
-        for res in socket.getaddrinfo(self.host, self.port, 0,
-                                      socket.SOCK_STREAM):
-            af, socktype, proto, canonname, sa = res
-            try:
-                self.sock = socket.socket(af, socktype, proto)
-                if self.debuglevel > 0:
-                    print "connect: (%s, %s)" % (self.host, self.port)
-                self.sock.connect(sa)
-            except socket.error, msg:
-                if self.debuglevel > 0:
-                    print 'connect fail:', (self.host, self.port)
-                if self.sock:
-                    self.sock.close()
-                self.sock = None
-                continue
-            break
-        if not self.sock:
-            raise socket.error, msg
+        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        if self.debuglevel > 0:
+            print "connect: (%s, %s)" % (self.host, self.port)
+        self.sock.connect((self.host, self.port))
 
     def close(self):
         """Close the connection to the HTTP server."""