httpy.http2 package

Subpackages

Submodules

httpy.http2.connection module

class httpy.http2.connection.AsyncConnection(host, port, debugger, client_settings={}, sock=None)

Bases: object

Asynchronous HTTP/2 Connection implementation. For method description, see Connection.__doc__

close(*args, **kwargs)
close_on_error(*args, **kwargs)
close_on_internal_error(*args, **kwargs)
close_socket(*args, **kwargs)
create_stream(*args, **kwargs)
classmethod from_socket(socket, debugger, host, port, client_settings={})
process_next_frame(*args, **kwargs)
send_frame(*args, **kwargs)
async start()
update_server_settings(new_settings)
update_settings(**new_settings)
class httpy.http2.connection.Connection(host, port, debugger, client_settings={}, sock=None)

Bases: object

A synchronous HTTP/2 Conection implementation

close(*args, **kwargs)
close_on_error(*args, **kwargs)
close_on_internal_error(*args, **kwargs)
close_socket(*args, **kwargs)
create_stream(*args, **kwargs)
classmethod from_socket(socket, debugger, host, port, client_settings={})

Builds a Connection from a socket

process_next_frame(*args, **kwargs)
send_frame(*args, **kwargs)
start()

Starts a HTTP2 connection to the server.

update_server_settings(new_settings)

Updates the server_settings upon the receival of a SETTINGS frame

update_settings(**new_settings)

Sends a SETTINGS frame with new settings

async httpy.http2.connection.async_initiate_connection(reader, writer, client_settings)

Initiates an asynchronous connection by sending the connection preface and exchanging settings frames

async httpy.http2.connection.async_start_connection(host, port, client_settings, alpn=True)

Starts an asynchronous connection to a given server

httpy.http2.connection.initiate_connection(sock, client_settings)

Initiates the connection on a socket by sending the connection preface and exchanging settings frames

httpy.http2.connection.start_connection(host, port, client_settings, alpn=True)

Starts a connection to a given server.

httpy.http2.error module

httpy.http2.error.CANCEL

alias of CANCEL

httpy.http2.error.COMPRESSION_ERROR

alias of COMPRESSION_ERROR

httpy.http2.error.CONNECT_ERROR

alias of CONNECT_ERROR

httpy.http2.error.ENHANCE_YOUR_CALM

alias of ENHANCE_YOUR_CALM

class httpy.http2.error.ErrType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

CONNECTION = 0
STREAM = 1
httpy.http2.error.FLOW_CONTROL_ERROR

alias of FLOW_CONTROL_ERROR

httpy.http2.error.FRAME_SIZE_ERROR

alias of FRAME_SIZE_ERROR

exception httpy.http2.error.HTTP2Error(*args, errtype=None, send=True)

Bases: Exception

code = NotImplemented
errtype = None
name = NotImplemented
httpy.http2.error.HTTP_1_1_REQUIRED

alias of HTTP_1_1_REQUIRED

httpy.http2.error.INADEQUATE_SECURITY

alias of INADEQUATE_SECURITY

httpy.http2.error.INTERNAL_ERROR

alias of INTERNAL_ERROR

exception httpy.http2.error.InvalidStreamID(*args, errtype=None, send=True)

Bases: HTTP2Error

httpy.http2.error.NO_ERROR

alias of NO_ERROR

httpy.http2.error.PROTOCOL_ERROR

alias of PROTOCOL_ERROR

exception httpy.http2.error.PayloadOverflow(*args, errtype=None, send=True)

Bases: HTTP2Error

httpy.http2.error.REFUSED_STREAM

alias of REFUSED_STREAM

exception httpy.http2.error.Refuse

Bases: Exception

httpy.http2.error.SETTINGS_TIMEOUT

alias of SETTINGS_TIMEOUT

httpy.http2.error.STREAM_CLOSED

alias of STREAM_CLOSED

exception httpy.http2.error.UNKNOWN_ERROR(*args, errtype=None, send=True)

Bases: HTTP2Error

code = 13
errtype = 0
name = 'HTTP_1_1_REQUIRED'
async httpy.http2.error.async_throw(frame, send=False, conn=None)
httpy.http2.error.throw(frame, send=False, conn=None)

httpy.http2.frame module

class httpy.http2.frame.ConnectionToken(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

CONNECTION_CLOSE = 0
class httpy.http2.frame.ContinuationFrame(end_headers=False, **kwargs)

Bases: HTTP2Frame

frame_type = 9
classmethod frombytes(payload, streamid, flags, **kwargs)
class httpy.http2.frame.DataFrame(data, padding=0, end_stream=False, **kwargs)

Bases: HTTP2Frame

frame_type = 0
classmethod frombytes(payload, payload_length, streamid, flags, **kwargs)
class httpy.http2.frame.GoAwayFrame(last_stream_id, error_code, debugdata=b'', **kwargs)

Bases: HTTP2Frame

frame_type = 7
classmethod frombytes(payload, streamid, **kwargs)
class httpy.http2.frame.HTTP2Frame(instance=None, type=None, payload=None, flags=0, streamid=0, frame_size=16384, **_)

Bases: object

frame_type = -1
tobytes()
class httpy.http2.frame.HeadersFrame(header_fragment, pad_length=0, priority_weight=None, stream_dependency=None, end_stream=False, end_headers=False, **kwargs)

Bases: HTTP2Frame

decode_headers(hpack)
frame_type = 1
classmethod frombytes(payload, payload_length, flags, streamid, **kwargs)
class httpy.http2.frame.PingFrame(data=b'\x00\x00\x00\x00\x00\x00\x00\x00', ack=False, **kwargs)

Bases: HTTP2Frame

frame_type = 6
classmethod frombytes(payload, payload_length, flags, streamid, **kwargs)
class httpy.http2.frame.PriorityFrame(stream_dependency, priority_weight, **kwargs)

Bases: HTTP2Frame

frame_type = 2
classmethod frombytes(payload, payload_length, streamid, **kwargs)
class httpy.http2.frame.PushPromiseFrame(promised_stream, header_fragment, pad_length=0, end_headers=False, **kwargs)

Bases: HTTP2Frame

frame_type = 5
classmethod frombytes(payload, payload_length, flags, streamid, **kwargs)
class httpy.http2.frame.RstStreamFrame(errcode, **kwargs)

Bases: HTTP2Frame

frame_type = 3
classmethod frombytes(payload, payload_length, streamid, **kwargs)
class httpy.http2.frame.SettingsFrame(header_table_size=None, enable_push=None, max_concurrent_streams=None, initial_window_size=None, max_frame_size=None, max_header_list_size=None, ack=False, **kwargs)

Bases: HTTP2Frame

frame_type = 4
classmethod frombytes(payload, payload_length, flags, streamid, **kwargs)
class httpy.http2.frame.WindowUpdateFrame(increment, **kwargs)

Bases: HTTP2Frame

frame_type = 8
classmethod frombytes(payload, payload_length, **kwargs)
async httpy.http2.frame.async_parse(reader)
async httpy.http2.frame.async_parse_data(reader)
httpy.http2.frame.parse(stream)
httpy.http2.frame.parse_data(stream)

httpy.http2.frame_queue module

class httpy.http2.frame_queue.AsyncFrameQueue(streams, conn)

Bases: object

add_stream(s)
async process(f)
async quit()
async throw(err)
class httpy.http2.frame_queue.FrameQueue(streams, conn)

Bases: object

add_stream(s)
process(f)
quit()
throw(err)

httpy.http2.priority module

class httpy.http2.priority.StreamDependency(stream, exc=False)

Bases: object

httpy.http2.proto module

class httpy.http2.proto.AsyncHTTP2Recver

Bases: object

Asynchronous HTTP/2 receiver implementation. For method details, see HTTP2Recver.__doc__

class httpy.http2.proto.AsyncHTTP2Sender(method, headers, body, path, debugger, authority=None, *_, **__)

Bases: object

Asynchronous HTTP/2 sender implementation. For method details, see HTTP2Sender.__doc__

async send(connection)

Creates a new stream and sends the frames to it

class httpy.http2.proto.HTTP2Headers(headers)

Bases: CaseInsensitiveDict

class httpy.http2.proto.HTTP2Recver

Bases: object

A synchronous HTTP/2 receiver implementation.

class httpy.http2.proto.HTTP2Sender(method, headers, body, path, debugger, authority=None, *_, **__)

Bases: object

A synchronous HTTP/2 sender.

send(connection)

Creates a new stream and sends the frames to it

httpy.http2.proto.serialize_data(data, max_frame_size)

Serialises data as a sequence of DATA frames

httpy.http2.proto.serialize_headers(headers, connection, end_stream, max_frame_size)

Serialises headers as a sequence of HEADERS/CONTINUATION frames

httpy.http2.settings module

class httpy.http2.settings.Settings(sd, client, server)

Bases: object

httpy.http2.settings.merge_client_settings(new, old)
httpy.http2.settings.merge_settings(server, client)

httpy.http2.socket_reader module

class httpy.http2.socket_reader.SocketReader(sock)

Bases: object

property closed
read(nbytes)

httpy.http2.stream module

class httpy.http2.stream.AsyncStream(streamid, conn, window_size, weight=0, dependency=0)

Bases: object

Asynchronous HTTP/2 stream implementation For method description, see Stream.__doc__

async error_check(f)
async recv_frame(enable_closed=False, frame_filter=None)
async send_frame(f)
class httpy.http2.stream.Stream(streamid, conn, window_size, weight=0, dependency=0)

Bases: object

A HTTP/2 synchronous stream implementation.

error_check(f)

Checks a frame for stream state errors.

recv_frame(enable_closed=False, frame_filter=None)

Returns the last frame received on this stream.

send_frame(f)

Sends a frame to the server on this stream.

class httpy.http2.stream.StreamEvent(token, value)

Bases: object

class httpy.http2.stream.StreamState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

CLOSED = 6
HALF_CLOSED_LOCAL = 4
HALF_CLOSED_REMOTE = 5
IDLE = 0
OPEN = 3
RESERVED_LOCAL = 1
RESERVED_REMOTE = 2
class httpy.http2.stream.StreamToken(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

CLOSE_TOKEN = 0
ERROR_TOKEN = 2
FRAME_TOKEN = 1

httpy.http2.streams module

class httpy.http2.streams.Streams(max_concurrent_streams, conn)

Bases: object

add_stream(s)
close_stream(streamid)

httpy.http2.window module

class httpy.http2.window.Window(max_window_size)

Bases: object

increase_size(si)
process(nbytes)
received_frame(f)
update_max_window_size(new_size)

Module contents