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)

HTTP/2 Event handler.

This handles h2 events asynchrously.

Initialization

__slots__

None

async dispatch_events(events: List)

Dispatch all received events.

async entry(data: bytes)

Entry method for processing incoming data.

async execute_synchronously_in_current_thread(func: Callable)

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)

Connection terminated.

on_new_request(event)

Received headers for a new request.

on_remote_settings_changed(event)

On RemoteSettingsChanged event handler method.

async on_request_body(event)

Called when we received a request body.

async on_request_complete(event)

Full request received.

on_stream_reset(stream_id: int)

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)

A window update frame was received.

async wait_for_flow_control(stream_id: int)

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

Parameters:

stream_id – The HTTP/2 stream ID.