Message236803
#14721 solved setting the Content-Length header for 0-length bodies. However, it doesn't account for cases where body is None (reported by James Rutherford here: http://bugs.python.org/issue14721#msg236600).
One method of solving this might be something like this:
_METHODS_EXPECTING_BODIES = {'OPTIONS', 'POST', 'PUT', 'PATCH'}
if method.upper() in _METHODS_EXPECTING_BODIES and \
'content-length' not in header_names:
self._set_content_length(body)
(_set_content_length would have to be updated in order to allow for None)
This ensures that Content-Length will not be set for methods not expecting a body.
RFC 7230, Section 3.3.2:
A user agent SHOULD NOT send a Content-Length header field when the
request message does not contain a payload body and the method
semantics do not anticipate such a body. |
|
Date |
User |
Action |
Args |
2015-02-27 17:30:43 | demian.brecht | set | recipients:
+ demian.brecht |
2015-02-27 17:30:43 | demian.brecht | set | messageid: <1425058243.4.0.797359828619.issue23539@psf.upfronthosting.co.za> |
2015-02-27 17:30:43 | demian.brecht | link | issue23539 messages |
2015-02-27 17:30:43 | demian.brecht | create | |
|