diff options
author | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 13:19:42 -0700 |
---|---|---|
committer | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 13:19:42 -0700 |
commit | c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a (patch) | |
tree | 2c14ecbc5e10513419b15f690e7bddfdb2dab75e /docs/index.rst | |
parent | b6ab7bae87b22c6fae783e8850533219d3bf8a29 (diff) | |
download | python-urllib3-c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a.tar python-urllib3-c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a.tar.gz |
Imported Upstream version 1.10.4
Diffstat (limited to 'docs/index.rst')
-rw-r--r-- | docs/index.rst | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/index.rst b/docs/index.rst index 1fc8a9c..81ac2d8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,6 +11,7 @@ urllib3 Documentation helpers collections contrib + security Highlights @@ -257,6 +258,35 @@ disabled individually. See the :class:`~urllib3.util.retry.Retry` definition for more details. +Stream +------ + +You may also stream your response and get data as they come (e.g. when using +``transfer-encoding: chunked``). In this case, method +:func:`~urllib3.response.HTTPResponse.stream` will return generator. + +:: + + >>> from urllib3 import PoolManager + >>> http = urllib3.PoolManager() + + >>> r = http.request("GET", "http://httpbin.org/stream/3") + >>> r.getheader("transfer-encoding") + 'chunked' + + >>> for chunk in r.stream(): + ... print chunk + {"url": "http://httpbin.org/stream/3", ..., "id": 0, ...} + {"url": "http://httpbin.org/stream/3", ..., "id": 1, ...} + {"url": "http://httpbin.org/stream/3", ..., "id": 2, ...} + >>> r.closed + True + +Completely consuming the stream will auto-close the response and release +the connection back to the pool. If you're only partially consuming the +consuming a stream, make sure to manually call ``r.close()`` on the +response. + Foundation ---------- |