classification
Title: httplib specifies content-length when transfer-encoding present
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: apmatthews, cheryl.sabella
Priority: normal Keywords: patch

Created on 2019-09-30 20:24 by apmatthews, last changed 2020-01-12 20:27 by cheryl.sabella. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16501 closed apmatthews, 2019-09-30 20:34
Messages (3)
msg353617 - (view) Author: (apmatthews) * Date: 2019-09-30 20:24
RFC 7230 3.3.2 states "A sender MUST NOT send a Content-Length header field in any message that contains a Transfer-Encoding header field."

When trying to perform a chunked request:

import httplib
http = httplib.HTTPSConnection('google.com')
http.request("POST", '/', None, {'Content-Type': 'text/plain',
                                 'Transfer-Encoding': 'chunked'})

Resulting headers include:

Content-Length: 0
Transfer-Encoding: chunked

The receiving server should ignore the Content-Length in this case but some versions of IIS don't and consequently fail to accept the chunks that follow.
msg359767 - (view) Author: (apmatthews) * Date: 2020-01-10 23:01
ping :)
msg359867 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2020-01-12 20:27
Hi @apmatthews, thank you for the report and for the pull request.  Unfortunately, Python 2.7 reached end of life on 1/1/2020, so no additional changes are being incorporated into Python 2.  Looking at the documentation for Python 3, I think it's OK there (https://docs.python.org/3/library/http.client.html#http.client.HTTPConnection.request).
History
Date User Action Args
2020-01-12 20:27:25cheryl.sabellasetstatus: open -> closed

nosy: + cheryl.sabella
messages: + msg359867

resolution: wont fix
stage: patch review -> resolved
2020-01-10 23:01:43apmatthewssetmessages: + msg359767
2019-09-30 20:34:23apmatthewssetkeywords: + patch
stage: patch review
pull_requests: + pull_request16090
2019-09-30 20:24:01apmatthewscreate