proxy.http.plugin module#

proxy.py#

⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging.

copyright
  1. 2013-present by Abhinav Singh and contributors.

license

BSD, see LICENSE for more details.

class proxy.http.plugin.HttpProtocolHandlerPlugin(uid: str, flags: argparse.Namespace, client: proxy.http.connection.HttpClientConnection, request: proxy.http.parser.parser.HttpParser, event_queue: Optional[proxy.core.event.queue.EventQueue] = None, upstream_conn_pool: Optional[UpstreamConnectionPool] = None)[source]#

Bases: proxy.http.descriptors.DescriptorsHandlerMixin, abc.ABC

Base HttpProtocolHandler Plugin class.

NOTE: This is an internal plugin and in most cases only useful for core contributors. If you are looking for proxy server plugins see <proxy.HttpProxyBasePlugin>.

Implements various lifecycle events for an accepted client connection. Following events are of interest:

  1. Client Connection Accepted A new plugin instance is created per accepted client connection. Add your logic within __init__ constructor for any per connection setup.

  2. Client Request Chunk Received on_client_data is called for every chunk of data sent by the client.

  3. Client Request Complete on_request_complete is called once client request has completed.

  4. Server Response Chunk Received on_response_chunk is called for every chunk received from the server.

  5. Client Connection Closed Add your logic within on_client_connection_close for any per connection tear-down.

_abc_impl = <_abc._abc_data object>#
client: proxy.http.connection.HttpClientConnection#
flags: argparse.Namespace#
abstract on_client_connection_close() None[source]#

Client connection shutdown has been received, flush has been called, perform any cleanup work here.

abstract on_client_data(raw: memoryview) None[source]#

Called only after original request has been completely received.

abstract on_request_complete() Union[socket.socket, bool][source]#

Called right after client request parser has reached COMPLETE state.

abstract on_response_chunk(chunk: List[memoryview]) List[memoryview][source]#

Handle data chunks as received from the server.

Return optionally modified chunk to return back to client.

abstract static protocols() List[int][source]#
request: proxy.http.parser.parser.HttpParser#
property tls_interception_enabled: bool#
uid: str#