Protocol Types¶
The protocol module contains the request and response types.
FingerRequest¶
FingerRequest
dataclass
¶
FingerRequest(
query: str,
username: str,
hostname: str,
port: int,
verbose: bool,
query_type: QueryType,
)
Represents a Finger protocol request.
RFC 1288 Query Specification:
{Q1} ::= [{W}|{W}{S}{U}]{C}
{Q2} ::= [{W}{S}][{U}]
{U} ::= username
{H} ::= @hostname | @hostname{H}
{W} ::= /W
{S} ::=
Attributes:
| Name | Type | Description |
|---|---|---|
query |
str
|
The raw query string (without CRLF). |
username |
str
|
Username to query (may be empty). |
hostname |
str
|
Target hostname. |
port |
int
|
Target port. |
verbose |
bool
|
Whether verbose (/W) output is requested. |
query_type |
QueryType
|
Classification of the query type. |
wire_query
property
¶
Get the query string to send for this request.
For remote queries, this returns only the local part (user or /W user). The hostname is used for connection, not sent in the query.
parse
classmethod
¶
parse(
query: str,
default_host: str | None = None,
default_port: int = DEFAULT_PORT,
) -> FingerRequest
Parse a Finger query string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Query string (e.g., "username", "@host", "user@host", "/W user") |
required |
default_host
|
str | None
|
Default host if none specified in query |
None
|
default_port
|
int
|
Default port if none specified |
DEFAULT_PORT
|
Returns:
| Type | Description |
|---|---|
FingerRequest
|
FingerRequest instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If query format is invalid or no host available |
Source code in src/mapilli/protocol/request.py
to_wire
¶
Convert request to wire format (query + CRLF).
Returns:
| Type | Description |
|---|---|
bytes
|
Bytes ready to send over TCP |
FingerResponse¶
FingerResponse
dataclass
¶
Represents a Finger protocol response.
Per RFC 1288, responses are plain ASCII text with lines ending in CRLF. The connection closes after the response is complete.
Attributes:
| Name | Type | Description |
|---|---|---|
body |
str
|
The response text content. |
host |
str
|
The host that was queried. |
port |
int
|
The port used for the query. |
query |
str
|
The original query string. |
QueryType¶
QueryType
¶
Bases: Enum
Type of Finger query.