ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

class documentation

class ClientResponse: (source)

View In Hierarchy

Store the status, ordered header fields and bounded body of a response.

Repeated header fields retain their wire order.

Method body Return the complete, bounded response body.
Method clientError Return whether the status is in the client error class.
Method failed Return whether the response has an HTTP error status.
Method header Return the first matching header or the supplied default.
Method headers Return every header field in wire order, including duplicate names.
Method headerValues Return every value of a case-insensitive header name.
Method json Decode JSON and optionally traverse a dot-separated object path.
Method ok Return whether the response has status 200.
Method serverError Return whether the status is in the server error class.
Method status Return the HTTP status code.
Method successful Return whether the status is in the successful class.
Method text Decode using the declared character set, defaulting to UTF-8.
Method throw Raise a status exception on 4xx or 5xx, otherwise return this result.
Instance Variable _body Complete response body retained after the stream closes.
Instance Variable _headers Header fields in received order, including duplicates.
Instance Variable _status HTTP status code supplied by the transport.
def body(self) -> bytes: (source)

Return the complete, bounded response body.

Returns
bytesComplete response body.
def clientError(self) -> bool: (source)

Return whether the status is in the client error class.

Returns
boolTrue if the status is in the client error class.
def failed(self) -> bool: (source)

Return whether the response has an HTTP error status.

Returns
boolTrue if the response has an HTTP error status.
def header(self, name: str, default: str | None = None) -> str | None: (source)

Return the first matching header or the supplied default.

Parameters
name:strCase-insensitive HTTP field name.
default:str | NoneValue returned when the header is absent.
Returns
str | NoneFirst matching value or the supplied default.
def headers(self) -> tuple[tuple[str, str], ...]: (source)

Return every header field in wire order, including duplicate names.

Returns
tuple of tuple[str, str]All header pairs in wire order, including repeated field names.
def headerValues(self, name: str) -> tuple[str, ...]: (source)

Return every value of a case-insensitive header name.

Parameters
name:strCase-insensitive HTTP field name.
Returns
tuple of strMatching values in wire order.
def json(self, path: str | None = None, *, default: object = MISSING) -> object: (source)

Decode JSON and optionally traverse a dot-separated object path.

Parameters
path:str | NoneDot-separated object path, or None for the decoded document.
default:objectValue returned when a path segment is missing.
Returns
objectDecoded document, selected value or the explicit fallback.
Raises
HttpDecodeExceptionIf the body contains invalid JSON or exceeds the decoder nesting limit.
KeyErrorIf the object path is missing and no default was supplied.
def ok(self) -> bool: (source)

Return whether the response has status 200.

Returns
boolTrue if the response has status 200.
def serverError(self) -> bool: (source)

Return whether the status is in the server error class.

Returns
boolTrue if the status is in the server error class.
def status(self) -> int: (source)

Return the HTTP status code.

Returns
intNumeric HTTP status code.
def successful(self) -> bool: (source)

Return whether the status is in the successful class.

Returns
boolTrue if the status is in the successful class.
def text(self) -> str: (source)

Decode using the declared character set, defaulting to UTF-8.

Returns
strDecoded response text.
Raises
HttpDecodeExceptionIf the declared charset is unknown or the body cannot be decoded.
def throw(self) -> Self: (source)

Raise a status exception on 4xx or 5xx, otherwise return this result.

Returns
ClientResponseThis response after checking its status.
Raises
HttpStatusExceptionIf the response has a 4xx or 5xx status.

Complete response body retained after the stream closes.

_headers: tuple of tuple[str, str] = (source)

Header fields in received order, including duplicates.

HTTP status code supplied by the transport.