This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 5.0.
Async HTTP Client Interface - kombu.asynchronous.http.base
¶
Base async HTTP client implementation.
- class kombu.asynchronous.http.base.Headers[source]¶
Represents a mapping of HTTP headers.
- complete = False¶
Set when all of the headers have been read.
- class kombu.asynchronous.http.base.Request(url, method='GET', on_ready=None, on_timeout=None, on_stream=None, on_prepare=None, on_header=None, headers=None, **kwargs)[source]¶
A HTTP Request.
- Parameters
url (str) – The URL to request.
method (str) – The HTTP method to use (defaults to
GET
).
- Keyword Arguments
headers (Dict, Headers) – Optional headers for this request
body (str) – Optional body for this request.
connect_timeout (float) – Connection timeout in float seconds Default is 30.0.
timeout (float) – Time in float seconds before the request times out Default is 30.0.
follow_redirects (bool) – Specify if the client should follow redirects Enabled by default.
max_redirects (int) – Maximum number of redirects (default 6).
use_gzip (bool) – Allow the server to use gzip compression. Enabled by default.
validate_cert (bool) – Set to true if the server certificate should be verified when performing
https://
requests. Enabled by default.auth_username (str) – Username for HTTP authentication.
auth_password (str) – Password for HTTP authentication.
auth_mode (str) – Type of HTTP authentication (
basic
ordigest
).user_agent (str) – Custom user agent for this request.
network_interface (str) – Network interface to use for this request.
on_ready (Callable) – Callback to be called when the response has been received. Must accept single
response
argument.on_stream (Callable) – Optional callback to be called every time body content has been read from the socket. If specified then the response body and buffer attributes will not be available.
on_timeout (callable) – Optional callback to be called if the request times out.
on_header (Callable) – Optional callback to be called for every header line received from the server. The signature is
(headers, line)
and note that if you wantresponse.headers
to be populated then your callback needs to also callclient.on_header(headers, line)
.on_prepare (Callable) – Optional callback that is implementation specific (e.g. curl client will pass the
curl
instance to this callback).proxy_host (str) – Optional proxy host. Note that a
proxy_port
must also be provided or aValueError
will be raised.proxy_username (str) – Optional username to use when logging in to the proxy.
proxy_password (str) – Optional password to use when authenticating with the proxy server.
ca_certs (str) – Custom CA certificates file to use.
client_key (str) – Optional filename for client SSL key.
client_cert (str) – Optional filename for client SSL certificate.
- auth_mode = None¶
- auth_password = None¶
- auth_username = None¶
- body = None¶
- ca_certs = None¶
- client_cert = None¶
- client_key = None¶
- connect_timeout = 30.0¶
- follow_redirects = True¶
- headers¶
- max_redirects = 6¶
- method¶
- network_interface = None¶
- on_header¶
- on_prepare¶
- on_ready¶
- on_stream¶
- on_timeout¶
- proxy_host = None¶
- proxy_password = None¶
- proxy_port = None¶
- proxy_username = None¶
- request_timeout = 30.0¶
- url¶
- use_gzip = True¶
- user_agent = None¶
- validate_cert = True¶
- class kombu.asynchronous.http.base.Response(request, code, headers=None, buffer=None, effective_url=None, error=None, status=None)[source]¶
HTTP Response.
- Parameters
- code¶
HTTP response code (e.g. 200, 404, or 500).
- Type
int
- buffer¶
Socket read buffer.
- Type
bytes
- effective_url¶
The destination url for this request after following redirects.
- Type
str
- error¶
Error instance if the request resulted in a HTTP error code.
- Type
Exception
- property body¶
The full contents of the response body.
Note
Accessing this property will evaluate the buffer and subsequent accesses will be cached.
- buffer¶
- code¶
- property content¶
- effective_url¶
- error¶
- headers¶
- request¶
- status¶
- property status_code¶