Skip to content

HTTPSProxyHandler

HTTPSProxyHandler

An instance of a connection from a client to the HTTPS proxy server

Each new client connection will create a new instance of this class.

client_reader instance-attribute

StreamReader for reading data from the client

client_writer instance-attribute

StreamWriter for writing data to the client

request instance-attribute

The parsed HTTP request from the client (set by the server)

on_client_connected() async

Called when a client has connected to the proxy and sent a valid request.

Override this method to implement custom behavior.

on_request_received() async

Called when a complete request has been received from the client.

Override this method to implement custom behavior.

on_error(error) async

Called when any error occurs during proxy operation.

Parameters:

Name Type Description Default
error Exception

The error that occurred

required

Override this method to implement custom error handling (logging, metrics, error responses, etc.).

read_request_body() async

Read the request body from the client. This is an async generator that yields chunks of the request body.

Yields:

Type Description
AsyncIterator[bytes]

Chunks of the request body as bytes.

write_response(content)

Write response data to the client. Until flush_response() is called, the data may be buffered.

Parameters:

Name Type Description Default
content bytes

The content to send to the client.

required

flush_response() async

Flush the response data to the client.