HTTP/3 API

The HTTP/3 API performs no I/O on its own, leaving this to the API user. This allows you to integrate HTTP/3 in any Python application, regardless of the concurrency model you are using.

Connection

class aioquic.h3.connection.H3Connection(quic)

A low-level HTTP/3 connection object.

Parameters

quic (QuicConnection) – A QuicConnection instance.

handle_event(event)

Handle a QUIC event and return a list of HTTP events.

Parameters

event (QuicEvent) – The QUIC event to handle.

Return type

List[H3Event]

send_data(stream_id, data, end_stream)

Send data on the given stream.

To retrieve datagram which need to be sent over the network call the QUIC connection’s datagrams_to_send() method.

Parameters
  • stream_id (int) – The stream ID on which to send the data.

  • data (bytes) – The data to send.

  • end_stream (bool) – Whether to end the stream.

Return type

None

send_headers(stream_id, headers, end_stream=False)

Send headers on the given stream.

To retrieve datagram which need to be sent over the network call the QUIC connection’s datagrams_to_send() method.

Parameters
  • stream_id (int) – The stream ID on which to send the headers.

  • headers (List[Tuple[bytes, bytes]]) – The HTTP headers to send.

  • end_stream (bool) – Whether to end the stream.

Return type

None

send_push_promise(stream_id, headers)

Send a push promise related to the specified stream.

Returns the stream ID on which headers and data can be sent.

Parameters
  • stream_id (int) – The stream ID on which to send the data.

  • headers (List[Tuple[bytes, bytes]]) – The HTTP request headers for this push.

Return type

int

Events

class aioquic.h3.events.H3Event

Base class for HTTP/3 events.

class aioquic.h3.events.DataReceived(data, stream_id, stream_ended, push_id=None)

The DataReceived event is fired whenever data is received on a stream from the remote peer.

data: bytes

The data which was received.

push_id: Optional[int] = None

The Push ID or None if this is not a push.

stream_ended: bool

Whether the STREAM frame had the FIN bit set.

stream_id: int

The ID of the stream the data was received for.

class aioquic.h3.events.HeadersReceived(headers, stream_id, stream_ended, push_id=None)

The HeadersReceived event is fired whenever headers are received.

headers: Headers

The headers.

push_id: Optional[int] = None

The Push ID or None if this is not a push.

stream_ended: bool

Whether the STREAM frame had the FIN bit set.

stream_id: int

The ID of the stream the headers were received for.

class aioquic.h3.events.PushPromiseReceived(headers, push_id, stream_id)

The PushedStreamReceived event is fired whenever a pushed stream has been received from the remote peer.

headers: Headers

The request headers.

push_id: int

The Push ID of the push promise.

stream_id: int

The Stream ID of the stream that the push is related to.

Exceptions

class aioquic.h3.exceptions.H3Error

Base class for HTTP/3 exceptions.

class aioquic.h3.exceptions.NoAvailablePushIDError

There are no available push IDs left.