reqivo.client packageΒΆ

SubmodulesΒΆ

reqivo.client.auth moduleΒΆ

src/reqivo/client/auth.py

Authentication helpers for Reqivo.

reqivo.client.auth.build_basic_auth_header(username: str, password: str) str[source]ΒΆ

Build Basic Auth header from username and password.

Parameters:
  • username – Username for authentication.

  • password – Password for authentication.

Returns:

Basic Auth header value.

reqivo.client.auth.build_bearer_auth_header(token: str) str[source]ΒΆ

Build Bearer token header.

Parameters:

token – Bearer token for authentication.

Returns:

Bearer token header value.

reqivo.client.request moduleΒΆ

src/reqivo/client/request.py

HTTP request builder and sender.

class reqivo.client.request.Request[source]ΒΆ

Bases: object

HTTP request builder and sender.

classmethod set_session_instance(session: Session | None) None[source]ΒΆ

Sets the current session instance for the request.

static build_request(method: str, path: str, host: str, headers: Dict[str, str], body: str | bytes | None) bytes[source]ΒΆ

Builds the raw HTTP request bytes.

classmethod send(method: str, url: str, headers: Dict[str, str] | None = None, body: str | bytes | None = None, timeout: float | Timeout | None = 5, connection: Connection | None = None, allow_redirects: bool = True, max_redirects: int = 30, limits: Dict[str, int] | None = None) Response[source]ΒΆ

Sends an HTTP request with automatic redirects support.

class reqivo.client.request.AsyncRequest[source]ΒΆ

Bases: object

Asynchronous HTTP request builder and sender.

classmethod set_session_instance(session: AsyncSession | None) None[source]ΒΆ

Sets the current session instance for the async request.

async classmethod send(method: str, url: str, headers: Dict[str, str] | None = None, body: str | bytes | None = None, timeout: float | Timeout | None = 5, connection: AsyncConnection | None = None, allow_redirects: bool = True, max_redirects: int = 30, limits: Dict[str, int] | None = None) Response[source]ΒΆ

Sends an async request with automatic redirects support.

reqivo.client.response moduleΒΆ

src/reqivo/client/response.py

HTTP Response handling module.

This module provides classes for parsing and handling HTTP responses, including status line, headers, and body parsing.

exception reqivo.client.response.ResponseParseError[source]ΒΆ

Bases: Exception

Exception raised when HTTP response parsing fails.

class reqivo.client.response.Response(raw_response: bytes, connection: Connection | None = None, stream: bool = False, limits: Dict[str, int] | None = None)[source]ΒΆ

Bases: object

Represents a parsed HTTP response.

rawΒΆ

Original raw response bytes (headers + initial body).

status_lineΒΆ

HTTP status line (e.g., β€œHTTP/1.1 200 OK”).

status_codeΒΆ

HTTP status code as integer.

headersΒΆ

Dictionary of response headers (normalized to Title-Case).

bodyΒΆ

Response body as bytes (full content if stream=False).

urlΒΆ

URL of the response (if set externally).

property status: intΒΆ

Alias for status_code for compatibility.

property stream: boolΒΆ

Whether the response is streamed.

iter_content(chunk_size: int = 4096) Generator[bytes, None, None][source]ΒΆ

Iterate over the response body.

Parameters:

chunk_size – Size of chunks to read.

Yields:

Bytes chunks.

text(encoding: str | None = None) str[source]ΒΆ

Return decoded text. Note: Accessing .text on a stream (without iterating) consumes it into memory.

json() Any[source]ΒΆ

Returns JSON-decoded body.

close() None[source]ΒΆ

Close the underlying connection.

reqivo.client.session moduleΒΆ

src/reqivo/client/session.py

HTTP Session management module.

This module provides session functionality for persistent HTTP connections, cookie management, authentication, and request state across multiple HTTP calls.

class reqivo.client.session.Session(limits: Dict[str, int] | None = None)[source]ΒΆ

Bases: object

HTTP session manager for persistent connections and state.

This class manages session-specific data like cookies, persistent headers, and authentication credentials across multiple requests.

cookiesΒΆ

Dictionary of stored cookies.

headersΒΆ

Persistent headers for all requests.

poolΒΆ

Connection pool for reuse.

_basic_authΒΆ

Basic authentication credentials.

_bearer_tokenΒΆ

Bearer token for authentication.

set_basic_auth(username: str, password: str) None[source]ΒΆ

Set Basic Auth credentials for the session.

Parameters:
  • username – Username for authentication.

  • password – Password for authentication.

set_bearer_token(token: str) None[source]ΒΆ

Set Bearer token for the session.

Parameters:

token – Bearer token for authentication.

get(url: str, headers: Dict[str, str] | None = None, timeout: float | None = 5, limits: Dict[str, int] | None = None) Response[source]ΒΆ

Sends a GET request.

post(url: str, *, headers: Dict[str, str] | None = None, body: str | bytes | None = None, timeout: float | None = 5, limits: Dict[str, int] | None = None) Response[source]ΒΆ

Sends a POST request.

close() None[source]ΒΆ

Close all open connections in the connection pool.

Should be called when done with the session to free resources.

class reqivo.client.session.AsyncSession(limits: Dict[str, int] | None = None)[source]ΒΆ

Bases: object

Asynchronous HTTP session manager.

set_basic_auth(username: str, password: str) None[source]ΒΆ

Set basic auth.

set_bearer_token(token: str) None[source]ΒΆ

Set bearer token.

async get(url: str, headers: Dict[str, str] | None = None, timeout: float | None = 5, limits: Dict[str, int] | None = None) Response[source]ΒΆ

Async GET.

async close() None[source]ΒΆ

Close pool.

reqivo.client.websocket moduleΒΆ

src/reqivo/client/websocket.py

WebSocket client implementation (Sync and Async).

class reqivo.client.websocket.WebSocket(url: str, timeout: float | None = None, headers: Dict[str, str] | None = None, subprotocols: List[str] | None = None)[source]ΒΆ

Bases: object

Synchronous WebSocket Client.

connect() None[source]ΒΆ

Establishes the WebSocket connection.

send(data: str | bytes) None[source]ΒΆ

Sends data through the WebSocket.

recv() str | bytes[source]ΒΆ

Receives data from the WebSocket.

ping(payload: bytes = b'') None[source]ΒΆ

Sends a PING frame.

pong(payload: bytes = b'') None[source]ΒΆ

Sends a PONG frame.

close() None[source]ΒΆ

Closes the WebSocket connection.

class reqivo.client.websocket.AsyncWebSocket(url: str, timeout: float | None = None, headers: Dict[str, str] | None = None, subprotocols: List[str] | None = None)[source]ΒΆ

Bases: object

Asynchronous WebSocket Client.

async connect() None[source]ΒΆ

Async connect.

async send(data: str | bytes) None[source]ΒΆ

Sends data through the WebSocket asynchronously.

async recv() str | bytes[source]ΒΆ

Async recv.

async ping(payload: bytes = b'') None[source]ΒΆ

Async ping.

async pong(payload: bytes = b'') None[source]ΒΆ

Async pong.

async close() None[source]ΒΆ

Async close.