port70.client
Async Gopher protocol client implementation.
DEFAULT_TIMEOUT
module-attribute
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 |
|---|---|---|---|
|
float | None
|
Default timeout in seconds for requests, or None for no timeout. |
DEFAULT_TIMEOUT
|
|
str
|
Default character encoding for response text. |
'utf-8'
|
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 |
|---|---|---|---|
|
str | GopherURI
|
Either a Gopher target string (e.g. 'gopher://example.com/1') or a GopherURI. |
required |
|
str | None
|
Optional search query string override for search requests. |
None
|
|
float | None
|
Optional timeout override in seconds for this request. |
None
|
|
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. |