This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jasondavies
Recipients jasondavies
Date 2009-03-23.09:29:06
SpamBayes Score 4.989308e-05
Marked as misclassified No
Message-id <1237800550.85.0.782891199129.issue5542@psf.upfronthosting.co.za>
In-reply-to
Content
I came across this bug when trying to use CouchDB-Python to PUT an
attachment using HTTP authentication (using the httplib2 library). 
Essentially what httplib2 does is this:

1. Attempt PUT with no auth credentials
2. If a 401 response is received, try again with credentials

However, CouchDB sends a 401 response as soon as it has consumed the
request headers, and before the request body has been fully sent by the
client.

This triggers a bug in both httplib and httplib2, whereby they raise
exceptions due to a broken pipe being encountered when trying to finish
sending the request body.

It seems that Python's httplib checks for broken pipe errors and closes
the connection entirely when they occur when making a request.  This is
unhelpful if a legitimate response was sent and the socket was closed
early by the server.

The offending try/except handler is in httplib.HttpConnection.send and
has a comment saying:

# send the data to the server. if we get a broken pipe, then close
# the socket. we want to reconnect when somebody tries to send again.

This is wrong, as someone might want to read the response before closing
the socket.

For reference, the CouchDB-Python issue is:
http://code.google.com/p/couchdb-python/issues/detail?id=68

This bug may also be related to: http://bugs.python.org/issue3566
History
Date User Action Args
2009-03-23 09:29:11jasondaviessetrecipients: + jasondavies
2009-03-23 09:29:10jasondaviessetmessageid: <1237800550.85.0.782891199129.issue5542@psf.upfronthosting.co.za>
2009-03-23 09:29:09jasondavieslinkissue5542 messages
2009-03-23 09:29:06jasondaviescreate