gesomax / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

httplib blocks on response.read() for HEAD requests #56

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have tested this on Python 2.5.4 and Python 2.4.6.

Trying to read a response from a HEAD request will block and fail after
several (~50) seconds. httplib2 reads the httplib response regardless of
the request method used.

In my understanding of RFC2616 this should not be done anyway:

"The HEAD method is identical to GET except that the server MUST NOT return
a message-body in the response."

This patch fixes the problem:

http://github.com/uggedal/httplib2/commit/ce4063b6dc28aadbe5d2ff5953592668fbc1cf
22

I'm not sure if HEAD requests should return an empty string or None for
content.

The test case can probably not be used as it relies on network access. I
was unable to reproduce the read block against local files.

Original issue reported on code.google.com by ugge...@gmail.com on 28 May 2009 at 11:33

GoogleCodeExporter commented 8 years ago
I just discovered exactly this problem.  I can confirm uggedal's report, and 
that the
suggested fix solves the problem..  

In my case, it occurs when I did a HEAD request for a nonexistent file stored in
Amazon S3.  (My Python is 2.4.4)  That request returned an httplib.HTTPResponse
instance with "'chunked':1" and "'fp': <httplib.SSLFile instance at 0x108bda4c>"
atts.  These caused a call to httplib "_read_chunked()", which choked trying to 
read
the body.  My server took longer (3 minutes) to give up.

~ Thanks
~ Ken

P.S.  As a newcomer to messing with the code of products like httplib2, I'm 
wondering
what advice people have about what to do when the system I'm building gets 
installed
in a new environment and/or when a new version of httplib2 comes out if it 
fails to
include this fix?  Is there anything better than just trying to remember all the
things like this I have done, so I can redo them when necessary?

Original comment by kenatsun@gmail.com on 10 Jun 2009 at 11:15

GoogleCodeExporter commented 8 years ago
This issue was closed by a415e1667b.

Original comment by joe.gregorio@gmail.com on 16 Jul 2009 at 4:28

GoogleCodeExporter commented 8 years ago
Fixed in trunk.

Original comment by joe.gregorio@gmail.com on 16 Jul 2009 at 4:28