diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2003-05-05 16:13:58 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2003-05-05 16:13:58 (GMT) |
commit | c1b2cb9d8f70ed3a1209f53eae38f69be8248fcb (patch) | |
tree | 4910fb718225472f96cf2a7a3b540fdd922dadd3 /Lib/httplib.py | |
parent | 581c36773a5915411611d7079b62dce9976adaf1 (diff) | |
download | cpython-c1b2cb9d8f70ed3a1209f53eae38f69be8248fcb.zip cpython-c1b2cb9d8f70ed3a1209f53eae38f69be8248fcb.tar.gz cpython-c1b2cb9d8f70ed3a1209f53eae38f69be8248fcb.tar.bz2 |
SF bug 622042: Don't expect response body from HEAD request.
Bug fix candidate.
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r-- | Lib/httplib.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index caf6ccd..9527e29 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -208,10 +208,11 @@ class HTTPResponse: # See RFC 2616 sec 19.6 and RFC 1945 sec 6 for details. - def __init__(self, sock, debuglevel=0, strict=0): + def __init__(self, sock, debuglevel=0, strict=0, method=None): self.fp = sock.makefile('rb', 0) self.debuglevel = debuglevel self.strict = strict + self._method = method self.msg = None @@ -326,7 +327,8 @@ class HTTPResponse: # does the body have a fixed length? (of zero) if (status == 204 or # No Content status == 304 or # Not Modified - 100 <= status < 200): # 1xx codes + 100 <= status < 200 or # 1xx codes + self._method == 'HEAD'): self.length = 0 # if the connection remains open, and we aren't using chunked, and @@ -497,6 +499,7 @@ class HTTPConnection: self._buffer = [] self.__response = None self.__state = _CS_IDLE + self._method = None self._set_hostport(host, port) if strict is not None: @@ -626,6 +629,8 @@ class HTTPConnection: else: raise CannotSendRequest() + # Save the method we use, we need it later in the response phase + self._method = method if not url: url = '/' str = '%s %s %s' % (method, url, self._http_vsn_str) @@ -763,9 +768,11 @@ class HTTPConnection: if self.debuglevel > 0: response = self.response_class(self.sock, self.debuglevel, - strict=self.strict) + strict=self.strict, + method=self._method) else: - response = self.response_class(self.sock, strict=self.strict) + response = self.response_class(self.sock, strict=self.strict, + method=self._method) response.begin() assert response.will_close != _UNKNOWN |