This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 5.3.

# Async HTTP Client Interface - `kombu.asynchronous.http.base`

Base async HTTP client implementation.

class kombu.asynchronous.http.base.Headers

  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)

  A HTTP Request.

  ## Arguments:

  > url (str): The URL to request. method (str): The HTTP method to use (defaults to `GET`).

  ## Keyword Arguments:

  > headers (Dict, ~kombu.asynchronous.http.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` or `digest`). 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 want `response.headers` to be populated then your callback needs to also call `client.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 a `ValueError` 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
  then(callback, errback=None)
  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)

  HTTP Response.

  Parameters:

    - (~kombu.asynchronous.http.Request) (request)

    - (int) (code)

    - (~kombu.asynchronous.http.Headers) (headers)

    - (bytes) (buffer)

    - (str) (status)

    - (str)

  request(~kombu.asynchronous.http.Request)

    get this response.

    Type:

      object used to

  code(int)
    Type:

      HTTP response code (e.g. 200, 404, or 500).

  headers(~kombu.asynchronous.http.Headers)

    for this response.

    Type:

      HTTP headers

  buffer(bytes)
    Type:

      Socket read buffer.

  effective_url(str)

    following redirects.

    Type:

      The destination url for this request after

  error(Exception)

    a HTTP error code.

    Type:

      Error instance if the request resulted in

  status(str)

    e.g. `OK`, Not found, or ‘Internal Server Error’.

    Type:

      Human equivalent of `code`,

  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
  raise_for_error()

    Raise if the request resulted in an HTTP error code.

    Raises:

      HttpError –

  request
  status
  property status_code