HPACK (RFC 7541) implementation in Swift.
let headers: [Header] = [
(":method", "GET"),
(":path", "/"),
("Accept", "application/json"),
]
let encoder = hpack.Encoder()
let bytes = try encoder.encode(headers)
print(bytes)
You may also pass a secure parameter when encoding a header, which allows you to prevent the header from being added to the header table.
let bytes = try encoder.encode([
("secret", "secret-key", true),
])
print(bytes)
let bytes: [UInt8] = [130]
let decoder = hpack.Decoder()
let headers = try decoder.decode(bytes)
for header in headers {
print(header.name)
print(header.value)
}