diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-03 13:30:02 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-03 13:30:02 (GMT) |
commit | 811fc1493593a07288ef125ec733454befd4f7ee (patch) | |
tree | 7f1e92a1691ffb77eb8d14992a8b71544625c07f /Lib/httplib.py | |
parent | 4737482fada222f2353b9abc9bcf14bfac49fb79 (diff) | |
download | cpython-811fc1493593a07288ef125ec733454befd4f7ee.zip cpython-811fc1493593a07288ef125ec733454befd4f7ee.tar.gz cpython-811fc1493593a07288ef125ec733454befd4f7ee.tar.bz2 |
Fix status line parsing for http response.
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r-- | Lib/httplib.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index 5c15f9d..297f1e3 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -264,7 +264,7 @@ class HTTPMessage(mimetools.Message): except IOError: startofline = tell = None self.seekable = 0 - line = self.fp.readline() + line = str(self.fp.readline(), "iso-8859-1") if not line: self.status = 'EOF in headers' break @@ -317,6 +317,11 @@ class HTTPResponse: # See RFC 2616 sec 19.6 and RFC 1945 sec 6 for details. + # The bytes from the socket object are iso-8859-1 strings. + # See RFC 2616 sec 2.2 which notes an exception for MIME-encoded + # text following RFC 2047. The basic status line parsing only + # accepts iso-8859-1. + def __init__(self, sock, debuglevel=0, strict=0, method=None): self.fp = sock.makefile('rb', 0) self.debuglevel = debuglevel @@ -337,7 +342,7 @@ class HTTPResponse: def _read_status(self): # Initialize with Simple-Response defaults - line = self.fp.readline() + line = str(self.fp.readline(), "iso-8859-1") if self.debuglevel > 0: print("reply:", repr(line)) if not line: |