protocol.http.client Module

Basic HTTP Client.

class wpull.protocol.http.client.Client(*args, stream_factory=<class 'wpull.protocol.http.stream.Stream'>, **kwargs)[source]

Bases: wpull.protocol.abstract.client.BaseClient

Stateless HTTP/1.1 client.

The session object is Session.

session() → wpull.protocol.http.client.Session[source]
class wpull.protocol.http.client.Session(stream_factory: typing.Callable=None, **kwargs)[source]

Bases: wpull.protocol.abstract.client.BaseSession

HTTP request and response session.

class Event[source]

Bases: enum.Enum

Session.abort()[source]
Session.done() → bool[source]

Return whether the session was complete.

A session is complete when it has sent a request, read the response header and the response body.

Session.download(file: typing.Union=None, raw: bool=False, rewind: bool=True, duration_timeout: typing.Union=None)[source]

Read the response content into file.

Parameters:
  • file – A file object or asyncio stream.
  • raw – Whether chunked transfer encoding should be included.
  • rewind – Seek the given file back to its original offset after reading is finished.
  • duration_timeout – Maximum time in seconds of which the entire file must be read.

Be sure to call start() first.

Coroutine.

Session.recycle()[source]
Session.start(request: wpull.protocol.http.request.Request) → wpull.protocol.http.request.Response[source]

Begin a HTTP request

Parameters:request – Request information.
Returns:A response populated with the HTTP headers.

Once the headers are received, call download().

Coroutine.

class wpull.protocol.http.client.SessionState[source]

Bases: enum.Enum