Skip to content

sybaritic.client

Client

Client(timeout: float = 10.0)

An asynchronous Spartan protocol client.

Parameters:

Name Type Description Default

timeout

float

Default connection and read timeout in seconds. Defaults to 10.0.

10.0

get async

get(
    uri: str | SpartanURI,
    *,
    timeout: float | None = None,
    follow_redirects: bool = True,
    max_redirects: int = 5,
) -> Response

Convenience method for GET request (no payload).

post async

post(
    uri: str | SpartanURI,
    data: bytes | str,
    *,
    timeout: float | None = None,
    follow_redirects: bool = True,
    max_redirects: int = 5,
) -> Response

Convenience method for POST request with data payload.

request async

request(
    uri: str | SpartanURI,
    data: bytes | str | None = None,
    *,
    timeout: float | None = None,
    follow_redirects: bool = True,
    max_redirects: int = 5,
) -> Response

Perform a Spartan request with optional redirect following.

Parameters:

Name Type Description Default

uri

str | SpartanURI

Target Spartan URI string or SpartanURI.

required

data

bytes | str | None

Optional data payload to upload.

None

timeout

float | None

Optional override for connection timeout in seconds.

None

follow_redirects

bool

Whether to follow status 3 redirects automatically.

True

max_redirects

int

Maximum number of redirects to follow before raising error.

5

Returns:

Type Description
Response

Response object containing final target URI, history, and status.

send_request async

send_request(
    uri: SpartanURI,
    data: bytes | str | None = None,
    timeout: float | None = None,
) -> Response

Send a single low-level Spartan request to the server without following redirects.

Parameters:

Name Type Description Default

uri

SpartanURI

Target SpartanURI object.

required

data

bytes | str | None

Optional payload string or bytes.

None

timeout

float | None

Optional connection timeout in seconds.

None

Returns:

Type Description
Response

Response object.

get async

get(
    uri: str | SpartanURI,
    *,
    timeout: float = 10.0,
    follow_redirects: bool = True,
    max_redirects: int = 5,
) -> Response

Top-level convenience function to make a GET request.

post async

post(
    uri: str | SpartanURI,
    data: bytes | str,
    *,
    timeout: float = 10.0,
    follow_redirects: bool = True,
    max_redirects: int = 5,
) -> Response

Top-level convenience function to make a POST request with payload data.

request async

request(
    uri: str | SpartanURI,
    data: bytes | str | None = None,
    *,
    timeout: float = 10.0,
    follow_redirects: bool = True,
    max_redirects: int = 5,
) -> Response

Top-level convenience function to make a Spartan request.