proxy.http.handler 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.handler.HttpProtocolHandler(*args: Any, **kwargs: Any)[source]#

Bases: proxy.core.base.tcp_server.BaseTcpServerHandler[proxy.http.connection.HttpClientConnection]

HTTP, HTTPS, HTTP2, WebSockets protocol handler.

Accepts Client connection and delegates to HttpProtocolHandlerPlugin.

_abc_impl = <_abc._abc_data object>#
_connection_inactive_for() float[source]#
_discover_plugin_klass(protocol: int) Optional[Type[proxy.http.plugin.HttpProtocolHandlerPlugin]][source]#

Discovers and return matching HTTP handler plugin matching protocol.

_flush() None[source]#
_initialize_plugin(klass: Type[proxy.http.plugin.HttpProtocolHandlerPlugin]) proxy.http.plugin.HttpProtocolHandlerPlugin[source]#

Initializes passed HTTP protocol handler plugin class.

_parse_first_request(data: memoryview) bool[source]#
async _run_once() bool[source]#
async _selected_events() Tuple[Dict[int, int], List[int], List[int]][source]#
static create(*args: Any) proxy.http.connection.HttpClientConnection[source]#

Implementations are responsible for creation of work objects from incoming args. This helps keep work core agnostic to creation of externally defined work class objects.

async get_events() Dict[int, int][source]#

Return sockets and events (read or write) that we are interested in.

handle_data(data: memoryview) Optional[bool][source]#

Handles incoming data from client.

async handle_events(readables: List[int], writables: List[int]) bool[source]#

Returns True if proxy must tear down.

async handle_readables(readables: List[int]) bool[source]#
async handle_writables(writables: List[int]) bool[source]#
initialize() None[source]#

Optionally upgrades connection to HTTPS, sets conn in non-blocking mode and initializes HTTP protocol plugins.

is_inactive() bool[source]#

Return True if connection should be considered inactive.

last_activity: float#
plugin: Optional[proxy.http.plugin.HttpProtocolHandlerPlugin]#
reads_teared: bool#
request: proxy.http.parser.parser.HttpParser#
run() None[source]#

run() method is not used when in –threadless mode.

This is here just to maintain backward compatibility with threaded mode.

selector: Optional[selectors.EpollSelector]#
shutdown() None[source]#

Implementation must close any opened resources here and call super().shutdown().

start_time: float#
uid: str#
writes_teared: bool#