]> granicus.if.org Git - python/commit
Issue #12319: Support for chunked encoding of HTTP request bodies
authorMartin Panter <vadmium+py@gmail.com>
Wed, 24 Aug 2016 06:33:33 +0000 (06:33 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Wed, 24 Aug 2016 06:33:33 +0000 (06:33 +0000)
commit3c0d0baf2badfad7deb346d1043f7d83bb92691f
tree968ca71729f519aaf6ebb38477efdc73e5ae3ae9
parenta790fe7ff86f193670b3d8287b22c72cbe675c7b
Issue #12319: Support for chunked encoding of HTTP request bodies

When the body object is a file, its size is no longer determined with
fstat(), since that can report the wrong result (e.g. reading from a pipe).
Instead, determine the size using seek(), or fall back to chunked encoding
for unseekable files.

Also, change the logic for detecting text files to check for TextIOBase
inheritance, rather than inspecting the “mode” attribute, which may not
exist (e.g. BytesIO and StringIO).  The Content-Length for text files is no
longer determined ahead of time, because the original logic could have been
wrong depending on the codec and newline translation settings.

Patch by Demian Brecht and Rolf Krahl, with a few tweaks by me.
Doc/library/http.client.rst
Doc/library/urllib.request.rst
Doc/whatsnew/3.6.rst
Lib/http/client.py
Lib/test/test_httplib.py
Lib/test/test_urllib2.py
Lib/urllib/request.py
Misc/ACKS
Misc/NEWS