Add stream docstring (#1200)

* Add stream() docstring

* Update docs
This commit is contained in:
Joe 2020-08-20 17:28:28 +08:00 committed by GitHub
parent bd8165a1b1
commit 924fa8c9dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View File

@ -31,18 +31,21 @@
::: httpx.delete
:docstring:
::: httpx.stream
:docstring:
## `Client`
::: httpx.Client
:docstring:
:members: headers cookies params auth request get head options post put patch delete build_request send close
:members: headers cookies params auth request get head options post put patch delete stream build_request send close
## `AsyncClient`
::: httpx.AsyncClient
:docstring:
:members: headers cookies params auth request get head options post put patch delete build_request send aclose
:members: headers cookies params auth request get head options post put patch delete stream build_request send aclose
## `Response`

View File

@ -118,6 +118,16 @@ def stream(
cert: CertTypes = None,
trust_env: bool = True,
) -> StreamContextManager:
"""
Alternative to `httpx.request()` that streams the response body
instead of loading it into memory at once.
**Parameters**: See `httpx.request`.
See also: [Streaming Responses][0]
[0]: /quickstart#streaming-responses
"""
client = Client(proxies=proxies, cert=cert, verify=verify, trust_env=trust_env)
request = Request(
method=method,

View File

@ -191,6 +191,16 @@ class BaseClient:
allow_redirects: bool = True,
timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,
) -> "StreamContextManager":
"""
Alternative to `httpx.request()` that streams the response body
instead of loading it into memory at once.
**Parameters**: See `httpx.request`.
See also: [Streaming Responses][0]
[0]: /quickstart#streaming-responses
"""
request = self.build_request(
method=method,
url=url,