add __str__ methods, and refine a self.sock close test

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3440 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2006-09-15 18:07:13 +00:00
parent cdca8ef7ca
commit 2a75dff16e

View file

@ -288,6 +288,10 @@ class HTTPResponse:
self.length = _UNKNOWN # number of bytes left in response
self.will_close = _UNKNOWN # conn will close at end of response
def __str__ (self):
return "<HTTPResponse status=%s reason=%s chunked=%s length=%s>" % \
(self.status, self.reason, self.chunked, self.length)
def _read_status(self):
# Initialize with Simple-Response defaults
line = self.fp.readline()
@ -589,6 +593,10 @@ class HTTPConnection:
if strict is not None:
self.strict = strict
def __str__ (self):
return "<HttpConnection state=%s method=%s sock=%s buffer=%s>" % \
(self.__state, self._method, self.sock, self._buffer)
def _set_hostport(self, host, port):
if port is None:
i = host.rfind(':')
@ -622,9 +630,9 @@ class HTTPConnection:
except socket.error, msg:
if self.debuglevel > 0:
print 'connect fail:', (self.host, self.port)
if self.sock:
if self.sock is not None:
self.sock.close()
self.sock = None
self.sock = None
continue
break
if not self.sock: