gesomax / httplib2

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

Failure to handle server legitimately closing connection before request body is fully sent #51

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I came across this problem when attempting to PUT an attachment using
CouchDB-Python with auth credentials:
http://code.google.com/p/couchdb-python/issues/detail?id=68

It seems there is also a bug in Python's standard httplib module:
http://bugs.python.org/issue5542

I've attached a patch for httplib2.

Essentially the problem is that CouchDB sends a 401 response as soon as it
has received the request headers, and before the request body has been
fully sent.  Hence, it closes the socket before the request body is fully
sent, causing a broken pipe error.  Python's httplib catches this and
prematurely closes the socket before we can read the response.  The patch
for httplib2 just catches httplib.CannotSendRequest and tries to read the
response anyway even if sending the request fails.

Original issue reported on code.google.com by jason.da...@gmail.com on 23 Mar 2009 at 9:40

Attachments:

GoogleCodeExporter commented 8 years ago
Just tested this under Linux and realised it needs to catch "connection reset by
peer" errors too.  Attached updated patch.

Original comment by jason.da...@gmail.com on 23 Mar 2009 at 11:03

Attachments:

GoogleCodeExporter commented 8 years ago
Fixed in 1457646c54 

Original comment by joe.gregorio@gmail.com on 26 Dec 2009 at 5:11

GoogleCodeExporter commented 8 years ago
Note: This change resulted in issue 51.

Original comment by tre...@gmail.com on 30 Mar 2010 at 8:42

GoogleCodeExporter commented 8 years ago
Jason, would you be able to take a look at my question at 
http://code.google.com/p/httplib2/issues/detail?
id=62#c9

Thanks.

Original comment by tre...@gmail.com on 30 Mar 2010 at 8:51