diff options
| author | Kenneth Reitz <me@kennethreitz.com> | 2013-01-10 02:13:02 -0500 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.com> | 2013-01-10 02:13:02 -0500 |
| commit | 41687c8fa8e77830a8ff3f2cefa05d8a586c5132 (patch) | |
| tree | 3a87565d9f44da5d70797cafd580bbf2ffc287c3 /docs/user | |
| parent | 9d33629b6d3f4ed3a2ee0f413090b48fa10e8560 (diff) | |
| download | python-requests-41687c8fa8e77830a8ff3f2cefa05d8a586c5132.tar.gz | |
v1.1.0 and docs
Diffstat (limited to 'docs/user')
| -rw-r--r-- | docs/user/advanced.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 0bf34510..51cef7e4 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -138,6 +138,28 @@ Excellent news — thanks to urllib3, keep-alive is 100% automatic within a ses Note that connections are only released back to the pool for reuse once all body data has been read; be sure to either set ``stream`` to ``False`` or read the ``content`` property of the ``Response`` object. +Streaming Uploads +----------------- + +Requests supports streaming uploads, which allow you to send large streams or files without reading them into memory. To stream and upload, simply provide a file-like object for your body:: + + with open('massive-body') as f: + request.post('http://some.url/streamed', data=f) + + +Chunk-Encoded Requests +---------------------- + +Requests also supports Chunked transfer encoding for outgoing and incoming requests. 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' + + request.post('http://some.url/chunked', data=gen()) + + Event Hooks ----------- |
