interface documentation

Streaming parser that handles PROXY protocol headers.

Method feed Consume a chunk of data and attempt to parse it.
Method parse Parse a bytestring as a full PROXY protocol header line.

Consume a chunk of data and attempt to parse it.

Parameters
data:bytesA bytestring.
Returns
Union[Tuple[IProxyInfo, bytes], Tuple[None, None]]A two-tuple containing, in order, an IProxyInfo and any bytes fed to the parser that followed the end of the header. Both of these values are None until a complete header is parsed.
Raises
InvalidProxyHeaderIf the bytes fed to the parser create an invalid PROXY header.
def parse(line: bytes) -> IProxyInfo: (source)

Parse a bytestring as a full PROXY protocol header line.

Parameters
line:bytesA bytestring that represents a valid HAProxy PROXY protocol header line.
Returns
IProxyInfoAn IProxyInfo containing the parsed data.
Raises
InvalidProxyHeaderIf the bytestring does not represent a valid PROXY header.