class

HT2::HeaderValidator

Inherits Reference < Object

Validates HTTP/2 headers according to RFC 7540

Constants

ALL_PSEUDO_HEADERS = REQUEST_PSEUDO_HEADERS + RESPONSE_PSEUDO_HEADERS

All valid pseudo-headers

CONNECTION_SPECIFIC_HEADERS = {"connection", "keep-alive", "proxy-connection", "transfer-encoding", "upgrade", "host"}

Connection-specific headers that must be stripped

REQUEST_PSEUDO_HEADERS = {":method", ":scheme", ":authority", ":path"}

Valid pseudo-headers for requests

RESPONSE_PSEUDO_HEADERS = {":status"}

Valid pseudo-headers for responses

TE_HEADER = "te"

TE header is allowed only with "trailers" value

TRAILERS_VALUE = "trailers"

Constructors

new(is_request : Bool = true, is_trailers : Bool = false)
Source

Class methods

get_content_length(headers : Array(Tuple(String, String))) : UInt64 | Nil

Returns the content-length value if present

Source
has_trailers?(headers : Array(Tuple(String, String))) : Bool

Checks if headers contain trailers

Source

Instance methods

validate(headers : Array(Tuple(String, String))) : Array(Tuple(String, String))

Validates a set of headers and returns validated headers

Source
validate_content_length(value : String) : Nil

Validates content-length header value

Source