module HTTP2

Extends
Configurable

Inherited Methods

From Async::HTTP::Protocol::Configurable:

Provides an HTTP/2 client and server protocol implementation.

Classes and Modules

class Client < ::Protocol::HTTP2::Client

An HTTP/2 client connection that sends requests and reads responses.

module Connection

Provides shared connection behaviour for HTTP/2 client and server connections.

class Input < ::Protocol::HTTP::Body::Writable

A writable body which requests window updates when data is read from it.

class Output

Writes body data to an HTTP/2 stream, respecting flow control windows.

class Request < Protocol::Request

Typically used on the server side to represent an incoming request, and write the response.

class Response < Protocol::Response

Typically used on the client side for writing a request and reading the incoming response.

class Server < ::Protocol::HTTP2::Server

An HTTP/2 server connection that receives requests and sends responses.

class Stream < ::Protocol::HTTP2::Stream

An HTTP/2 stream that manages headers, input data, and output data for a single request/response exchange.

Definitions

def self.bidirectional?

Signature

returns Boolean

Whether the protocol supports bidirectional communication.

Implementation

def self.bidirectional?
	true
end

def self.trailer?

Signature

returns Boolean

Whether the protocol supports trailers.

Implementation

def self.trailer?
	true
end

CLIENT_SETTINGS = {...}

The default settings for the client.

Implementation

CLIENT_SETTINGS = {
	::Protocol::HTTP2::Settings::ENABLE_PUSH => 0,
	::Protocol::HTTP2::Settings::MAXIMUM_FRAME_SIZE => 0x100000,
	::Protocol::HTTP2::Settings::INITIAL_WINDOW_SIZE => 0x800000,
	::Protocol::HTTP2::Settings::NO_RFC7540_PRIORITIES => 1,
}

SERVER_SETTINGS = {...}

The default settings for the server.

Implementation

SERVER_SETTINGS = {
	# We choose a lower maximum concurrent streams to avoid overloading a single connection/thread.
	::Protocol::HTTP2::Settings::MAXIMUM_CONCURRENT_STREAMS => 128,
	::Protocol::HTTP2::Settings::MAXIMUM_FRAME_SIZE => 0x100000,
	::Protocol::HTTP2::Settings::INITIAL_WINDOW_SIZE => 0x800000,
	::Protocol::HTTP2::Settings::ENABLE_CONNECT_PROTOCOL => 1,
	::Protocol::HTTP2::Settings::NO_RFC7540_PRIORITIES => 1,
}

def self.client(peer, settings: CLIENT_SETTINGS)

Create a client for an outbound connection.

Signature

parameter peer IO

The peer to communicate with.

parameter options Hash

Options to pass to the client instance.

Implementation

def self.client(peer, settings: CLIENT_SETTINGS)
	stream = ::IO::Stream(peer)
	client = Client.new(stream)
	
	client.send_connection_preface(settings)
	client.start_connection
	
	return client
end

def self.server(peer, settings: SERVER_SETTINGS)

Create a server for an inbound connection.

Signature

parameter peer IO

The peer to communicate with.

parameter options Hash

Options to pass to the server instance.

Implementation

def self.server(peer, settings: SERVER_SETTINGS)
	stream = ::IO::Stream(peer)
	server = Server.new(stream)
	
	server.read_connection_preface(settings)
	server.start_connection
	
	return server
end

def self.names

Signature

returns Array

The names of the supported protocol.

Implementation

def self.names
	["h2"]
end