Message236686
> I'm happy to produce a patch if there's any chance it would be merged.
If the patch adheres to the RFC, then I see no reason why it shouldn't be merged. What makes this a little more tricky than the snippet that you included in your post though (which would include the Content-Length header for all HTTP methods) is the following from RFC 7230:
A user agent SHOULD send a Content-Length in a request message when
no Transfer-Encoding is sent and the request method defines a meaning
for an enclosed payload body. For example, a Content-Length header
field is normally sent in a POST request even when the value is 0
(indicating an empty payload body). 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.
Currently, there is nothing in the http package that defines whether or not a given HTTP method expects a body (as far as I'm aware at any rate), although this would be a simple addition. I'd imagine that the result might look 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)
I'd prefer to have the conversion from None to empty string done in the body of _set_content_length in order to ensure consistency should the call be made from elsewhere. |
|
Date |
User |
Action |
Args |
2015-02-26 16:41:19 | demian.brecht | set | recipients:
+ demian.brecht, jcea, orsenthil, ezio.melotti, eric.araujo, Arve.Knudsen, python-dev, piotr.dobrogost, jimr |
2015-02-26 16:41:19 | demian.brecht | set | messageid: <1424968879.04.0.759428044341.issue14721@psf.upfronthosting.co.za> |
2015-02-26 16:41:19 | demian.brecht | link | issue14721 messages |
2015-02-26 16:41:18 | demian.brecht | create | |
|