From 8b95bce45865e6b9233abd4d57b61444e0dcf242 Mon Sep 17 00:00:00 2001 From: Akshay Shah Date: Mon, 13 Feb 2023 11:32:25 -0800 Subject: [PATCH] web: make HTTP field names case-insensitive I'm opening this PR to (hopefully!) stimulate a discussion. In brief, I'd like to amend the gRPC-Web protocol docs to encourage implementations to follow HTTP semantics and compare HTTP field names case-insensitively. The gRPC-Web specification is a nicely-designed way for proxies to expose standard HTTP/2 gRPC servers to clients using less tightly-controlled HTTP stacks, such as web browsers. To serve that goal, it seems valuable to have the gRPC-Web specification follow [RFC 9110 (HTTP Semantics)](https://www.rfc-editor.org/rfc/rfc9110.html#name-field-names). Like previous RFCs, 9110 specifies that "field names are case-insensitive." However, the current gRPC-Web specification requires that servers and proxies "use lower-case header/trailer names" on the wire. In principle, mandating casing on the wire is normal for HTTP/2 and fine (if unusual) for HTTP/1.1; however, it encourages implementations to violate HTTP semantics and require lower-case names when _reading_ headers and trailers. I'd like to loosen the gRPC-Web specification to permit any casing on the wire for HTTP/1.1. I'd also like to emphasize that gRPC-Web implementations ought to follow standard HTTP semantics when _reading_ fields and compare names case-insensitively. This amendment does not affect the correctness of Envoy (which may continue to use lower-case field names) or the `grpc-web` Javascript project (which already treats field names case-insensitively, thanks to the Web Platform's `Headers` interface). However, it does clarify that `grpc-dart` is _incorrect_ in relying on lower-case field names. Relates to https://github.com/improbable-eng/grpc-web/issues/228, https://github.com/bufbuild/connect-go/issues/453/, and https://github.com/grpc/grpc-dart/issues/594. --- doc/PROTOCOL-WEB.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/PROTOCOL-WEB.md b/doc/PROTOCOL-WEB.md index c3f9169b331b1..080b0b6c1c8aa 100644 --- a/doc/PROTOCOL-WEB.md +++ b/doc/PROTOCOL-WEB.md @@ -48,7 +48,12 @@ Content-Type HTTP wire protocols 1. support any HTTP/*, with no dependency on HTTP/2 specific framing -2. use lower-case header/trailer names +2. send lower-case header/trailer names over HTTP/2 (following [RFC + 9113](https://www.rfc-editor.org/rfc/rfc9113#section-8.2-2)), send + header/trailer names using any case over HTTP/1.1 (following [RFC + 9110](https://www.rfc-editor.org/rfc/rfc9112.html#section-5-1)), and compare + header/trailer names case-insensitively (following [RFC + 9110](https://www.rfc-editor.org/rfc/rfc9110.html#section-5.1-3)) 3. use EOF (end of body) to close the stream ---