oak
oak copied to clipboard
Add support for HTTP Trailer Headers
This long-standing feature of HTTP responses is getting new life, and it would be great to support it in Oak. It's useful for streamed responses when one doesn't know the value of a specific header at the start.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer
Ideally the request handler would register a callback so Oak could query their Trailer value after the body stream has closed. Something like this:
response.registerTrailer("etag", async () => { return calculatedEtag() } )
The tricky part is the Trailer header has to contain the list of expected trailer values, so the handler would register before sending the body stream. Oak would set Trailer header, pipe the stream, and then fulfill the callbacks to get the trailer values.