NIOAsyncChannel corrupted HTTP/2 stream: why?

hah. after two hours of debugging, i have discovered it is spooky HPACK action at a distance.

i was sending too many headers.

[
    ":scheme": "https", 
    ":authority": authority.domain, 
    ":status": "\(status)"
]

for some reason :scheme and :authority causes NIO, or curl, or firefox, or all three, to ignore the headers frame. then when NIO sends rstStream to terminate the stream, curl/firefox gets confused and thinks the stream was reset for no reason.

moral of the story: it’s always HPACKHeaders’ fault!

in all seriousness though, this type could really benefit from a builder API. nobody should be encoding pseudo-headers manually! it’s just asking for trouble…

//  one day...
let headers:HPACKHeaders = .server(status: 200)
{
    $0["content-type"] = "\(contentType)"
    $0["content-length"] = "\(length)"
    $0["etag"] = "\"\(hash)\""
}
1 Like