[issue12319] [http.client] HTTPConnection.request not support "chunked" Transfer-Encoding to send data
Martin Panter
report at bugs.python.org
Wed Aug 24 08:11:03 EDT 2016
Martin Panter added the comment:
Thankyou Eryksun for the detailed explanation. Unfortunately, that means that uploading an unseekable file via urllib.request, or via http.client, isn’t going to work by default on Windows. I see a couple of workarounds with the current code:
* Users can force chunked encoding (manually pass Transfer-Encoding: chunked, and/or encode_chunked=True, depending on the API)
* Users can pass an iterator that reads the file: iter(partial(file.read, CHUNK_SIZE), b"")
But I never liked how so much behaviour depends on specific details of the upload body object anyway. Perhaps this is an opportunity to change the behaviour so that a file object always triggers chunked encoding. We could add a note to <https://docs.python.org/3.6/whatsnew/3.6.html#changes-in-the-python-api> to warn that uploading files to HTTP 1.0 servers will now require Content-Length to be manually specified.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12319>
_______________________________________
More information about the Python-bugs-list
mailing list