Add a new HTTP/2 pseudo header :protocol (#11192)

Motivation:

RFC 8411 defines a new HTTP/2 pseudo header called `:protocol`:

- https://datatracker.ietf.org/doc/rfc8441/

Netty currently raises an exception when validating an `Http2Headers`.

Modifications:

- Added `Http2Headers.PseudoHeaderNames.PROTOCOL` so that `:protocol`
  pseudo header is not rejected.

Result:

- A user can implement WebSockets with HTTP/2.
This commit is contained in:
Trustin Lee 2021-04-26 16:28:35 +09:00 committed by Norman Maurer
parent 10758eef73
commit 6389f18a16
2 changed files with 8 additions and 1 deletions

View File

@ -55,7 +55,13 @@ public interface Http2Headers extends Headers<CharSequence, CharSequence, Http2H
/**
* {@code :status}.
*/
STATUS(":status", false);
STATUS(":status", false),
/**
* {@code :protocol}, as defined in <a href="https://datatracker.ietf.org/doc/rfc8441/">RFC 8441,
* Bootstrapping WebSockets with HTTP/2</a>.
*/
PROTOCOL(":protocol", true);
private static final char PSEUDO_HEADER_PREFIX = ':';
private static final byte PSEUDO_HEADER_PREFIX_BYTE = (byte) PSEUDO_HEADER_PREFIX;

View File

@ -180,6 +180,7 @@ public class DefaultHttp2HeadersTest {
headers.authority(of("netty.io"));
headers.add(of("name3"), of("value4"));
headers.scheme(of("https"));
headers.add(of(":protocol"), of("websocket"));
return headers;
}
}