module

HT2::H2C

Constants

CONNECTION_HEADER = "Connection"
H2C_PROTOCOL = "h2c"

Values for upgrade headers

HTTP1_METHODS = ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "PATCH", "CONNECT", "TRACE"]

Common HTTP/1.1 method names for detection

HTTP2_SETTINGS_HEADER = "HTTP2-Settings"
SWITCHING_PROTOCOLS_RESPONSE = "HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nUpgrade: h2c\r\n\r\n"

HTTP/1.1 response for successful upgrade

UPGRADE_CONNECTION = "Upgrade"
UPGRADE_HEADER = "Upgrade"

HTTP/1.1 headers required for h2c upgrade

Class methods

connection_preface?(data : Bytes) : Bool

Checks if bytes represent HTTP/2 connection preface

Source
decode_settings(encoded : String) : SettingsFrame::Settings

Decodes HTTP2-Settings header value (base64url encoded SETTINGS frame)

Source
detect_connection_type(data : Bytes) : ConnectionType
Source
h2_prior_knowledge?(data : Bytes) : Bool

Detects if the initial bytes are HTTP/2 prior knowledge connection

Source
http1_request?(data : Bytes) : Bool

Detects if the initial bytes are HTTP/1.1

Source
read_http1_headers(socket : IO, timeout : Time::Span) : Hash(String, String) | Nil

Reads HTTP/1.1 request headers from socket

Source
upgrade_request?(headers : Hash(String, String)) : Bool

Checks if an HTTP/1.1 request is an h2c upgrade request

Source

Nested types