Skip to content

port70.client

Async Gopher protocol client implementation.

DEFAULT_TIMEOUT module-attribute

DEFAULT_TIMEOUT: Final[float] = 30.0

Default timeout in seconds for Gopher network operations.

Client

Client(
    *,
    timeout: float | None = DEFAULT_TIMEOUT,
    encoding: str = "utf-8",
)

An asynchronous client for the Gopher protocol (RFC 1436 / RFC 4266).

Parameters:

Name Type Description Default

timeout

float | None

Default timeout in seconds for requests, or None for no timeout.

DEFAULT_TIMEOUT

encoding

str

Default character encoding for response text.

'utf-8'

encoding property

encoding: str

The default character encoding for decoding responses.

timeout property

timeout: float | None

The default timeout in seconds for requests.

request async

request(
    query: str | GopherURI,
    *,
    query_terms: str | None = None,
    timeout: float | None = None,
    encoding: str | None = None,
) -> Response

Send a Gopher request to a server.

Parameters:

Name Type Description Default

query

str | GopherURI

Either a Gopher target string (e.g. 'gopher://example.com/1') or a GopherURI.

required

query_terms

str | None

Optional search query string override for search requests.

None

timeout

float | None

Optional timeout override in seconds for this request.

None

encoding

str | None

Optional character encoding override for decoding the response.

None

Returns:

Type Description
Response

A Response instance containing the server output and URI metadata.

Raises:

Type Description
URIError

If the query string cannot be parsed as a valid Gopher URI.

ConnectionError

If network connection to the server fails.

TimeoutError

If the request times out.