* http3: add HTTP Trailer support for clients
This change only adds support to read HTTP trailers sent to clients.
* chore: add protection against some out-of-spec behavior + tests
* chore: re-add test accidentally overwtitten
* chore: empty commit to re-trigger ci
* fix: address some review notes (wip)
* fix: simplify code in stream.Read by using a callback from requestStream.ReadResponse
* restructure where trailers are read and parsed
* WIP simplify trailer parsing design
* chore: refactor to use simpler trailer parsing strategy
* make gofumpt happy
* Update http3/headers.go
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* remove stray TODO
---------
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* try to sniff content-type as long as the data is not written to the client
* only write when body is allowed
* fix tests
* fix tests
* fix header count
* fix lint
* merge from upstream
* merge updates from master
* Update http3/response_writer.go
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
---------
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* automatically add date header if not already set
* improve comment for Date header
---------
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
* feat: compatibility with "net/http".ResponseController
* better deadline tests
* don't run deadline tests on Go 1.19
* skip deadline tests on Go 1.19
* add sniff
* add test for sniff
* fix typo in comment
* move bodyAllowedForStatus() to top of the function to aviod calling it twice
* add comments
* format with gofumpt
* fix typo and simplify the code
Currently, it's not possible to send informational responses such as 103 Early Hints or 102 Processing.
This patch allows calling WriteHeader() multiple times in order to send informational responses before the final one.
It follows the patch for HTTP/1 (golang/go#42597) and HTTP/2 (golang/net#96).
In conformance with RFC 8297, if the status code is 103 the current content of the header map is also sent. Its content is not removed after the call to WriteHeader() because the headers must also be included in the final response.
The Chrome and Fastly teams are starting a large-scale experiment to measure the real-life impact of the 103 status code.
Using Early Hints is proposed as a (partial) alternative to Server Push, which are going to be removed from Chrome: https://groups.google.com/a/chromium.org/g/blink-dev/c/K3rYLvmQUBY/m/21anpFhxAQAJ
Being able to send this status code from servers implemented using Go would help to see if implementing it in browsers is worth it.