httpx API Reference
Full documentation for httpx (0.27.0)
httpx.ASGITransport
Python Library Documentation: class ASGITransport in module httpx
class ASGITransport(AsyncBaseTransport)
| ASGITransport(app: '_ASGIApp', raise_app_exceptions: 'bool' = True, root_path: 'str' = '', client: 'tuple[str, int]' = ('127.0.0.1', 123)) -> 'None'
|
| A custom AsyncTransport that handles sending requests directly to an ASGI app.
| The simplest way to use this functionality is to use the `app` argument.
|
| ```
| client = httpx.AsyncClient(app=app)
| ```
|
| Alternatively, you can setup the transport instance explicitly.
| This allows you to include any additional configuration arguments specific
| to the ASGITransport class:
|
| ```
| transport = httpx.ASGITransport(
| app=app,
| root_path="/submount",
| client=("1.2.3.4", 123)
| )
| client = httpx.AsyncClient(transport=transport)
| ```
|
| Arguments:
|
| * `app` - The ASGI application.
| * `raise_app_exceptions` - Boolean indicating if exceptions in the application
| should be raised. Default to `True`. Can be set to `False` for use cases
| such as testing the content of a client 500 response.
| * `root_path` - The root path on which the ASGI application should be mounted.
| * `client` - A two-tuple indicating the client IP and port of incoming requests.
| ```
|
| Method resolution order:
| ASGITransport
| AsyncBaseTransport
| builtins.object
|
| Methods defined here:
|
| __init__(self, app: '_ASGIApp', raise_app_exceptions: 'bool' = True, root_path: 'str' = '', client: 'tuple[str, int]' = ('127.0.0.1', 123)) -> 'None' from httpx._transports.asgi.ASGITransport
| Initialize self. See help(type(self)) for accurate signature.
|
| async handle_async_request(self, request: 'Request') -> 'Response' from httpx._transports.asgi.ASGITransport
|
| ----------------------------------------------------------------------
| Methods inherited from AsyncBaseTransport:
|
| async __aenter__(self: 'A') -> 'A' from httpx._transports.base.AsyncBaseTransport
|
| async __aexit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._transports.base.AsyncBaseTransport
|
| async aclose(self) -> 'None' from httpx._transports.base.AsyncBaseTransport
|
| ----------------------------------------------------------------------
| Data descriptors inherited from AsyncBaseTransport:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
httpx.AsyncBaseTransport
Python Library Documentation: class AsyncBaseTransport in module httpx class AsyncBaseTransport(builtins.object) | Methods defined here: | | async __aenter__(self: 'A') -> 'A' from httpx._transports.base.AsyncBaseTransport | | async __aexit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._transports.base.AsyncBaseTransport | | async aclose(self) -> 'None' from httpx._transports.base.AsyncBaseTransport | | async handle_async_request(self, request: 'Request') -> 'Response' from httpx._transports.base.AsyncBaseTransport | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.AsyncByteStream
Python Library Documentation: class AsyncByteStream in module httpx class AsyncByteStream(builtins.object) | Methods defined here: | | async __aiter__(self) -> AsyncIterator[bytes] from httpx._types.AsyncByteStream | | async aclose(self) -> None from httpx._types.AsyncByteStream | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.AsyncClient
Python Library Documentation: class AsyncClient in module httpx
class AsyncClient(httpx._client.BaseClient)
| AsyncClient(*, auth: 'AuthTypes | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, http1: 'bool' = True, http2: 'bool' = False, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, mounts: 'None | typing.Mapping[str, AsyncBaseTransport | None]' = None, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), follow_redirects: 'bool' = False, limits: 'Limits' = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), max_redirects: 'int' = 20, event_hooks: 'None | typing.Mapping[str, list[typing.Callable[..., typing.Any]]]' = None, base_url: 'URLTypes' = '', transport: 'AsyncBaseTransport | None' = None, app: 'typing.Callable[..., typing.Any] | None' = None, trust_env: 'bool' = True, default_encoding: 'str | typing.Callable[[bytes], str]' = 'utf-8') -> 'None'
|
| An asynchronous HTTP client, with connection pooling, HTTP/2, redirects,
| cookie persistence, etc.
|
| It can be shared between tasks.
|
| Usage:
|
| ```python
| >>> async with httpx.AsyncClient() as client:
| >>> response = await client.get('https://example.org')
| ```
|
| **Parameters:**
|
| * **auth** - *(optional)* An authentication class to use when sending
| requests.
| * **params** - *(optional)* Query parameters to include in request URLs, as
| a string, dictionary, or sequence of two-tuples.
| * **headers** - *(optional)* Dictionary of HTTP headers to include when
| sending requests.
| * **cookies** - *(optional)* Dictionary of Cookie items to include when
| sending requests.
| * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to
| verify the identity of requested hosts. Either `True` (default CA bundle),
| a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
| (which will disable verification).
| * **cert** - *(optional)* An SSL certificate used by the requested host
| to authenticate the client. Either a path to an SSL certificate file, or
| two-tuple of (certificate file, key file), or a three-tuple of (certificate
| file, key file, password).
| * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be
| enabled. Defaults to `False`.
| * **proxy** - *(optional)* A proxy URL where all the traffic should be routed.
| * **proxies** - *(optional)* A dictionary mapping HTTP protocols to proxy
| URLs.
| * **timeout** - *(optional)* The timeout configuration to use when sending
| requests.
| * **limits** - *(optional)* The limits configuration to use.
| * **max_redirects** - *(optional)* The maximum number of redirect responses
| that should be followed.
| * **base_url** - *(optional)* A URL to use as the base when building
| request URLs.
| * **transport** - *(optional)* A transport class to use for sending requests
| over the network.
| * **app** - *(optional)* An ASGI application to send requests to,
| rather than sending actual network requests.
| * **trust_env** - *(optional)* Enables or disables usage of environment
| variables for configuration.
| * **default_encoding** - *(optional)* The default encoding to use for decoding
| response text, if no charset information is included in a response Content-Type
| header. Set to a callable for automatic character set detection. Default: "utf-8".
|
| Method resolution order:
| AsyncClient
| httpx._client.BaseClient
| builtins.object
|
| Methods defined here:
|
| async __aenter__(self: 'U') -> 'U' from httpx._client.AsyncClient
|
| async __aexit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._client.AsyncClient
|
| __init__(self, *, auth: 'AuthTypes | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, http1: 'bool' = True, http2: 'bool' = False, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, mounts: 'None | typing.Mapping[str, AsyncBaseTransport | None]' = None, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), follow_redirects: 'bool' = False, limits: 'Limits' = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), max_redirects: 'int' = 20, event_hooks: 'None | typing.Mapping[str, list[typing.Callable[..., typing.Any]]]' = None, base_url: 'URLTypes' = '', transport: 'AsyncBaseTransport | None' = None, app: 'typing.Callable[..., typing.Any] | None' = None, trust_env: 'bool' = True, default_encoding: 'str | typing.Callable[[bytes], str]' = 'utf-8') -> 'None' from httpx._client.AsyncClient
| Initialize self. See help(type(self)) for accurate signature.
|
| async aclose(self) -> 'None' from httpx._client.AsyncClient
| Close transport and proxies.
|
| async delete(self, url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `DELETE` request.
|
| **Parameters**: See `httpx.request`.
|
| async get(self, url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `GET` request.
|
| **Parameters**: See `httpx.request`.
|
| async head(self, url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `HEAD` request.
|
| **Parameters**: See `httpx.request`.
|
| async options(self, url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send an `OPTIONS` request.
|
| **Parameters**: See `httpx.request`.
|
| async patch(self, url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `PATCH` request.
|
| **Parameters**: See `httpx.request`.
|
| async post(self, url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `POST` request.
|
| **Parameters**: See `httpx.request`.
|
| async put(self, url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `PUT` request.
|
| **Parameters**: See `httpx.request`.
|
| async request(self, method: 'str', url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Build and send a request.
|
| Equivalent to:
|
| ```python
| request = client.build_request(...)
| response = await client.send(request, ...)
| ```
|
| See `AsyncClient.build_request()`, `AsyncClient.send()`
| and [Merging of configuration][0] for how the various parameters
| are merged with client-level configuration.
|
| [0]: /advanced/#merging-of-configuration
|
| async send(self, request: 'Request', *, stream: 'bool' = False, auth: 'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>) -> 'Response' from httpx._client.AsyncClient
| Send a request.
|
| The request is sent as-is, unmodified.
|
| Typically you'll want to build one with `AsyncClient.build_request()`
| so that any client-level configuration is merged into the request,
| but passing an explicit `httpx.Request()` is supported as well.
|
| See also: [Request instances][0]
|
| [0]: /advanced/#request-instances
|
| stream(self, method: 'str', url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'typing.AsyncIterator[Response]' from httpx._client.AsyncClient
| 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
|
| ----------------------------------------------------------------------
| Methods inherited from httpx._client.BaseClient:
|
| build_request(self, method: 'str', url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Request'
| Build and return a request instance.
|
| * The `params`, `headers` and `cookies` arguments
| are merged with any values set on the client.
| * The `url` argument is merged with any `base_url` set on the client.
|
| See also: [Request instances][0]
|
| [0]: /advanced/#request-instances
|
| ----------------------------------------------------------------------
| Readonly properties inherited from httpx._client.BaseClient:
|
| is_closed
| Check if the client being closed
|
| trust_env
|
| ----------------------------------------------------------------------
| Data descriptors inherited from httpx._client.BaseClient:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| auth
| Authentication class used when none is passed at the request-level.
|
| See also [Authentication][0].
|
| [0]: /quickstart/#authentication
|
| base_url
| Base URL to use when sending requests with relative URLs.
|
| cookies
| Cookie values to include when sending requests.
|
| event_hooks
|
| headers
| HTTP headers to include when sending requests.
|
| params
| Query parameters to include in the URL when sending requests.
|
| timeout
httpx.AsyncHTTPTransport
Python Library Documentation: class AsyncHTTPTransport in module httpx class AsyncHTTPTransport(AsyncBaseTransport) | AsyncHTTPTransport(verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, http1: 'bool' = True, http2: 'bool' = False, limits: 'Limits' = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), trust_env: 'bool' = True, proxy: 'ProxyTypes | None' = None, uds: 'str | None' = None, local_address: 'str | None' = None, retries: 'int' = 0, socket_options: 'typing.Iterable[SOCKET_OPTION] | None' = None) -> 'None' | | Method resolution order: | AsyncHTTPTransport | AsyncBaseTransport | builtins.object | | Methods defined here: | | async __aenter__(self: 'A') -> 'A' from httpx._transports.default.AsyncHTTPTransport | | async __aexit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._transports.default.AsyncHTTPTransport | | __init__(self, verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, http1: 'bool' = True, http2: 'bool' = False, limits: 'Limits' = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), trust_env: 'bool' = True, proxy: 'ProxyTypes | None' = None, uds: 'str | None' = None, local_address: 'str | None' = None, retries: 'int' = 0, socket_options: 'typing.Iterable[SOCKET_OPTION] | None' = None) -> 'None' from httpx._transports.default.AsyncHTTPTransport | Initialize self. See help(type(self)) for accurate signature. | | async aclose(self) -> 'None' from httpx._transports.default.AsyncHTTPTransport | | async handle_async_request(self, request: 'Request') -> 'Response' from httpx._transports.default.AsyncHTTPTransport | | ---------------------------------------------------------------------- | Data descriptors inherited from AsyncBaseTransport: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.Auth
Python Library Documentation: class Auth in module httpx class Auth(builtins.object) | Base class for all authentication schemes. | | To implement a custom authentication scheme, subclass `Auth` and override | the `.auth_flow()` method. | | If the authentication scheme does I/O such as disk access or network calls, or uses | synchronization primitives such as locks, you should override `.sync_auth_flow()` | and/or `.async_auth_flow()` instead of `.auth_flow()` to provide specialized | implementations that will be used by `Client` and `AsyncClient` respectively. | | Methods defined here: | | async async_auth_flow(self, request: 'Request') -> 'typing.AsyncGenerator[Request, Response]' from httpx._auth.Auth | Execute the authentication flow asynchronously. | | By default, this defers to `.auth_flow()`. You should override this method | when the authentication scheme does I/O and/or uses concurrency primitives. | | auth_flow(self, request: 'Request') -> 'typing.Generator[Request, Response, None]' from httpx._auth.Auth | Execute the authentication flow. | | To dispatch a request, `yield` it: | | ``` | yield request | ``` | | The client will `.send()` the response back into the flow generator. You can | access it like so: | | ``` | response = yield request | ``` | | A `return` (or reaching the end of the generator) will result in the | client returning the last response obtained from the server. | | You can dispatch as many requests as is necessary. | | sync_auth_flow(self, request: 'Request') -> 'typing.Generator[Request, Response, None]' from httpx._auth.Auth | Execute the authentication flow synchronously. | | By default, this defers to `.auth_flow()`. You should override this method | when the authentication scheme does I/O and/or uses concurrency primitives. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | requires_request_body = False | | requires_response_body = False
httpx.BaseTransport
Python Library Documentation: class BaseTransport in module httpx class BaseTransport(builtins.object) | Methods defined here: | | __enter__(self: 'T') -> 'T' from httpx._transports.base.BaseTransport | | __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._transports.base.BaseTransport | | close(self) -> 'None' from httpx._transports.base.BaseTransport | | handle_request(self, request: 'Request') -> 'Response' from httpx._transports.base.BaseTransport | Send a single HTTP request and return a response. | | Developers shouldn't typically ever need to call into this API directly, | since the Client class provides all the higher level user-facing API | niceties. | | In order to properly release any network resources, the response | stream should *either* be consumed immediately, with a call to | `response.stream.read()`, or else the `handle_request` call should | be followed with a try/finally block to ensuring the stream is | always closed. | | Example usage: | | with httpx.HTTPTransport() as transport: | req = httpx.Request( | method=b"GET", | url=(b"https", b"www.example.com", 443, b"/"), | headers=[(b"Host", b"www.example.com")], | ) | resp = transport.handle_request(req) | body = resp.stream.read() | print(resp.status_code, resp.headers, body) | | | Takes a `Request` instance as the only argument. | | Returns a `Response` instance. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.BasicAuth
Python Library Documentation: class BasicAuth in module httpx class BasicAuth(Auth) | BasicAuth(username: 'str | bytes', password: 'str | bytes') -> 'None' | | Allows the 'auth' argument to be passed as a (username, password) pair, | and uses HTTP Basic authentication. | | Method resolution order: | BasicAuth | Auth | builtins.object | | Methods defined here: | | __init__(self, username: 'str | bytes', password: 'str | bytes') -> 'None' from httpx._auth.BasicAuth | Initialize self. See help(type(self)) for accurate signature. | | auth_flow(self, request: 'Request') -> 'typing.Generator[Request, Response, None]' from httpx._auth.BasicAuth | Execute the authentication flow. | | To dispatch a request, `yield` it: | | ``` | yield request | ``` | | The client will `.send()` the response back into the flow generator. You can | access it like so: | | ``` | response = yield request | ``` | | A `return` (or reaching the end of the generator) will result in the | client returning the last response obtained from the server. | | You can dispatch as many requests as is necessary. | | ---------------------------------------------------------------------- | Methods inherited from Auth: | | async async_auth_flow(self, request: 'Request') -> 'typing.AsyncGenerator[Request, Response]' from httpx._auth.Auth | Execute the authentication flow asynchronously. | | By default, this defers to `.auth_flow()`. You should override this method | when the authentication scheme does I/O and/or uses concurrency primitives. | | sync_auth_flow(self, request: 'Request') -> 'typing.Generator[Request, Response, None]' from httpx._auth.Auth | Execute the authentication flow synchronously. | | By default, this defers to `.auth_flow()`. You should override this method | when the authentication scheme does I/O and/or uses concurrency primitives. | | ---------------------------------------------------------------------- | Data descriptors inherited from Auth: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes inherited from Auth: | | requires_request_body = False | | requires_response_body = False
httpx.ByteStream
Python Library Documentation: class ByteStream in module httpx class ByteStream(AsyncByteStream, SyncByteStream) | ByteStream(stream: 'bytes') -> 'None' | | Method resolution order: | ByteStream | AsyncByteStream | SyncByteStream | builtins.object | | Methods defined here: | | async __aiter__(self) -> 'AsyncIterator[bytes]' from httpx._content.ByteStream | | __init__(self, stream: 'bytes') -> 'None' from httpx._content.ByteStream | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) -> 'Iterator[bytes]' from httpx._content.ByteStream | | ---------------------------------------------------------------------- | Methods inherited from AsyncByteStream: | | async aclose(self) -> None from httpx._types.AsyncByteStream | | ---------------------------------------------------------------------- | Data descriptors inherited from AsyncByteStream: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Methods inherited from SyncByteStream: | | close(self) -> None from httpx._types.SyncByteStream | Subclasses can override this method to release any network resources | after a request/response cycle is complete.
httpx.Client
Python Library Documentation: class Client in module httpx
class Client(httpx._client.BaseClient)
| Client(*, auth: 'AuthTypes | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, http1: 'bool' = True, http2: 'bool' = False, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, mounts: 'None | typing.Mapping[str, BaseTransport | None]' = None, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), follow_redirects: 'bool' = False, limits: 'Limits' = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), max_redirects: 'int' = 20, event_hooks: 'None | typing.Mapping[str, list[EventHook]]' = None, base_url: 'URLTypes' = '', transport: 'BaseTransport | None' = None, app: 'typing.Callable[..., typing.Any] | None' = None, trust_env: 'bool' = True, default_encoding: 'str | typing.Callable[[bytes], str]' = 'utf-8') -> 'None'
|
| An HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc.
|
| It can be shared between threads.
|
| Usage:
|
| ```python
| >>> client = httpx.Client()
| >>> response = client.get('https://example.org')
| ```
|
| **Parameters:**
|
| * **auth** - *(optional)* An authentication class to use when sending
| requests.
| * **params** - *(optional)* Query parameters to include in request URLs, as
| a string, dictionary, or sequence of two-tuples.
| * **headers** - *(optional)* Dictionary of HTTP headers to include when
| sending requests.
| * **cookies** - *(optional)* Dictionary of Cookie items to include when
| sending requests.
| * **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to
| verify the identity of requested hosts. Either `True` (default CA bundle),
| a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
| (which will disable verification).
| * **cert** - *(optional)* An SSL certificate used by the requested host
| to authenticate the client. Either a path to an SSL certificate file, or
| two-tuple of (certificate file, key file), or a three-tuple of (certificate
| file, key file, password).
| * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be
| enabled. Defaults to `False`.
| * **proxy** - *(optional)* A proxy URL where all the traffic should be routed.
| * **proxies** - *(optional)* A dictionary mapping proxy keys to proxy
| URLs.
| * **timeout** - *(optional)* The timeout configuration to use when sending
| requests.
| * **limits** - *(optional)* The limits configuration to use.
| * **max_redirects** - *(optional)* The maximum number of redirect responses
| that should be followed.
| * **base_url** - *(optional)* A URL to use as the base when building
| request URLs.
| * **transport** - *(optional)* A transport class to use for sending requests
| over the network.
| * **app** - *(optional)* An WSGI application to send requests to,
| rather than sending actual network requests.
| * **trust_env** - *(optional)* Enables or disables usage of environment
| variables for configuration.
| * **default_encoding** - *(optional)* The default encoding to use for decoding
| response text, if no charset information is included in a response Content-Type
| header. Set to a callable for automatic character set detection. Default: "utf-8".
|
| Method resolution order:
| Client
| httpx._client.BaseClient
| builtins.object
|
| Methods defined here:
|
| __enter__(self: 'T') -> 'T' from httpx._client.Client
|
| __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._client.Client
|
| __init__(self, *, auth: 'AuthTypes | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, http1: 'bool' = True, http2: 'bool' = False, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, mounts: 'None | typing.Mapping[str, BaseTransport | None]' = None, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), follow_redirects: 'bool' = False, limits: 'Limits' = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), max_redirects: 'int' = 20, event_hooks: 'None | typing.Mapping[str, list[EventHook]]' = None, base_url: 'URLTypes' = '', transport: 'BaseTransport | None' = None, app: 'typing.Callable[..., typing.Any] | None' = None, trust_env: 'bool' = True, default_encoding: 'str | typing.Callable[[bytes], str]' = 'utf-8') -> 'None' from httpx._client.Client
| Initialize self. See help(type(self)) for accurate signature.
|
| close(self) -> 'None' from httpx._client.Client
| Close transport and proxies.
|
| delete(self, url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `DELETE` request.
|
| **Parameters**: See `httpx.request`.
|
| get(self, url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `GET` request.
|
| **Parameters**: See `httpx.request`.
|
| head(self, url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `HEAD` request.
|
| **Parameters**: See `httpx.request`.
|
| options(self, url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send an `OPTIONS` request.
|
| **Parameters**: See `httpx.request`.
|
| patch(self, url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `PATCH` request.
|
| **Parameters**: See `httpx.request`.
|
| post(self, url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `POST` request.
|
| **Parameters**: See `httpx.request`.
|
| put(self, url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `PUT` request.
|
| **Parameters**: See `httpx.request`.
|
| request(self, method: 'str', url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Build and send a request.
|
| Equivalent to:
|
| ```python
| request = client.build_request(...)
| response = client.send(request, ...)
| ```
|
| See `Client.build_request()`, `Client.send()` and
| [Merging of configuration][0] for how the various parameters
| are merged with client-level configuration.
|
| [0]: /advanced/#merging-of-configuration
|
| send(self, request: 'Request', *, stream: 'bool' = False, auth: 'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>) -> 'Response' from httpx._client.Client
| Send a request.
|
| The request is sent as-is, unmodified.
|
| Typically you'll want to build one with `Client.build_request()`
| so that any client-level configuration is merged into the request,
| but passing an explicit `httpx.Request()` is supported as well.
|
| See also: [Request instances][0]
|
| [0]: /advanced/#request-instances
|
| stream(self, method: 'str', url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at 0x000002515621D250>, follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'typing.Iterator[Response]' from httpx._client.Client
| 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
|
| ----------------------------------------------------------------------
| Methods inherited from httpx._client.BaseClient:
|
| build_request(self, method: 'str', url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object at 0x000002515621D250>, extensions: 'RequestExtensions | None' = None) -> 'Request'
| Build and return a request instance.
|
| * The `params`, `headers` and `cookies` arguments
| are merged with any values set on the client.
| * The `url` argument is merged with any `base_url` set on the client.
|
| See also: [Request instances][0]
|
| [0]: /advanced/#request-instances
|
| ----------------------------------------------------------------------
| Readonly properties inherited from httpx._client.BaseClient:
|
| is_closed
| Check if the client being closed
|
| trust_env
|
| ----------------------------------------------------------------------
| Data descriptors inherited from httpx._client.BaseClient:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| auth
| Authentication class used when none is passed at the request-level.
|
| See also [Authentication][0].
|
| [0]: /quickstart/#authentication
|
| base_url
| Base URL to use when sending requests with relative URLs.
|
| cookies
| Cookie values to include when sending requests.
|
| event_hooks
|
| headers
| HTTP headers to include when sending requests.
|
| params
| Query parameters to include in the URL when sending requests.
|
| timeout
httpx.CloseError
Python Library Documentation: class CloseError in module httpx class CloseError(NetworkError) | CloseError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Failed to close a connection. | | Method resolution order: | CloseError | NetworkError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.ConnectError
Python Library Documentation: class ConnectError in module httpx class ConnectError(NetworkError) | ConnectError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Failed to establish a connection. | | Method resolution order: | ConnectError | NetworkError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.ConnectTimeout
Python Library Documentation: class ConnectTimeout in module httpx class ConnectTimeout(TimeoutException) | ConnectTimeout(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Timed out while connecting to the host. | | Method resolution order: | ConnectTimeout | TimeoutException | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.CookieConflict
Python Library Documentation: class CookieConflict in module httpx class CookieConflict(builtins.Exception) | CookieConflict(message: 'str') -> 'None' | | Attempted to lookup a cookie by name, but multiple cookies existed. | | Can occur when calling `response.cookies.get(...)`. | | Method resolution order: | CookieConflict | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, message: 'str') -> 'None' from httpx._exceptions.CookieConflict | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.Cookies
Python Library Documentation: class Cookies in module httpx class Cookies(collections.abc.MutableMapping, typing.Generic) | Cookies(cookies: 'CookieTypes | None' = None) -> 'None' | | HTTP Cookies, as a mutable mapping. | | Method resolution order: | Cookies | collections.abc.MutableMapping | collections.abc.Mapping | collections.abc.Collection | collections.abc.Sized | collections.abc.Iterable | collections.abc.Container | typing.Generic | builtins.object | | Methods defined here: | | __bool__(self) -> 'bool' from httpx._models.Cookies | | __delitem__(self, name: 'str') -> 'None' from httpx._models.Cookies | | __getitem__(self, name: 'str') -> 'str' from httpx._models.Cookies | | __init__(self, cookies: 'CookieTypes | None' = None) -> 'None' from httpx._models.Cookies | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) -> 'typing.Iterator[str]' from httpx._models.Cookies | | __len__(self) -> 'int' from httpx._models.Cookies | | __repr__(self) -> 'str' from httpx._models.Cookies | Return repr(self). | | __setitem__(self, name: 'str', value: 'str') -> 'None' from httpx._models.Cookies | | clear(self, domain: 'str | None' = None, path: 'str | None' = None) -> 'None' from httpx._models.Cookies | Delete all cookies. Optionally include a domain and path in | order to only delete a subset of all the cookies. | | delete(self, name: 'str', domain: 'str | None' = None, path: 'str | None' = None) -> 'None' from httpx._models.Cookies | Delete a cookie by name. May optionally include domain and path | in order to specify exactly which cookie to delete. | | extract_cookies(self, response: 'Response') -> 'None' from httpx._models.Cookies | Loads any cookies based on the response `Set-Cookie` headers. | | get(self, name: 'str', default: 'str | None' = None, domain: 'str | None' = None, path: 'str | None' = None) -> 'str | None' from httpx._models.Cookies | Get a cookie by name. May optionally include domain and path | in order to specify exactly which cookie to retrieve. | | set(self, name: 'str', value: 'str', domain: 'str' = '', path: 'str' = '/') -> 'None' from httpx._models.Cookies | Set a cookie value by name. May optionally include domain and path. | | set_cookie_header(self, request: 'Request') -> 'None' from httpx._models.Cookies | Sets an appropriate 'Cookie:' HTTP header on the `Request`. | | update(self, cookies: 'CookieTypes | None' = None) -> 'None' from httpx._models.Cookies | D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. | If E present and has a .keys() method, does: for k in E: D[k] = E[k] | If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v | In either case, this is followed by: for k, v in F.items(): D[k] = v | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | __orig_bases__ = (typing.MutableMapping[str, str],) | | __parameters__ = () | | ---------------------------------------------------------------------- | Methods inherited from collections.abc.MutableMapping: | | pop(self, key, default=<object object at 0x0000025153A481F0>) | D.pop(k[,d]) -> v, remove specified key and return the corresponding value. | If key is not found, d is returned if given, otherwise KeyError is raised. | | popitem(self) | D.popitem() -> (k, v), remove and return some (key, value) pair | as a 2-tuple; but raise KeyError if D is empty. | | setdefault(self, key, default=None) | D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D | | ---------------------------------------------------------------------- | Methods inherited from collections.abc.Mapping: | | __contains__(self, key) | | __eq__(self, other) | Return self==value. | | items(self) | D.items() -> a set-like object providing a view on D's items | | keys(self) | D.keys() -> a set-like object providing a view on D's keys | | values(self) | D.values() -> an object providing a view on D's values | | ---------------------------------------------------------------------- | Data and other attributes inherited from collections.abc.Mapping: | | __hash__ = None | | __reversed__ = None | | ---------------------------------------------------------------------- | Class methods inherited from collections.abc.Collection: | | __subclasshook__(C) | Abstract classes can override this to customize issubclass(). | | This is invoked early on by abc.ABCMeta.__subclasscheck__(). | It should return True, False or NotImplemented. If it returns | NotImplemented, the normal algorithm is used. Otherwise, it | overrides the normal algorithm (and the outcome is cached). | | ---------------------------------------------------------------------- | Class methods inherited from collections.abc.Iterable: | | __class_getitem__ = GenericAlias(...) | Represent a PEP 585 generic type | | E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,). | | ---------------------------------------------------------------------- | Class methods inherited from typing.Generic: | | __init_subclass__(...) | Function to initialize subclasses.
httpx.DecodingError
Python Library Documentation: class DecodingError in module httpx class DecodingError(RequestError) | DecodingError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Decoding of the response failed, due to a malformed encoding. | | Method resolution order: | DecodingError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.DigestAuth
Python Library Documentation: class DigestAuth in module httpx
class DigestAuth(Auth)
| DigestAuth(username: 'str | bytes', password: 'str | bytes') -> 'None'
|
| Method resolution order:
| DigestAuth
| Auth
| builtins.object
|
| Methods defined here:
|
| __init__(self, username: 'str | bytes', password: 'str | bytes') -> 'None' from httpx._auth.DigestAuth
| Initialize self. See help(type(self)) for accurate signature.
|
| auth_flow(self, request: 'Request') -> 'typing.Generator[Request, Response, None]' from httpx._auth.DigestAuth
| Execute the authentication flow.
|
| To dispatch a request, `yield` it:
|
| ```
| yield request
| ```
|
| The client will `.send()` the response back into the flow generator. You can
| access it like so:
|
| ```
| response = yield request
| ```
|
| A `return` (or reaching the end of the generator) will result in the
| client returning the last response obtained from the server.
|
| You can dispatch as many requests as is necessary.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'_ALGORITHM_TO_HASH_FUNCTION': 'dict[str, typing.Ca...
|
| ----------------------------------------------------------------------
| Methods inherited from Auth:
|
| async async_auth_flow(self, request: 'Request') -> 'typing.AsyncGenerator[Request, Response]' from httpx._auth.Auth
| Execute the authentication flow asynchronously.
|
| By default, this defers to `.auth_flow()`. You should override this method
| when the authentication scheme does I/O and/or uses concurrency primitives.
|
| sync_auth_flow(self, request: 'Request') -> 'typing.Generator[Request, Response, None]' from httpx._auth.Auth
| Execute the authentication flow synchronously.
|
| By default, this defers to `.auth_flow()`. You should override this method
| when the authentication scheme does I/O and/or uses concurrency primitives.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Auth:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from Auth:
|
| requires_request_body = False
|
| requires_response_body = False
httpx.HTTPError
Python Library Documentation: class HTTPError in module httpx
class HTTPError(builtins.Exception)
| HTTPError(message: 'str') -> 'None'
|
| Base class for `RequestError` and `HTTPStatusError`.
|
| Useful for `try...except` blocks when issuing a request,
| and then calling `.raise_for_status()`.
|
| For example:
|
| ```
| try:
| response = httpx.get("https://www.example.com")
| response.raise_for_status()
| except httpx.HTTPError as exc:
| print(f"HTTP Exception for {exc.request.url} - {exc}")
| ```
|
| Method resolution order:
| HTTPError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: 'str') -> 'None' from httpx._exceptions.HTTPError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| request
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
httpx.HTTPStatusError
Python Library Documentation: class HTTPStatusError in module httpx class HTTPStatusError(HTTPError) | HTTPStatusError(message: 'str', *, request: 'Request', response: 'Response') -> 'None' | | The response had an error HTTP status of 4xx or 5xx. | | May be raised when calling `response.raise_for_status()` | | Method resolution order: | HTTPStatusError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, message: 'str', *, request: 'Request', response: 'Response') -> 'None' from httpx._exceptions.HTTPStatusError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.HTTPTransport
Python Library Documentation: class HTTPTransport in module httpx class HTTPTransport(BaseTransport) | HTTPTransport(verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, http1: 'bool' = True, http2: 'bool' = False, limits: 'Limits' = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), trust_env: 'bool' = True, proxy: 'ProxyTypes | None' = None, uds: 'str | None' = None, local_address: 'str | None' = None, retries: 'int' = 0, socket_options: 'typing.Iterable[SOCKET_OPTION] | None' = None) -> 'None' | | Method resolution order: | HTTPTransport | BaseTransport | builtins.object | | Methods defined here: | | __enter__(self: 'T') -> 'T' from httpx._transports.default.HTTPTransport | | __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._transports.default.HTTPTransport | | __init__(self, verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, http1: 'bool' = True, http2: 'bool' = False, limits: 'Limits' = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), trust_env: 'bool' = True, proxy: 'ProxyTypes | None' = None, uds: 'str | None' = None, local_address: 'str | None' = None, retries: 'int' = 0, socket_options: 'typing.Iterable[SOCKET_OPTION] | None' = None) -> 'None' from httpx._transports.default.HTTPTransport | Initialize self. See help(type(self)) for accurate signature. | | close(self) -> 'None' from httpx._transports.default.HTTPTransport | | handle_request(self, request: 'Request') -> 'Response' from httpx._transports.default.HTTPTransport | Send a single HTTP request and return a response. | | Developers shouldn't typically ever need to call into this API directly, | since the Client class provides all the higher level user-facing API | niceties. | | In order to properly release any network resources, the response | stream should *either* be consumed immediately, with a call to | `response.stream.read()`, or else the `handle_request` call should | be followed with a try/finally block to ensuring the stream is | always closed. | | Example usage: | | with httpx.HTTPTransport() as transport: | req = httpx.Request( | method=b"GET", | url=(b"https", b"www.example.com", 443, b"/"), | headers=[(b"Host", b"www.example.com")], | ) | resp = transport.handle_request(req) | body = resp.stream.read() | print(resp.status_code, resp.headers, body) | | | Takes a `Request` instance as the only argument. | | Returns a `Response` instance. | | ---------------------------------------------------------------------- | Data descriptors inherited from BaseTransport: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.Headers
Python Library Documentation: class Headers in module httpx class Headers(collections.abc.MutableMapping, typing.Generic) | Headers(headers: 'HeaderTypes | None' = None, encoding: 'str | None' = None) -> 'None' | | HTTP headers, as a case-insensitive multi-dict. | | Method resolution order: | Headers | collections.abc.MutableMapping | collections.abc.Mapping | collections.abc.Collection | collections.abc.Sized | collections.abc.Iterable | collections.abc.Container | typing.Generic | builtins.object | | Methods defined here: | | __contains__(self, key: 'typing.Any') -> 'bool' from httpx._models.Headers | | __delitem__(self, key: 'str') -> 'None' from httpx._models.Headers | Remove the header `key`. | | __eq__(self, other: 'typing.Any') -> 'bool' from httpx._models.Headers | Return self==value. | | __getitem__(self, key: 'str') -> 'str' from httpx._models.Headers | Return a single header value. | | If there are multiple headers with the same key, then we concatenate | them with commas. See: https://tools.ietf.org/html/rfc7230#section-3.2.2 | | __init__(self, headers: 'HeaderTypes | None' = None, encoding: 'str | None' = None) -> 'None' from httpx._models.Headers | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) -> 'typing.Iterator[typing.Any]' from httpx._models.Headers | | __len__(self) -> 'int' from httpx._models.Headers | | __repr__(self) -> 'str' from httpx._models.Headers | Return repr(self). | | __setitem__(self, key: 'str', value: 'str') -> 'None' from httpx._models.Headers | Set the header `key` to `value`, removing any duplicate entries. | Retains insertion order. | | copy(self) -> 'Headers' from httpx._models.Headers | | get(self, key: 'str', default: 'typing.Any' = None) -> 'typing.Any' from httpx._models.Headers | Return a header value. If multiple occurrences of the header occur | then concatenate them together with commas. | | get_list(self, key: 'str', split_commas: 'bool' = False) -> 'list[str]' from httpx._models.Headers | Return a list of all header values for a given key. | If `split_commas=True` is passed, then any comma separated header | values are split into multiple return strings. | | items(self) -> 'typing.ItemsView[str, str]' from httpx._models.Headers | Return `(key, value)` items of headers. Concatenate headers | into a single comma separated value when a key occurs multiple times. | | keys(self) -> 'typing.KeysView[str]' from httpx._models.Headers | D.keys() -> a set-like object providing a view on D's keys | | multi_items(self) -> 'list[tuple[str, str]]' from httpx._models.Headers | Return a list of `(key, value)` pairs of headers. Allow multiple | occurrences of the same key without concatenating into a single | comma separated value. | | update(self, headers: 'HeaderTypes | None' = None) -> 'None' from httpx._models.Headers | D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. | If E present and has a .keys() method, does: for k in E: D[k] = E[k] | If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v | In either case, this is followed by: for k, v in F.items(): D[k] = v | | values(self) -> 'typing.ValuesView[str]' from httpx._models.Headers | D.values() -> an object providing a view on D's values | | ---------------------------------------------------------------------- | Readonly properties defined here: | | raw | Returns a list of the raw header items, as byte pairs. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | encoding | Header encoding is mandated as ascii, but we allow fallbacks to utf-8 | or iso-8859-1. | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | __hash__ = None | | __orig_bases__ = (typing.MutableMapping[str, str],) | | __parameters__ = () | | ---------------------------------------------------------------------- | Methods inherited from collections.abc.MutableMapping: | | clear(self) | D.clear() -> None. Remove all items from D. | | pop(self, key, default=<object object at 0x0000025153A481F0>) | D.pop(k[,d]) -> v, remove specified key and return the corresponding value. | If key is not found, d is returned if given, otherwise KeyError is raised. | | popitem(self) | D.popitem() -> (k, v), remove and return some (key, value) pair | as a 2-tuple; but raise KeyError if D is empty. | | setdefault(self, key, default=None) | D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D | | ---------------------------------------------------------------------- | Data and other attributes inherited from collections.abc.Mapping: | | __reversed__ = None | | ---------------------------------------------------------------------- | Class methods inherited from collections.abc.Collection: | | __subclasshook__(C) | Abstract classes can override this to customize issubclass(). | | This is invoked early on by abc.ABCMeta.__subclasscheck__(). | It should return True, False or NotImplemented. If it returns | NotImplemented, the normal algorithm is used. Otherwise, it | overrides the normal algorithm (and the outcome is cached). | | ---------------------------------------------------------------------- | Class methods inherited from collections.abc.Iterable: | | __class_getitem__ = GenericAlias(...) | Represent a PEP 585 generic type | | E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,). | | ---------------------------------------------------------------------- | Class methods inherited from typing.Generic: | | __init_subclass__(...) | Function to initialize subclasses.
httpx.InvalidURL
Python Library Documentation: class InvalidURL in module httpx class InvalidURL(builtins.Exception) | InvalidURL(message: 'str') -> 'None' | | URL is improperly formed or cannot be parsed. | | Method resolution order: | InvalidURL | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, message: 'str') -> 'None' from httpx._exceptions.InvalidURL | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.Limits
Python Library Documentation: class Limits in module httpx class Limits(builtins.object) | Limits(*, max_connections: 'int | None' = None, max_keepalive_connections: 'int | None' = None, keepalive_expiry: 'float | None' = 5.0) -> 'None' | | Configuration for limits to various client behaviors. | | **Parameters:** | | * **max_connections** - The maximum number of concurrent connections that may be | established. | * **max_keepalive_connections** - Allow the connection pool to maintain | keep-alive connections below this point. Should be less than or equal | to `max_connections`. | * **keepalive_expiry** - Time limit on idle keep-alive connections in seconds. | | Methods defined here: | | __eq__(self, other: 'typing.Any') -> 'bool' from httpx._config.Limits | Return self==value. | | __init__(self, *, max_connections: 'int | None' = None, max_keepalive_connections: 'int | None' = None, keepalive_expiry: 'float | None' = 5.0) -> 'None' from httpx._config.Limits | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) -> 'str' from httpx._config.Limits | Return repr(self). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None
httpx.LocalProtocolError
Python Library Documentation: class LocalProtocolError in module httpx class LocalProtocolError(ProtocolError) | LocalProtocolError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | A protocol was violated by the client. | | For example if the user instantiated a `Request` instance explicitly, | failed to include the mandatory `Host:` header, and then issued it directly | using `client.send()`. | | Method resolution order: | LocalProtocolError | ProtocolError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.MockTransport
Python Library Documentation: class MockTransport in module httpx class MockTransport(AsyncBaseTransport, BaseTransport) | MockTransport(handler: 'SyncHandler | AsyncHandler') -> 'None' | | Method resolution order: | MockTransport | AsyncBaseTransport | BaseTransport | builtins.object | | Methods defined here: | | __init__(self, handler: 'SyncHandler | AsyncHandler') -> 'None' from httpx._transports.mock.MockTransport | Initialize self. See help(type(self)) for accurate signature. | | async handle_async_request(self, request: 'Request') -> 'Response' from httpx._transports.mock.MockTransport | | handle_request(self, request: 'Request') -> 'Response' from httpx._transports.mock.MockTransport | Send a single HTTP request and return a response. | | Developers shouldn't typically ever need to call into this API directly, | since the Client class provides all the higher level user-facing API | niceties. | | In order to properly release any network resources, the response | stream should *either* be consumed immediately, with a call to | `response.stream.read()`, or else the `handle_request` call should | be followed with a try/finally block to ensuring the stream is | always closed. | | Example usage: | | with httpx.HTTPTransport() as transport: | req = httpx.Request( | method=b"GET", | url=(b"https", b"www.example.com", 443, b"/"), | headers=[(b"Host", b"www.example.com")], | ) | resp = transport.handle_request(req) | body = resp.stream.read() | print(resp.status_code, resp.headers, body) | | | Takes a `Request` instance as the only argument. | | Returns a `Response` instance. | | ---------------------------------------------------------------------- | Methods inherited from AsyncBaseTransport: | | async __aenter__(self: 'A') -> 'A' from httpx._transports.base.AsyncBaseTransport | | async __aexit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._transports.base.AsyncBaseTransport | | async aclose(self) -> 'None' from httpx._transports.base.AsyncBaseTransport | | ---------------------------------------------------------------------- | Data descriptors inherited from AsyncBaseTransport: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Methods inherited from BaseTransport: | | __enter__(self: 'T') -> 'T' from httpx._transports.base.BaseTransport | | __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._transports.base.BaseTransport | | close(self) -> 'None' from httpx._transports.base.BaseTransport
httpx.NetRCAuth
Python Library Documentation: class NetRCAuth in module httpx
class NetRCAuth(Auth)
| NetRCAuth(file: 'str | None' = None) -> 'None'
|
| Use a 'netrc' file to lookup basic auth credentials based on the url host.
|
| Method resolution order:
| NetRCAuth
| Auth
| builtins.object
|
| Methods defined here:
|
| __init__(self, file: 'str | None' = None) -> 'None' from httpx._auth.NetRCAuth
| Initialize self. See help(type(self)) for accurate signature.
|
| auth_flow(self, request: 'Request') -> 'typing.Generator[Request, Response, None]' from httpx._auth.NetRCAuth
| Execute the authentication flow.
|
| To dispatch a request, `yield` it:
|
| ```
| yield request
| ```
|
| The client will `.send()` the response back into the flow generator. You can
| access it like so:
|
| ```
| response = yield request
| ```
|
| A `return` (or reaching the end of the generator) will result in the
| client returning the last response obtained from the server.
|
| You can dispatch as many requests as is necessary.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from Auth:
|
| async async_auth_flow(self, request: 'Request') -> 'typing.AsyncGenerator[Request, Response]' from httpx._auth.Auth
| Execute the authentication flow asynchronously.
|
| By default, this defers to `.auth_flow()`. You should override this method
| when the authentication scheme does I/O and/or uses concurrency primitives.
|
| sync_auth_flow(self, request: 'Request') -> 'typing.Generator[Request, Response, None]' from httpx._auth.Auth
| Execute the authentication flow synchronously.
|
| By default, this defers to `.auth_flow()`. You should override this method
| when the authentication scheme does I/O and/or uses concurrency primitives.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Auth:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from Auth:
|
| requires_request_body = False
|
| requires_response_body = False
httpx.NetworkError
Python Library Documentation: class NetworkError in module httpx class NetworkError(TransportError) | NetworkError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | The base class for network-related errors. | | An error occurred while interacting with the network. | | Method resolution order: | NetworkError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.PoolTimeout
Python Library Documentation: class PoolTimeout in module httpx class PoolTimeout(TimeoutException) | PoolTimeout(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Timed out waiting to acquire a connection from the pool. | | Method resolution order: | PoolTimeout | TimeoutException | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.ProtocolError
Python Library Documentation: class ProtocolError in module httpx class ProtocolError(TransportError) | ProtocolError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | The protocol was violated. | | Method resolution order: | ProtocolError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.Proxy
Python Library Documentation: class Proxy in module httpx class Proxy(builtins.object) | Proxy(url: 'URLTypes', *, ssl_context: 'ssl.SSLContext | None' = None, auth: 'tuple[str, str] | None' = None, headers: 'HeaderTypes | None' = None) -> 'None' | | Methods defined here: | | __init__(self, url: 'URLTypes', *, ssl_context: 'ssl.SSLContext | None' = None, auth: 'tuple[str, str] | None' = None, headers: 'HeaderTypes | None' = None) -> 'None' from httpx._config.Proxy | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) -> 'str' from httpx._config.Proxy | Return repr(self). | | ---------------------------------------------------------------------- | Readonly properties defined here: | | raw_auth | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.ProxyError
Python Library Documentation: class ProxyError in module httpx class ProxyError(TransportError) | ProxyError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | An error occurred while establishing a proxy connection. | | Method resolution order: | ProxyError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.QueryParams
Python Library Documentation: class QueryParams in module httpx
class QueryParams(collections.abc.Mapping, typing.Generic)
| QueryParams(*args: 'QueryParamTypes | None', **kwargs: 'typing.Any') -> 'None'
|
| URL query parameters, as a multi-dict.
|
| Method resolution order:
| QueryParams
| collections.abc.Mapping
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __bool__(self) -> 'bool' from httpx._urls.QueryParams
|
| __contains__(self, key: 'typing.Any') -> 'bool' from httpx._urls.QueryParams
|
| __eq__(self, other: 'typing.Any') -> 'bool' from httpx._urls.QueryParams
| Return self==value.
|
| __getitem__(self, key: 'typing.Any') -> 'str' from httpx._urls.QueryParams
|
| __hash__(self) -> 'int' from httpx._urls.QueryParams
| Return hash(self).
|
| __init__(self, *args: 'QueryParamTypes | None', **kwargs: 'typing.Any') -> 'None' from httpx._urls.QueryParams
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self) -> 'typing.Iterator[typing.Any]' from httpx._urls.QueryParams
|
| __len__(self) -> 'int' from httpx._urls.QueryParams
|
| __repr__(self) -> 'str' from httpx._urls.QueryParams
| Return repr(self).
|
| __setitem__(self, key: 'str', value: 'str') -> 'None' from httpx._urls.QueryParams
|
| __str__(self) -> 'str' from httpx._urls.QueryParams
| Note that we use '%20' encoding for spaces, and treat '/' as a safe
| character.
|
| See https://github.com/encode/httpx/issues/2536 and
| https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlencode
|
| add(self, key: 'str', value: 'typing.Any' = None) -> 'QueryParams' from httpx._urls.QueryParams
| Return a new QueryParams instance, setting or appending the value of a key.
|
| Usage:
|
| q = httpx.QueryParams("a=123")
| q = q.add("a", "456")
| assert q == httpx.QueryParams("a=123&a=456")
|
| get(self, key: 'typing.Any', default: 'typing.Any' = None) -> 'typing.Any' from httpx._urls.QueryParams
| Get a value from the query param for a given key. If the key occurs
| more than once, then only the first value is returned.
|
| Usage:
|
| q = httpx.QueryParams("a=123&a=456&b=789")
| assert q.get("a") == "123"
|
| get_list(self, key: 'str') -> 'list[str]' from httpx._urls.QueryParams
| Get all values from the query param for a given key.
|
| Usage:
|
| q = httpx.QueryParams("a=123&a=456&b=789")
| assert q.get_list("a") == ["123", "456"]
|
| items(self) -> 'typing.ItemsView[str, str]' from httpx._urls.QueryParams
| Return all items in the query params. If a key occurs more than once
| only the first item for that key is returned.
|
| Usage:
|
| q = httpx.QueryParams("a=123&a=456&b=789")
| assert list(q.items()) == [("a", "123"), ("b", "789")]
|
| keys(self) -> 'typing.KeysView[str]' from httpx._urls.QueryParams
| Return all the keys in the query params.
|
| Usage:
|
| q = httpx.QueryParams("a=123&a=456&b=789")
| assert list(q.keys()) == ["a", "b"]
|
| merge(self, params: 'QueryParamTypes | None' = None) -> 'QueryParams' from httpx._urls.QueryParams
| Return a new QueryParams instance, updated with.
|
| Usage:
|
| q = httpx.QueryParams("a=123")
| q = q.merge({"b": "456"})
| assert q == httpx.QueryParams("a=123&b=456")
|
| q = httpx.QueryParams("a=123")
| q = q.merge({"a": "456", "b": "789"})
| assert q == httpx.QueryParams("a=456&b=789")
|
| multi_items(self) -> 'list[tuple[str, str]]' from httpx._urls.QueryParams
| Return all items in the query params. Allow duplicate keys to occur.
|
| Usage:
|
| q = httpx.QueryParams("a=123&a=456&b=789")
| assert list(q.multi_items()) == [("a", "123"), ("a", "456"), ("b", "789")]
|
| remove(self, key: 'str') -> 'QueryParams' from httpx._urls.QueryParams
| Return a new QueryParams instance, removing the value of a key.
|
| Usage:
|
| q = httpx.QueryParams("a=123")
| q = q.remove("a")
| assert q == httpx.QueryParams("")
|
| set(self, key: 'str', value: 'typing.Any' = None) -> 'QueryParams' from httpx._urls.QueryParams
| Return a new QueryParams instance, setting the value of a key.
|
| Usage:
|
| q = httpx.QueryParams("a=123")
| q = q.set("a", "456")
| assert q == httpx.QueryParams("a=456")
|
| update(self, params: 'QueryParamTypes | None' = None) -> 'None' from httpx._urls.QueryParams
|
| values(self) -> 'typing.ValuesView[str]' from httpx._urls.QueryParams
| Return all the values in the query params. If a key occurs more than once
| only the first item for that key is returned.
|
| Usage:
|
| q = httpx.QueryParams("a=123&a=456&b=789")
| assert list(q.values()) == ["123", "789"]
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __orig_bases__ = (typing.Mapping[str, str],)
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from collections.abc.Mapping:
|
| __reversed__ = None
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Collection:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __init_subclass__(...)
| Function to initialize subclasses.
httpx.ReadError
Python Library Documentation: class ReadError in module httpx class ReadError(NetworkError) | ReadError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Failed to receive data from the network. | | Method resolution order: | ReadError | NetworkError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.ReadTimeout
Python Library Documentation: class ReadTimeout in module httpx class ReadTimeout(TimeoutException) | ReadTimeout(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Timed out while receiving data from the host. | | Method resolution order: | ReadTimeout | TimeoutException | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.RemoteProtocolError
Python Library Documentation: class RemoteProtocolError in module httpx class RemoteProtocolError(ProtocolError) | RemoteProtocolError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | The protocol was violated by the server. | | For example, returning malformed HTTP. | | Method resolution order: | RemoteProtocolError | ProtocolError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.Request
Python Library Documentation: class Request in module httpx class Request(builtins.object) | Request(method: 'str | bytes', url: 'URL | str', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, stream: 'SyncByteStream | AsyncByteStream | None' = None, extensions: 'RequestExtensions | None' = None) -> 'None' | | Methods defined here: | | __getstate__(self) -> 'dict[str, typing.Any]' from httpx._models.Request | Helper for pickle. | | __init__(self, method: 'str | bytes', url: 'URL | str', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, stream: 'SyncByteStream | AsyncByteStream | None' = None, extensions: 'RequestExtensions | None' = None) -> 'None' from httpx._models.Request | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) -> 'str' from httpx._models.Request | Return repr(self). | | __setstate__(self, state: 'dict[str, typing.Any]') -> 'None' from httpx._models.Request | | async aread(self) -> 'bytes' from httpx._models.Request | Read and return the request content. | | read(self) -> 'bytes' from httpx._models.Request | Read and return the request content. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | content | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.RequestError
Python Library Documentation: class RequestError in module httpx class RequestError(HTTPError) | RequestError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Base class for all exceptions that may occur when issuing a `.request()`. | | Method resolution order: | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.RequestNotRead
Python Library Documentation: class RequestNotRead in module httpx class RequestNotRead(StreamError) | RequestNotRead() -> 'None' | | Attempted to access streaming request content, without having called `read()`. | | Method resolution order: | RequestNotRead | StreamError | builtins.RuntimeError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self) -> 'None' from httpx._exceptions.RequestNotRead | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from StreamError: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Static methods inherited from builtins.RuntimeError: | | __new__(*args, **kwargs) class method of builtins.RuntimeError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.Response
Python Library Documentation: class Response in module httpx class Response(builtins.object) | Response(status_code: 'int', *, headers: 'HeaderTypes | None' = None, content: 'ResponseContent | None' = None, text: 'str | None' = None, html: 'str | None' = None, json: 'typing.Any' = None, stream: 'SyncByteStream | AsyncByteStream | None' = None, request: 'Request | None' = None, extensions: 'ResponseExtensions | None' = None, history: 'list[Response] | None' = None, default_encoding: 'str | typing.Callable[[bytes], str]' = 'utf-8') -> 'None' | | Methods defined here: | | __getstate__(self) -> 'dict[str, typing.Any]' from httpx._models.Response | Helper for pickle. | | __init__(self, status_code: 'int', *, headers: 'HeaderTypes | None' = None, content: 'ResponseContent | None' = None, text: 'str | None' = None, html: 'str | None' = None, json: 'typing.Any' = None, stream: 'SyncByteStream | AsyncByteStream | None' = None, request: 'Request | None' = None, extensions: 'ResponseExtensions | None' = None, history: 'list[Response] | None' = None, default_encoding: 'str | typing.Callable[[bytes], str]' = 'utf-8') -> 'None' from httpx._models.Response | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) -> 'str' from httpx._models.Response | Return repr(self). | | __setstate__(self, state: 'dict[str, typing.Any]') -> 'None' from httpx._models.Response | | async aclose(self) -> 'None' from httpx._models.Response | Close the response and release the connection. | Automatically called if the response body is read to completion. | | async aiter_bytes(self, chunk_size: 'int | None' = None) -> 'typing.AsyncIterator[bytes]' from httpx._models.Response | A byte-iterator over the decoded response content. | This allows us to handle gzip, deflate, and brotli encoded responses. | | async aiter_lines(self) -> 'typing.AsyncIterator[str]' from httpx._models.Response | | async aiter_raw(self, chunk_size: 'int | None' = None) -> 'typing.AsyncIterator[bytes]' from httpx._models.Response | A byte-iterator over the raw response content. | | async aiter_text(self, chunk_size: 'int | None' = None) -> 'typing.AsyncIterator[str]' from httpx._models.Response | A str-iterator over the decoded response content | that handles both gzip, deflate, etc but also detects the content's | string encoding. | | async aread(self) -> 'bytes' from httpx._models.Response | Read and return the response content. | | close(self) -> 'None' from httpx._models.Response | Close the response and release the connection. | Automatically called if the response body is read to completion. | | iter_bytes(self, chunk_size: 'int | None' = None) -> 'typing.Iterator[bytes]' from httpx._models.Response | A byte-iterator over the decoded response content. | This allows us to handle gzip, deflate, and brotli encoded responses. | | iter_lines(self) -> 'typing.Iterator[str]' from httpx._models.Response | | iter_raw(self, chunk_size: 'int | None' = None) -> 'typing.Iterator[bytes]' from httpx._models.Response | A byte-iterator over the raw response content. | | iter_text(self, chunk_size: 'int | None' = None) -> 'typing.Iterator[str]' from httpx._models.Response | A str-iterator over the decoded response content | that handles both gzip, deflate, etc but also detects the content's | string encoding. | | json(self, **kwargs: 'typing.Any') -> 'typing.Any' from httpx._models.Response | | raise_for_status(self) -> 'Response' from httpx._models.Response | Raise the `HTTPStatusError` if one occurred. | | read(self) -> 'bytes' from httpx._models.Response | Read and return the response content. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | charset_encoding | Return the encoding, as specified by the Content-Type header. | | content | | cookies | | has_redirect_location | Returns True for 3xx responses with a properly formed URL redirection, | `False` otherwise. | | http_version | | is_client_error | A property which is `True` for 4xx status codes, `False` otherwise. | | is_error | A property which is `True` for 4xx and 5xx status codes, `False` otherwise. | | is_informational | A property which is `True` for 1xx status codes, `False` otherwise. | | is_redirect | A property which is `True` for 3xx status codes, `False` otherwise. | | Note that not all responses with a 3xx status code indicate a URL redirect. | | Use `response.has_redirect_location` to determine responses with a properly | formed URL redirection. | | is_server_error | A property which is `True` for 5xx status codes, `False` otherwise. | | is_success | A property which is `True` for 2xx status codes, `False` otherwise. | | links | Returns the parsed header links of the response, if any | | num_bytes_downloaded | | reason_phrase | | text | | url | Returns the URL for which the request was made. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | elapsed | Returns the time taken for the complete request/response | cycle to complete. | | encoding | Return an encoding to use for decoding the byte content into text. | The priority for determining this is given by... | | * `.encoding = <>` has been set explicitly. | * The encoding as specified by the charset parameter in the Content-Type header. | * The encoding as determined by `default_encoding`, which may either be | a string like "utf-8" indicating the encoding to use, or may be a callable | which enables charset autodetection. | | request | Returns the request instance associated to the current response.
httpx.ResponseNotRead
Python Library Documentation: class ResponseNotRead in module httpx class ResponseNotRead(StreamError) | ResponseNotRead() -> 'None' | | Attempted to access streaming response content, without having called `read()`. | | Method resolution order: | ResponseNotRead | StreamError | builtins.RuntimeError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self) -> 'None' from httpx._exceptions.ResponseNotRead | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from StreamError: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Static methods inherited from builtins.RuntimeError: | | __new__(*args, **kwargs) class method of builtins.RuntimeError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.StreamClosed
Python Library Documentation: class StreamClosed in module httpx class StreamClosed(StreamError) | StreamClosed() -> 'None' | | Attempted to read or stream response content, but the request has been | closed. | | Method resolution order: | StreamClosed | StreamError | builtins.RuntimeError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self) -> 'None' from httpx._exceptions.StreamClosed | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from StreamError: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Static methods inherited from builtins.RuntimeError: | | __new__(*args, **kwargs) class method of builtins.RuntimeError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.StreamConsumed
Python Library Documentation: class StreamConsumed in module httpx class StreamConsumed(StreamError) | StreamConsumed() -> 'None' | | Attempted to read or stream content, but the content has already | been streamed. | | Method resolution order: | StreamConsumed | StreamError | builtins.RuntimeError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self) -> 'None' from httpx._exceptions.StreamConsumed | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from StreamError: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Static methods inherited from builtins.RuntimeError: | | __new__(*args, **kwargs) class method of builtins.RuntimeError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.StreamError
Python Library Documentation: class StreamError in module httpx class StreamError(builtins.RuntimeError) | StreamError(message: 'str') -> 'None' | | The base class for stream exceptions. | | The developer made an error in accessing the request stream in | an invalid way. | | Method resolution order: | StreamError | builtins.RuntimeError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, message: 'str') -> 'None' from httpx._exceptions.StreamError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Static methods inherited from builtins.RuntimeError: | | __new__(*args, **kwargs) class method of builtins.RuntimeError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.SyncByteStream
Python Library Documentation: class SyncByteStream in module httpx class SyncByteStream(builtins.object) | Methods defined here: | | __iter__(self) -> Iterator[bytes] from httpx._types.SyncByteStream | | close(self) -> None from httpx._types.SyncByteStream | Subclasses can override this method to release any network resources | after a request/response cycle is complete. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.Timeout
Python Library Documentation: class Timeout in module httpx class Timeout(builtins.object) | Timeout(timeout: 'TimeoutTypes | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>, *, connect: 'None | float | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>, read: 'None | float | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>, write: 'None | float | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>, pool: 'None | float | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>) -> 'None' | | Timeout configuration. | | **Usage**: | | Timeout(None) # No timeouts. | Timeout(5.0) # 5s timeout on all operations. | Timeout(None, connect=5.0) # 5s timeout on connect, no other timeouts. | Timeout(5.0, connect=10.0) # 10s timeout on connect. 5s timeout elsewhere. | Timeout(5.0, pool=None) # No timeout on acquiring connection from pool. | # 5s timeout elsewhere. | | Methods defined here: | | __eq__(self, other: 'typing.Any') -> 'bool' from httpx._config.Timeout | Return self==value. | | __init__(self, timeout: 'TimeoutTypes | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>, *, connect: 'None | float | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>, read: 'None | float | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>, write: 'None | float | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>, pool: 'None | float | UnsetType' = <httpx._config.UnsetType object at 0x000002515621F4A0>) -> 'None' from httpx._config.Timeout | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) -> 'str' from httpx._config.Timeout | Return repr(self). | | as_dict(self) -> 'dict[str, float | None]' from httpx._config.Timeout | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None
httpx.TimeoutException
Python Library Documentation: class TimeoutException in module httpx class TimeoutException(TransportError) | TimeoutException(message: 'str', *, request: 'Request | None' = None) -> 'None' | | The base class for timeout errors. | | An operation has timed out. | | Method resolution order: | TimeoutException | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.TooManyRedirects
Python Library Documentation: class TooManyRedirects in module httpx class TooManyRedirects(RequestError) | TooManyRedirects(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Too many redirects. | | Method resolution order: | TooManyRedirects | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.TransportError
Python Library Documentation: class TransportError in module httpx class TransportError(RequestError) | TransportError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Base class for all exceptions that occur at the level of the Transport API. | | Method resolution order: | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.URL
Python Library Documentation: class URL in module httpx
class URL(builtins.object)
| URL(url: 'URL | str' = '', **kwargs: 'typing.Any') -> 'None'
|
| url = httpx.URL("HTTPS://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink")
|
| assert url.scheme == "https"
| assert url.username == "jo@email.com"
| assert url.password == "a secret"
| assert url.userinfo == b"jo%40email.com:a%20secret"
| assert url.host == "müller.de"
| assert url.raw_host == b"xn--mller-kva.de"
| assert url.port == 1234
| assert url.netloc == b"xn--mller-kva.de:1234"
| assert url.path == "/pa th"
| assert url.query == b"?search=ab"
| assert url.raw_path == b"/pa%20th?search=ab"
| assert url.fragment == "anchorlink"
|
| The components of a URL are broken down like this:
|
| https://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink
| [scheme] [ username ] [password] [ host ][port][ path ] [ query ] [fragment]
| [ userinfo ] [ netloc ][ raw_path ]
|
| Note that:
|
| * `url.scheme` is normalized to always be lowercased.
|
| * `url.host` is normalized to always be lowercased. Internationalized domain
| names are represented in unicode, without IDNA encoding applied. For instance:
|
| url = httpx.URL("http://中国.icom.museum")
| assert url.host == "中国.icom.museum"
| url = httpx.URL("http://xn--fiqs8s.icom.museum")
| assert url.host == "中国.icom.museum"
|
| * `url.raw_host` is normalized to always be lowercased, and is IDNA encoded.
|
| url = httpx.URL("http://中国.icom.museum")
| assert url.raw_host == b"xn--fiqs8s.icom.museum"
| url = httpx.URL("http://xn--fiqs8s.icom.museum")
| assert url.raw_host == b"xn--fiqs8s.icom.museum"
|
| * `url.port` is either None or an integer. URLs that include the default port for
| "http", "https", "ws", "wss", and "ftp" schemes have their port
| normalized to `None`.
|
| assert httpx.URL("http://example.com") == httpx.URL("http://example.com:80")
| assert httpx.URL("http://example.com").port is None
| assert httpx.URL("http://example.com:80").port is None
|
| * `url.userinfo` is raw bytes, without URL escaping. Usually you'll want to work
| with `url.username` and `url.password` instead, which handle the URL escaping.
|
| * `url.raw_path` is raw bytes of both the path and query, without URL escaping.
| This portion is used as the target when constructing HTTP requests. Usually you'll
| want to work with `url.path` instead.
|
| * `url.query` is raw bytes, without URL escaping. A URL query string portion can
| only be properly URL escaped when decoding the parameter names and values
| themselves.
|
| Methods defined here:
|
| __eq__(self, other: 'typing.Any') -> 'bool' from httpx._urls.URL
| Return self==value.
|
| __hash__(self) -> 'int' from httpx._urls.URL
| Return hash(self).
|
| __init__(self, url: 'URL | str' = '', **kwargs: 'typing.Any') -> 'None' from httpx._urls.URL
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self) -> 'str' from httpx._urls.URL
| Return repr(self).
|
| __str__(self) -> 'str' from httpx._urls.URL
| Return str(self).
|
| copy_add_param(self, key: 'str', value: 'typing.Any' = None) -> 'URL' from httpx._urls.URL
|
| copy_merge_params(self, params: 'QueryParamTypes') -> 'URL' from httpx._urls.URL
|
| copy_remove_param(self, key: 'str') -> 'URL' from httpx._urls.URL
|
| copy_set_param(self, key: 'str', value: 'typing.Any' = None) -> 'URL' from httpx._urls.URL
|
| copy_with(self, **kwargs: 'typing.Any') -> 'URL' from httpx._urls.URL
| Copy this URL, returning a new URL with some components altered.
| Accepts the same set of parameters as the components that are made
| available via properties on the `URL` class.
|
| For example:
|
| url = httpx.URL("https://www.example.com").copy_with(
| username="jo@gmail.com", password="a secret"
| )
| assert url == "https://jo%40email.com:a%20secret@www.example.com"
|
| join(self, url: 'URLTypes') -> 'URL' from httpx._urls.URL
| Return an absolute URL, using this URL as the base.
|
| Eg.
|
| url = httpx.URL("https://www.example.com/test")
| url = url.join("/new/path")
| assert url == "https://www.example.com/new/path"
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| fragment
| The URL fragments, as used in HTML anchors.
| As a string, without the leading '#'.
|
| host
| The URL host as a string.
| Always normalized to lowercase, with IDNA hosts decoded into unicode.
|
| Examples:
|
| url = httpx.URL("http://www.EXAMPLE.org")
| assert url.host == "www.example.org"
|
| url = httpx.URL("http://中国.icom.museum")
| assert url.host == "中国.icom.museum"
|
| url = httpx.URL("http://xn--fiqs8s.icom.museum")
| assert url.host == "中国.icom.museum"
|
| url = httpx.URL("https://[::ffff:192.168.0.1]")
| assert url.host == "::ffff:192.168.0.1"
|
| is_absolute_url
| Return `True` for absolute URLs such as 'http://example.com/path',
| and `False` for relative URLs such as '/path'.
|
| is_relative_url
| Return `False` for absolute URLs such as 'http://example.com/path',
| and `True` for relative URLs such as '/path'.
|
| netloc
| Either `<host>` or `<host>:<port>` as bytes.
| Always normalized to lowercase, and IDNA encoded.
|
| This property may be used for generating the value of a request
| "Host" header.
|
| params
| The URL query parameters, neatly parsed and packaged into an immutable
| multidict representation.
|
| password
| The URL password as a string, with URL decoding applied.
| For example: "a secret"
|
| path
| The URL path as a string. Excluding the query string, and URL decoded.
|
| For example:
|
| url = httpx.URL("https://example.com/pa%20th")
| assert url.path == "/pa th"
|
| port
| The URL port as an integer.
|
| Note that the URL class performs port normalization as per the WHATWG spec.
| Default ports for "http", "https", "ws", "wss", and "ftp" schemes are always
| treated as `None`.
|
| For example:
|
| assert httpx.URL("http://www.example.com") == httpx.URL("http://www.example.com:80")
| assert httpx.URL("http://www.example.com:80").port is None
|
| query
| The URL query string, as raw bytes, excluding the leading b"?".
|
| This is necessarily a bytewise interface, because we cannot
| perform URL decoding of this representation until we've parsed
| the keys and values into a QueryParams instance.
|
| For example:
|
| url = httpx.URL("https://example.com/?filter=some%20search%20terms")
| assert url.query == b"filter=some%20search%20terms"
|
| raw
| Provides the (scheme, host, port, target) for the outgoing request.
|
| In older versions of `httpx` this was used in the low-level transport API.
| We no longer use `RawURL`, and this property will be deprecated
| in a future release.
|
| raw_host
| The raw bytes representation of the URL host.
| Always normalized to lowercase, and IDNA encoded.
|
| Examples:
|
| url = httpx.URL("http://www.EXAMPLE.org")
| assert url.raw_host == b"www.example.org"
|
| url = httpx.URL("http://中国.icom.museum")
| assert url.raw_host == b"xn--fiqs8s.icom.museum"
|
| url = httpx.URL("http://xn--fiqs8s.icom.museum")
| assert url.raw_host == b"xn--fiqs8s.icom.museum"
|
| url = httpx.URL("https://[::ffff:192.168.0.1]")
| assert url.raw_host == b"::ffff:192.168.0.1"
|
| raw_path
| The complete URL path and query string as raw bytes.
| Used as the target when constructing HTTP requests.
|
| For example:
|
| GET /users?search=some%20text HTTP/1.1
| Host: www.example.org
| Connection: close
|
| raw_scheme
| The raw bytes representation of the URL scheme, such as b"http", b"https".
| Always normalised to lowercase.
|
| scheme
| The URL scheme, such as "http", "https".
| Always normalised to lowercase.
|
| userinfo
| The URL userinfo as a raw bytestring.
| For example: b"jo%40email.com:a%20secret".
|
| username
| The URL username as a string, with URL decoding applied.
| For example: "jo@email.com"
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
httpx.USE_CLIENT_DEFAULT
Python Library Documentation: UseClientDefault in module httpx object class UseClientDefault(builtins.object) | For some parameters such as `auth=...` and `timeout=...` we need to be able | to indicate the default "unset" state, in a way that is distinctly different | to using `None`. | | The default "unset" state indicates that whatever default is set on the | client should be used. This is different to setting `None`, which | explicitly disables the parameter, possibly overriding a client default. | | For example we use `timeout=USE_CLIENT_DEFAULT` in the `request()` signature. | Omitting the `timeout` parameter will send a request using whatever default | timeout has been configured on the client. Including `timeout=None` will | ensure no timeout is used. | | Note that user code shouldn't need to use the `USE_CLIENT_DEFAULT` constant, | but it is used internally when a parameter is not included. | | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.UnsupportedProtocol
Python Library Documentation: class UnsupportedProtocol in module httpx class UnsupportedProtocol(TransportError) | UnsupportedProtocol(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Attempted to make a request to an unsupported protocol. | | For example issuing a request to `ftp://www.example.com`. | | Method resolution order: | UnsupportedProtocol | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.WSGITransport
Python Library Documentation: class WSGITransport in module httpx class WSGITransport(BaseTransport) | WSGITransport(app: 'WSGIApplication', raise_app_exceptions: 'bool' = True, script_name: 'str' = '', remote_addr: 'str' = '127.0.0.1', wsgi_errors: 'typing.TextIO | None' = None) -> 'None' | | A custom transport that handles sending requests directly to an WSGI app. | The simplest way to use this functionality is to use the `app` argument. | | ``` | client = httpx.Client(app=app) | ``` | | Alternatively, you can setup the transport instance explicitly. | This allows you to include any additional configuration arguments specific | to the WSGITransport class: | | ``` | transport = httpx.WSGITransport( | app=app, | script_name="/submount", | remote_addr="1.2.3.4" | ) | client = httpx.Client(transport=transport) | ``` | | Arguments: | | * `app` - The WSGI application. | * `raise_app_exceptions` - Boolean indicating if exceptions in the application | should be raised. Default to `True`. Can be set to `False` for use cases | such as testing the content of a client 500 response. | * `script_name` - The root path on which the WSGI application should be mounted. | * `remote_addr` - A string indicating the client IP of incoming requests. | ``` | | Method resolution order: | WSGITransport | BaseTransport | builtins.object | | Methods defined here: | | __init__(self, app: 'WSGIApplication', raise_app_exceptions: 'bool' = True, script_name: 'str' = '', remote_addr: 'str' = '127.0.0.1', wsgi_errors: 'typing.TextIO | None' = None) -> 'None' from httpx._transports.wsgi.WSGITransport | Initialize self. See help(type(self)) for accurate signature. | | handle_request(self, request: 'Request') -> 'Response' from httpx._transports.wsgi.WSGITransport | Send a single HTTP request and return a response. | | Developers shouldn't typically ever need to call into this API directly, | since the Client class provides all the higher level user-facing API | niceties. | | In order to properly release any network resources, the response | stream should *either* be consumed immediately, with a call to | `response.stream.read()`, or else the `handle_request` call should | be followed with a try/finally block to ensuring the stream is | always closed. | | Example usage: | | with httpx.HTTPTransport() as transport: | req = httpx.Request( | method=b"GET", | url=(b"https", b"www.example.com", 443, b"/"), | headers=[(b"Host", b"www.example.com")], | ) | resp = transport.handle_request(req) | body = resp.stream.read() | print(resp.status_code, resp.headers, body) | | | Takes a `Request` instance as the only argument. | | Returns a `Response` instance. | | ---------------------------------------------------------------------- | Methods inherited from BaseTransport: | | __enter__(self: 'T') -> 'T' from httpx._transports.base.BaseTransport | | __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' from httpx._transports.base.BaseTransport | | close(self) -> 'None' from httpx._transports.base.BaseTransport | | ---------------------------------------------------------------------- | Data descriptors inherited from BaseTransport: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
httpx.WriteError
Python Library Documentation: class WriteError in module httpx class WriteError(NetworkError) | WriteError(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Failed to send data through the network. | | Method resolution order: | WriteError | NetworkError | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.WriteTimeout
Python Library Documentation: class WriteTimeout in module httpx class WriteTimeout(TimeoutException) | WriteTimeout(message: 'str', *, request: 'Request | None' = None) -> 'None' | | Timed out while sending data to the host. | | Method resolution order: | WriteTimeout | TimeoutException | TransportError | RequestError | HTTPError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from RequestError: | | __init__(self, message: 'str', *, request: 'Request | None' = None) -> 'None' from httpx._exceptions.RequestError | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from HTTPError: | | __weakref__ | list of weak references to the object | | request | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) class method of builtins.Exception | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
httpx.codes
Python Library Documentation: class codes in module httpx class codes(enum.IntEnum) | codes(*values) | | HTTP status codes and reason phrases | | Status codes from the following RFCs are all observed: | | * RFC 7231: Hypertext Transfer Protocol (HTTP/1.1), obsoletes 2616 | * RFC 6585: Additional HTTP Status Codes | * RFC 3229: Delta encoding in HTTP | * RFC 4918: HTTP Extensions for WebDAV, obsoletes 2518 | * RFC 5842: Binding Extensions to WebDAV | * RFC 7238: Permanent Redirect | * RFC 2295: Transparent Content Negotiation in HTTP | * RFC 2774: An HTTP Extension Framework | * RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2) | * RFC 2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) | * RFC 7725: An HTTP Status Code to Report Legal Obstacles | * RFC 8297: An HTTP Status Code for Indicating Hints | * RFC 8470: Using Early Data in HTTP | | Method resolution order: | codes | enum.IntEnum | builtins.int | enum.ReprEnum | enum.Enum | builtins.object | | Methods defined here: | | __format__(self, format_spec, /) from builtins.int | Convert to a string according to format_spec. | | __new__(cls, value) from enum.Enum | Create and return a new object. See help(type) for accurate signature. | | __str__(self) -> 'str' from httpx._status_codes.codes | Return repr(self). | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | ACCEPTED = <codes.ACCEPTED: 202> | | ALREADY_REPORTED = <codes.ALREADY_REPORTED: 208> | | BAD_GATEWAY = <codes.BAD_GATEWAY: 502> | | BAD_REQUEST = <codes.BAD_REQUEST: 400> | | CONFLICT = <codes.CONFLICT: 409> | | CONTINUE = <codes.CONTINUE: 100> | | CREATED = <codes.CREATED: 201> | | EARLY_HINTS = <codes.EARLY_HINTS: 103> | | EXPECTATION_FAILED = <codes.EXPECTATION_FAILED: 417> | | FAILED_DEPENDENCY = <codes.FAILED_DEPENDENCY: 424> | | FORBIDDEN = <codes.FORBIDDEN: 403> | | FOUND = <codes.FOUND: 302> | | GATEWAY_TIMEOUT = <codes.GATEWAY_TIMEOUT: 504> | | GONE = <codes.GONE: 410> | | HTTP_VERSION_NOT_SUPPORTED = <codes.HTTP_VERSION_NOT_SUPPORTED: 505> | | IM_A_TEAPOT = <codes.IM_A_TEAPOT: 418> | | IM_USED = <codes.IM_USED: 226> | | INSUFFICIENT_STORAGE = <codes.INSUFFICIENT_STORAGE: 507> | | INTERNAL_SERVER_ERROR = <codes.INTERNAL_SERVER_ERROR: 500> | | LENGTH_REQUIRED = <codes.LENGTH_REQUIRED: 411> | | LOCKED = <codes.LOCKED: 423> | | LOOP_DETECTED = <codes.LOOP_DETECTED: 508> | | METHOD_NOT_ALLOWED = <codes.METHOD_NOT_ALLOWED: 405> | | MISDIRECTED_REQUEST = <codes.MISDIRECTED_REQUEST: 421> | | MOVED_PERMANENTLY = <codes.MOVED_PERMANENTLY: 301> | | MULTIPLE_CHOICES = <codes.MULTIPLE_CHOICES: 300> | | MULTI_STATUS = <codes.MULTI_STATUS: 207> | | NETWORK_AUTHENTICATION_REQUIRED = <codes.NETWORK_AUTHENTICATION_REQUIR... | | NON_AUTHORITATIVE_INFORMATION = <codes.NON_AUTHORITATIVE_INFORMATION: ... | | NOT_ACCEPTABLE = <codes.NOT_ACCEPTABLE: 406> | | NOT_EXTENDED = <codes.NOT_EXTENDED: 510> | | NOT_FOUND = <codes.NOT_FOUND: 404> | | NOT_IMPLEMENTED = <codes.NOT_IMPLEMENTED: 501> | | NOT_MODIFIED = <codes.NOT_MODIFIED: 304> | | NO_CONTENT = <codes.NO_CONTENT: 204> | | OK = <codes.OK: 200> | | PARTIAL_CONTENT = <codes.PARTIAL_CONTENT: 206> | | PAYMENT_REQUIRED = <codes.PAYMENT_REQUIRED: 402> | | PERMANENT_REDIRECT = <codes.PERMANENT_REDIRECT: 308> | | PRECONDITION_FAILED = <codes.PRECONDITION_FAILED: 412> | | PRECONDITION_REQUIRED = <codes.PRECONDITION_REQUIRED: 428> | | PROCESSING = <codes.PROCESSING: 102> | | PROXY_AUTHENTICATION_REQUIRED = <codes.PROXY_AUTHENTICATION_REQUIRED: ... | | REQUESTED_RANGE_NOT_SATISFIABLE = <codes.REQUESTED_RANGE_NOT_SATISFIAB... | | REQUEST_ENTITY_TOO_LARGE = <codes.REQUEST_ENTITY_TOO_LARGE: 413> | | REQUEST_HEADER_FIELDS_TOO_LARGE = <codes.REQUEST_HEADER_FIELDS_TOO_LAR... | | REQUEST_TIMEOUT = <codes.REQUEST_TIMEOUT: 408> | | REQUEST_URI_TOO_LONG = <codes.REQUEST_URI_TOO_LONG: 414> | | RESET_CONTENT = <codes.RESET_CONTENT: 205> | | SEE_OTHER = <codes.SEE_OTHER: 303> | | SERVICE_UNAVAILABLE = <codes.SERVICE_UNAVAILABLE: 503> | | SWITCHING_PROTOCOLS = <codes.SWITCHING_PROTOCOLS: 101> | | TEMPORARY_REDIRECT = <codes.TEMPORARY_REDIRECT: 307> | | TOO_EARLY = <codes.TOO_EARLY: 425> | | TOO_MANY_REQUESTS = <codes.TOO_MANY_REQUESTS: 429> | | UNAUTHORIZED = <codes.UNAUTHORIZED: 401> | | UNAVAILABLE_FOR_LEGAL_REASONS = <codes.UNAVAILABLE_FOR_LEGAL_REASONS: ... | | UNPROCESSABLE_ENTITY = <codes.UNPROCESSABLE_ENTITY: 422> | | UNSUPPORTED_MEDIA_TYPE = <codes.UNSUPPORTED_MEDIA_TYPE: 415> | | UPGRADE_REQUIRED = <codes.UPGRADE_REQUIRED: 426> | | USE_PROXY = <codes.USE_PROXY: 305> | | VARIANT_ALSO_NEGOTIATES = <codes.VARIANT_ALSO_NEGOTIATES: 506> | | ---------------------------------------------------------------------- | Methods inherited from enum.IntEnum: | | __repr__(self) from enum.Enum | Return repr(self). | | ---------------------------------------------------------------------- | Methods inherited from builtins.int: | | __abs__(self, /) | abs(self) | | __add__(self, value, /) | Return self+value. | | __and__(self, value, /) | Return self&value. | | __bool__(self, /) | True if self else False | | __ceil__(...) | Ceiling of an Integral returns itself. | | __divmod__(self, value, /) | Return divmod(self, value). | | __eq__(self, value, /) | Return self==value. | | __float__(self, /) | float(self) | | __floor__(...) | Flooring an Integral returns itself. | | __floordiv__(self, value, /) | Return self//value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getnewargs__(self, /) | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __index__(self, /) | Return self converted to an integer, if self is suitable for use as an index into a list. | | __int__(self, /) | int(self) | | __invert__(self, /) | ~self | | __le__(self, value, /) | Return self<=value. | | __lshift__(self, value, /) | Return self<<value. | | __lt__(self, value, /) | Return self<value. | | __mod__(self, value, /) | Return self%value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __neg__(self, /) | -self | | __or__(self, value, /) | Return self|value. | | __pos__(self, /) | +self | | __pow__(self, value, mod=None, /) | Return pow(self, value, mod). | | __radd__(self, value, /) | Return value+self. | | __rand__(self, value, /) | Return value&self. | | __rdivmod__(self, value, /) | Return divmod(value, self). | | __rfloordiv__(self, value, /) | Return value//self. | | __rlshift__(self, value, /) | Return value<<self. | | __rmod__(self, value, /) | Return value%self. | | __rmul__(self, value, /) | Return value*self. | | __ror__(self, value, /) | Return value|self. | | __round__(...) | Rounding an Integral returns itself. | | Rounding with an ndigits argument also returns an integer. | | __rpow__(self, value, mod=None, /) | Return pow(value, self, mod). | | __rrshift__(self, value, /) | Return value>>self. | | __rshift__(self, value, /) | Return self>>value. | | __rsub__(self, value, /) | Return value-self. | | __rtruediv__(self, value, /) | Return value/self. | | __rxor__(self, value, /) | Return value^self. | | __sizeof__(self, /) | Returns size in memory, in bytes. | | __sub__(self, value, /) | Return self-value. | | __truediv__(self, value, /) | Return self/value. | | __trunc__(...) | Truncating an Integral returns itself. | | __xor__(self, value, /) | Return self^value. | | as_integer_ratio(self, /) | Return a pair of integers, whose ratio is equal to the original int. | | The ratio is in lowest terms and has a positive denominator. | | >>> (10).as_integer_ratio() | (10, 1) | >>> (-10).as_integer_ratio() | (-10, 1) | >>> (0).as_integer_ratio() | (0, 1) | | bit_count(self, /) | Number of ones in the binary representation of the absolute value of self. | | Also known as the population count. | | >>> bin(13) | '0b1101' | >>> (13).bit_count() | 3 | | bit_length(self, /) | Number of bits necessary to represent self in binary. | | >>> bin(37) | '0b100101' | >>> (37).bit_length() | 6 | | conjugate(...) | Returns self, the complex conjugate of any int. | | is_integer(self, /) | Returns True. Exists for duck type compatibility with float.is_integer. | | to_bytes(self, /, length=1, byteorder='big', *, signed=False) | Return an array of bytes representing an integer. | | length | Length of bytes object to use. An OverflowError is raised if the | integer is not representable with the given number of bytes. Default | is length 1. | byteorder | The byte order used to represent the integer. If byteorder is 'big', | the most significant byte is at the beginning of the byte array. If | byteorder is 'little', the most significant byte is at the end of the | byte array. To request the native byte order of the host system, use | `sys.byteorder' as the byte order value. Default is to use 'big'. | signed | Determines whether two's complement is used to represent the integer. | If signed is False and a negative integer is given, an OverflowError | is raised. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.int: | | from_bytes(bytes, byteorder='big', *, signed=False) | Return the integer represented by the given array of bytes. | | bytes | Holds the array of bytes to convert. The argument must either | support the buffer protocol or be an iterable object producing bytes. | Bytes and bytearray are examples of built-in objects that support the | buffer protocol. | byteorder | The byte order used to represent the integer. If byteorder is 'big', | the most significant byte is at the beginning of the byte array. If | byteorder is 'little', the most significant byte is at the end of the | byte array. To request the native byte order of the host system, use | `sys.byteorder' as the byte order value. Default is to use 'big'. | signed | Indicates whether two's complement is used to represent the integer. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.int: | | denominator | the denominator of a rational number in lowest terms | | imag | the imaginary part of a complex number | | numerator | the numerator of a rational number in lowest terms | | real | the real part of a complex number | | ---------------------------------------------------------------------- | Methods inherited from enum.Enum: | | __dir__(self) | Returns public methods and other interesting attributes. | | __init__(self, *args, **kwds) | Initialize self. See help(type(self)) for accurate signature. | | __reduce_ex__(self, proto) | Helper for pickle. | | ---------------------------------------------------------------------- | Data descriptors inherited from enum.Enum: | | name | The name of the Enum member. | | value | The value of the Enum member. | | ---------------------------------------------------------------------- | Static methods inherited from enum.EnumType: | | __contains__(value) | Return True if `value` is in `cls`. | | `value` is in `cls` if: | 1) `value` is a member of `cls`, or | 2) `value` is the value of one of the `cls`'s members. | | __getitem__(name) | Return the member matching `name`. | | __iter__() | Return members in definition order. | | __len__() | Return the number of members (no aliases) | | ---------------------------------------------------------------------- | Readonly properties inherited from enum.EnumType: | | __members__ | Returns a mapping of member name->value. | | This mapping lists all enum members, including aliases. Note that this | is a read-only view of the internal mapping.
httpx.create_ssl_context
Python Library Documentation: function create_ssl_context in module httpx create_ssl_context(cert: 'CertTypes | None' = None, verify: 'VerifyTypes' = True, trust_env: 'bool' = True, http2: 'bool' = False) -> 'ssl.SSLContext'
httpx.delete
Python Library Documentation: function delete in module httpx
delete(url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, follow_redirects: 'bool' = False, cert: 'CertTypes | None' = None, verify: 'VerifyTypes' = True, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), trust_env: 'bool' = True) -> 'Response'
Sends a `DELETE` request.
**Parameters**: See `httpx.request`.
Note that the `data`, `files`, `json` and `content` parameters are not available
on this function, as `DELETE` requests should not include a request body.
httpx.get
Python Library Documentation: function get in module httpx
get(url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, follow_redirects: 'bool' = False, cert: 'CertTypes | None' = None, verify: 'VerifyTypes' = True, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), trust_env: 'bool' = True) -> 'Response'
Sends a `GET` request.
**Parameters**: See `httpx.request`.
Note that the `data`, `files`, `json` and `content` parameters are not available
on this function, as `GET` requests should not include a request body.
httpx.head
Python Library Documentation: function head in module httpx
head(url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, follow_redirects: 'bool' = False, cert: 'CertTypes | None' = None, verify: 'VerifyTypes' = True, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), trust_env: 'bool' = True) -> 'Response'
Sends a `HEAD` request.
**Parameters**: See `httpx.request`.
Note that the `data`, `files`, `json` and `content` parameters are not available
on this function, as `HEAD` requests should not include a request body.
httpx.main
Python Library Documentation: Command in module httpx
<Command main>
An HTTP command line client.
Sends a request and displays the response.
httpx.options
Python Library Documentation: function options in module httpx
options(url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, follow_redirects: 'bool' = False, cert: 'CertTypes | None' = None, verify: 'VerifyTypes' = True, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), trust_env: 'bool' = True) -> 'Response'
Sends an `OPTIONS` request.
**Parameters**: See `httpx.request`.
Note that the `data`, `files`, `json` and `content` parameters are not available
on this function, as `OPTIONS` requests should not include a request body.
httpx.patch
Python Library Documentation: function patch in module httpx
patch(url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, follow_redirects: 'bool' = False, cert: 'CertTypes | None' = None, verify: 'VerifyTypes' = True, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), trust_env: 'bool' = True) -> 'Response'
Sends a `PATCH` request.
**Parameters**: See `httpx.request`.
httpx.post
Python Library Documentation: function post in module httpx
post(url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, follow_redirects: 'bool' = False, cert: 'CertTypes | None' = None, verify: 'VerifyTypes' = True, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), trust_env: 'bool' = True) -> 'Response'
Sends a `POST` request.
**Parameters**: See `httpx.request`.
httpx.put
Python Library Documentation: function put in module httpx
put(url: 'URLTypes', *, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, follow_redirects: 'bool' = False, cert: 'CertTypes | None' = None, verify: 'VerifyTypes' = True, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), trust_env: 'bool' = True) -> 'Response'
Sends a `PUT` request.
**Parameters**: See `httpx.request`.
httpx.request
Python Library Documentation: function request in module httpx
request(method: 'str', url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), follow_redirects: 'bool' = False, verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, trust_env: 'bool' = True) -> 'Response'
Sends an HTTP request.
**Parameters:**
* **method** - HTTP method for the new `Request` object: `GET`, `OPTIONS`,
`HEAD`, `POST`, `PUT`, `PATCH`, or `DELETE`.
* **url** - URL for the new `Request` object.
* **params** - *(optional)* Query parameters to include in the URL, as a
string, dictionary, or sequence of two-tuples.
* **content** - *(optional)* Binary content to include in the body of the
request, as bytes or a byte iterator.
* **data** - *(optional)* Form data to include in the body of the request,
as a dictionary.
* **files** - *(optional)* A dictionary of upload files to include in the
body of the request.
* **json** - *(optional)* A JSON serializable object to include in the body
of the request.
* **headers** - *(optional)* Dictionary of HTTP headers to include in the
request.
* **cookies** - *(optional)* Dictionary of Cookie items to include in the
request.
* **auth** - *(optional)* An authentication class to use when sending the
request.
* **proxy** - *(optional)* A proxy URL where all the traffic should be routed.
* **proxies** - *(optional)* A dictionary mapping proxy keys to proxy URLs.
* **timeout** - *(optional)* The timeout configuration to use when sending
the request.
* **follow_redirects** - *(optional)* Enables or disables HTTP redirects.
* **verify** - *(optional)* SSL certificates (a.k.a CA bundle) used to
verify the identity of requested hosts. Either `True` (default CA bundle),
a path to an SSL certificate file, an `ssl.SSLContext`, or `False`
(which will disable verification).
* **cert** - *(optional)* An SSL certificate used by the requested host
to authenticate the client. Either a path to an SSL certificate file, or
two-tuple of (certificate file, key file), or a three-tuple of (certificate
file, key file, password).
* **trust_env** - *(optional)* Enables or disables usage of environment
variables for configuration.
**Returns:** `Response`
Usage:
```
>>> import httpx
>>> response = httpx.request('GET', 'https://httpbin.org/get')
>>> response
<Response [200 OK]>
```
httpx.stream
Python Library Documentation: function stream in module httpx
stream(method: 'str', url: 'URLTypes', *, params: 'QueryParamTypes | None' = None, content: 'RequestContent | None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json: 'typing.Any | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | None' = None, proxy: 'ProxyTypes | None' = None, proxies: 'ProxiesTypes | None' = None, timeout: 'TimeoutTypes' = Timeout(timeout=5.0), follow_redirects: 'bool' = False, verify: 'VerifyTypes' = True, cert: 'CertTypes | None' = None, trust_env: 'bool' = True) -> 'typing.Iterator[Response]'
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