Senthil Kumaran <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue14721>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com