ovok_sdk.http.transport

The pluggable transport that sends HTTP requests.

  • Stable unknown
  • Release candidate since 0.1.0-rc.4
  • Development since 0.1.0-dev.25+2ba84b0

The pluggable transport that sends HTTP requests.

OvokRequest

OvokRequest(
    method: str,
    url: str,
    headers: Mapping[str, str],
    body: str | None,
    timeout: float,
)

An HTTP request ready to send.

Attributes

NameTypeDescription
methodstrHTTP method.
urlstrAbsolute URL.
headersMapping[str, str]Request headers; never shown in repr.
bodystr | NoneEncoded body, or None.
timeoutfloatTimeout in seconds.

OvokResponse

OvokResponse(status: int, headers: Mapping[str, str], body: str)

An HTTP response of any status.

Attributes

NameTypeDescription
statusintHTTP status.
headersMapping[str, str]Response headers; never shown in repr.
bodystrDecoded body text.

is_success

is_success: bool

Whether the status is 2xx.

header(name: str) -> str | None

Return the header name, matched case-insensitively, or None.

json()

json() -> Any

Parse the body as JSON.

Returns

  • Any: The parsed body, or None when it is empty.

Raises

  • OvokError: The body is not JSON.

Transport

Transport()

Bases: Protocol

Sends one request; answers every HTTP status, raising only when no answer came.

UrllibTransport

UrllibTransport(open_url: OpenUrl = urlopen)

The default Transport, built on urllib.request.

Parameters

NameTypeDefaultDescription
open_urlOpenUrlurlopenOpens a request; defaults to urllib.request.urlopen.

Last updated on

On this page