Author orsenthil
Recipients Arve.Knudsen, eric.araujo, ezio.melotti, jcea, orsenthil, piotr.dobrogost
Date 2012-05-19.08:05:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The rule for content-length seems, if there is a body for a request, even if the body is "" ( empty body), then you should send the Content-Length.

The mistake in the Python httplib was, the set_content_length was called with this condition.

if body and ('content-length' not in header_names):

If the body was '', this was skipped. The default for GET and methods which do not use body was body=None and that was statement for correct in those cases.

A simple fix which covers the applicable methods and follows the definition of content-length seems to me like this:

-        if body and ('content-length' not in header_names):
+        if body is not None and 'content-length' not in header_names:

I prefer this rather than checking for methods explicitly as it could go into unnecessary details. (Things like if you are not sending a body why are you sending a Content-Length?. This fails the definition of Content-Length itself). The Patch is fine, I would adopt that for the above check and commit it all the active versions.

Thanks Arve Knudsen, for the bug report and the patch.
Date User Action Args
2012-05-19 08:05:01orsenthilsetrecipients: + orsenthil, jcea, ezio.melotti, eric.araujo, Arve.Knudsen, piotr.dobrogost
2012-05-19 08:05:01orsenthilsetmessageid: <>
2012-05-19 08:05:01orsenthillinkissue14721 messages
2012-05-19 08:05:00orsenthilcreate