summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGreg Stein <gstein@lyra.org>2003-06-24 06:35:19 (GMT)
committerGreg Stein <gstein@lyra.org>2003-06-24 06:35:19 (GMT)
commit616a58d79af2ae34430548156cfa7b44c55c700a (patch)
treeef48e87c15deb8f8ba2987ee1937ec6b1a34eeed /Lib
parent8a99b5023931c5a01540bda67516235a8dfe8470 (diff)
downloadcpython-616a58d79af2ae34430548156cfa7b44c55c700a.zip
cpython-616a58d79af2ae34430548156cfa7b44c55c700a.tar.gz
cpython-616a58d79af2ae34430548156cfa7b44c55c700a.tar.bz2
Deal with a couple XXX comments which asked questions.
In response to "shouldn't the client close the file?", the answer is "no". The original design behind HTTPConnection is that the client did not have to worry about it. The response would close itself when you read the last of the data from it. This closing also dealt with allowing the connection to perform another request/response (if it was a persistent connection). However... the auto-close behavior broke compatibility with the classic httplib.HTTP class' behavior when a zero-length response body was present. In that situation, the HTTPResponse object was auto-closing it since there was no data present, and for an HTTP/1.0 connection-close socket (or an HTTP/0.9 request) connection, that also ended up closing the socket. When an httplib.HTTP user went to read the socket... boom. A patch to correct the auto-close (for compat with old httplib users) was added in rev 1.22. But for non-zero-length *chunked* bodies, we should keep the auto-close behavior. The library user is not reading the socket (they can't cuz of the chunked response we just got done handling), so they should be immune to the response closing the socket. In fact, I would like to see (one day) the auto-close restored, and the HTTP subclass would simply have a flag to disable that behavior (for back-compat purposes).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/httplib.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 7eb9ad7..b1712d8 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -449,7 +449,6 @@ class HTTPResponse:
break
# we read everything; close the "file"
- # XXX Shouldn't the client close the file?
self.close()
return value
@@ -600,8 +599,7 @@ class HTTPConnection:
`url' specifies the object being requested, e.g. '/index.html'.
"""
- # check if a prior response has been completed
- # XXX What if it hasn't?
+ # if a prior response has been completed, then forget about it.
if self.__response and self.__response.isclosed():
self.__response = None
@@ -743,7 +741,7 @@ class HTTPConnection:
def getresponse(self):
"Get the response from the server."
- # check if a prior response has been completed
+ # if a prior response has been completed, then forget about it.
if self.__response and self.__response.isclosed():
self.__response = None