Skip to content

HTTPSForwardProxyHandler

HTTPSForwardProxyHandler()

Bases: HTTPSProxyHandler

A forward proxy handler that implements HTTP/HTTPS proxying without external dependencies.

This handler automatically forwards HTTP and HTTPS requests to their target destinations and provides hooks for intercepting and modifying requests and responses.

Note: CONNECT method is not supported by this handler.

on_request_received() async

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

Override this method to modify the request before it's forwarded.

on_response_received() async

Called when a complete response has been received from the upstream server.

Override this method to modify the response before it's sent to the client.

on_response_chunk(chunk) async

Called for each chunk of response body data.

Parameters:

Name Type Description Default
chunk bytes

The response data chunk

required

Returns:

Type Description
bytes | None

Modified chunk to forward, or None to skip this chunk

on_response_complete() async

Called when the response has been completely forwarded to the client.

Use this to perform cleanup or logging after response completion.

forward_http_request() async

Forward the request