diff Lib/http/client.py @ 51533:7bb3d515b677 3.0

Merged revisions 69513 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r69513 | antoine.pitrou | 2009-02-11 01:39:14 +0100 (mer., 11 févr. 2009) | 3 lines Issue #4631: Fix urlopen() result when an HTTP response uses chunked encoding. ........
author Antoine Pitrou <solipsis@pitrou.net>
date Wed, 11 Feb 2009 01:01:41 +0000
parents 4229a4b14f1d
children 4da5f0ded362
line wrap: on
line diff
--- a/Lib/http/client.py	Wed Feb 11 00:16:12 2009 +0000
+++ b/Lib/http/client.py	Wed Feb 11 01:01:41 2009 +0000
@@ -249,7 +249,7 @@
 
     return email.parser.Parser(_class=HTTPMessage).parsestr(hstring)
 
-class HTTPResponse:
+class HTTPResponse(io.RawIOBase):
 
     # strict: If true, raise BadStatusLine if the status line can't be
     # parsed as a valid HTTP/1.0 or 1.1 status line.  By default it is
@@ -471,8 +471,6 @@
         #          called, meaning self.isclosed() is meaningful.
         return self.fp is None
 
-    # XXX It would be nice to have readline and __iter__ for this, too.
-
     def read(self, amt=None):
         if self.fp is None:
             return b""
@@ -585,6 +583,9 @@
             amt -= len(chunk)
         return b"".join(s)
 
+    def fileno(self):
+        return self.fp.fileno()
+
     def getheader(self, name, default=None):
         if self.msg is None:
             raise ResponseNotReady()
@@ -596,6 +597,11 @@
             raise ResponseNotReady()
         return list(self.msg.items())
 
+    # We override IOBase.__iter__ so that it doesn't check for closed-ness
+
+    def __iter__(self):
+        return self
+
 
 class HTTPConnection: