Skip to content

Commit 344f425

Browse files
committed
Fix SF bug [ 599838 ] httplib.connect broken in 2.1 branch
Some IPv6-specific changes crept into the 2.1 branch when I backported other bug fixes.
1 parent 4fa82fa commit 344f425

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

Lib/httplib.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -505,25 +505,10 @@ def set_debuglevel(self, level):
505505

506506
def connect(self):
507507
"""Connect to the host and port specified in __init__."""
508-
msg = "getaddrinfo returns an empty list"
509-
for res in socket.getaddrinfo(self.host, self.port, 0,
510-
socket.SOCK_STREAM):
511-
af, socktype, proto, canonname, sa = res
512-
try:
513-
self.sock = socket.socket(af, socktype, proto)
514-
if self.debuglevel > 0:
515-
print "connect: (%s, %s)" % (self.host, self.port)
516-
self.sock.connect(sa)
517-
except socket.error, msg:
518-
if self.debuglevel > 0:
519-
print 'connect fail:', (self.host, self.port)
520-
if self.sock:
521-
self.sock.close()
522-
self.sock = None
523-
continue
524-
break
525-
if not self.sock:
526-
raise socket.error, msg
508+
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
509+
if self.debuglevel > 0:
510+
print "connect: (%s, %s)" % (self.host, self.port)
511+
self.sock.connect((self.host, self.port))
527512

528513
def close(self):
529514
"""Close the connection to the HTTP server."""

0 commit comments

Comments
 (0)