Expand on chunked handling.

This commit is contained in:
Cory Benfield
2015-03-18 21:31:55 +00:00
parent 86f9b1616a
commit 84cc36017a
+6 -1
View File
@@ -268,13 +268,18 @@ Requests also supports Chunked transfer encoding for outgoing and incoming reque
To send a chunk-encoded request, simply provide a generator (or any iterator without
a length) for your body::
def gen():
yield 'hi'
yield 'there'
requests.post('http://some.url/chunked', data=gen())
For chunked encoded responses, it's best to iterate over the data using
:meth:`Response.iter_content() <requests.models.Response.iter_content>`. In
an ideal situation you'll have set ``stream=True`` on the request, in which
case you can iterate chunk-by-chunk by calling ``iter_content`` with a chunk
size parameter of ``None``.
.. _multipart: