[Python-Dev] availability of httplib.HTTPResponse.close

Thomas Lee tom at vector-seven.com
Wed May 14 12:37:50 CEST 2008


I was debating whether this was truly a question for python-dev or if I 
should take it to one of the user lists. Ultimately it feels like a 
question about the implementation of a core module, so hopefully nobody 
minds me posting it here. :)

Although not listed as a public API method in the documentation, it 
would seem the httplib.HTTPResponse.close method might be useful in the 
event we don't want to actually read any of the data being sent back 
from the server.

If I'm to assume that an undocumented method is considered "private", 
currently the only way to force the underlying file-like socket wrapper 
to close is by calling read() until no more data remains (as per the 
documentation).

What's the reasoning behind requiring callers to read() all the pending 
data vs. just closing the socket? Is the close method really off limits 
to code using HTTPResponse?

Cheers,
Tom


More information about the Python-Dev mailing list