duck.http.core.httpd.http2.event_handler

H2 Event handler module.

Module Contents

Classes

EventHandler

HTTP/2 Event handler.

API

class duck.http.core.httpd.http2.event_handler.EventHandler(protocol, server)[source]

HTTP/2 Event handler.

This handles h2 events asynchrously.

Initialization

__slots__

None

async dispatch_events(events: List)[source]

Dispatch all received events.

async entry(data: bytes)[source]

Entry method for processing incoming data.

async execute_synchronously_in_current_thread(func: Callable)[source]

Adds a callable to sync_queue so that it will be executed outside async context, useful in multithreaded environment where threads are created for each connection and ASYNC_HANDLING=False

Parameters:

func – Callable function or method which doesn’t accept any arguments.

on_connection_terminated(event)[source]

Connection terminated.

on_new_request(event)[source]

Received headers for a new request.

on_remote_settings_changed(event)[source]

On RemoteSettingsChanged event handler method.

async on_request_body(event)[source]

Called when we received a request body.

async on_request_complete(event)[source]

Full request received.

on_stream_reset(stream_id: int)[source]

Called when the client resets a stream.

This can occur when:

  • The client cancels an in-progress request.

  • The client connection is aborted or timed out.

  • An internal protocol error is detected.

Cleans up any cached request data, pending flow control futures, or in-progress tasks associated with the given stream.

Parameters:

stream_id – The HTTP/2 stream ID that was reset.

on_window_updated(stream_id, delta)[source]

A window update frame was received.

async wait_for_flow_control(stream_id: int)[source]

Waits for a Future that fires when the flow control window is opened.

Parameters:

stream_id – The HTTP/2 stream ID.