Description
The method declareTrailer
in net/http/server.go
does not handle Trailer headers according to RFC 7230.
While the the obsoleted RFC 2616 section 14.40 states:
Message header fields listed in the Trailer header field MUST NOT
include the following header fields:
- Transfer-Encoding
- Content-Length
- Trailer
declareTrailer
only ignores the headers mentioned above, but RFC 7230 section 4.1.2 states:
A sender MUST NOT generate a trailer that contains a field necessary
for message framing (e.g., Transfer-Encoding and Content-Length),
routing (e.g., Host), request modifiers (e.g., controls and
conditionals in Section 5 of [RFC7231]), authentication (e.g., see
[RFC7235] and [RFC6265]), response control data (e.g., see Section
7.1 of [RFC7231]), or determining how to process the payload (e.g.,
Content-Encoding, Content-Type, Content-Range, and Trailer).
x/net/http2
already implements this behavior in ValidTrailerHeader
. Maybe this method can be moved to net/http
.