class

HTTP2::Headers

Inherits Enumerable < Reference < Object

An ordered, duplicate-preserving collection of HTTP fields.

Constructors

new(fields : Enumerable(Header))
Source
new(fields : HTTP::Headers)

HTTP::Headers field names are case-insensitive (RFC 9110 §5.1) but HTTP/2 requires lowercase on the wire (RFC 9113 §8.2.1); downcasing here is lossless and lets stdlib-interop callers pass mixed-case names without tripping outbound validation. Values are untouched.

Source

Instance methods

==(other : Headers) : Bool
Source
[](name : String) : String

Returns the first field value with exactly matching lowercase name.

Source
[]=(name : String, value : String) : String
Source
[]?(name : String) : String | Nil
Source
add(name : String, value : String) : self

Appends a field without replacing existing fields of the same name.

Source
delete(name : String) : Nil
Source
dup

Returns a shallow copy of this object.

This allocates a new object and copies the contents of self into it.

Source
each

Must yield this collection's elements to the block.

Source
empty?

Returns true if self does not contain any element.

([] of Int32).empty? # => true
([1]).empty?         # => false
[nil, false].empty?  # => false
  • #present? returns the inverse.
Source
get_all(name : String) : Array(String)

Returns every value with exactly matching lowercase name, in wire order.

Source
has_key?(name : String) : Bool
Source
hash(hasher)

See Object#hash(hasher)

Source
size

Returns the number of elements in the collection.

[1, 2, 3, 4].size # => 4
Source
to_a

Returns an Array with all the elements in the collection.

(1..5).to_a # => [1, 2, 3, 4, 5]
Source
to_http_headers
Source