From 84cc36017a53f99e10401e8d5f050c74e8529990 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Wed, 18 Mar 2015 21:31:55 +0000 Subject: [PATCH 1/2] Expand on chunked handling. --- docs/user/advanced.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index a2fe653b..494ba696 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -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() `. 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: From 2b5cdc56f36f083666fb9abaed2adc9b9c60529b Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Sat, 18 Jul 2015 16:41:29 +0100 Subject: [PATCH 2/2] Expand on chunk length --- docs/user/advanced.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 494ba696..fccc7320 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -278,7 +278,8 @@ For chunked encoded responses, it's best to iterate over the data using :meth:`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``. +size parameter of ``None``. If you want to set a maximum size of the chunk, +you can set a chunk size parameter to any integer. .. _multipart: