Skip to content

Commit

Permalink
netty: Add system property to disable Connection header check
Browse files Browse the repository at this point in the history
A user has a proxy that is sending "Connection: close", which is against
the HTTP/2 spec, but will take time to fix.

Fixes #8674
  • Loading branch information
ejona86 committed Nov 9, 2021
1 parent e056859 commit f1e4898
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion netty/src/main/java/io/grpc/netty/NettyServerHandler.java
Expand Up @@ -109,6 +109,9 @@ class NettyServerHandler extends AbstractNettyHandler {
@VisibleForTesting
static final long GRACEFUL_SHUTDOWN_PING = 0x97ACEF001L;
private static final long GRACEFUL_SHUTDOWN_PING_TIMEOUT_NANOS = TimeUnit.SECONDS.toNanos(10);
/** Temporary workaround for #8674. Fine to delete after v1.45 release, and maybe earlier. */
private static final boolean DISABLE_CONNECTION_HEADER_CHECK = Boolean.parseBoolean(
System.getProperty("io.grpc.netty.disableConnectionHeaderCheck", "false"));

private final Http2Connection.PropertyKey streamKey;
private final ServerTransportListener transportListener;
Expand Down Expand Up @@ -380,7 +383,7 @@ private void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers
try {
// Connection-specific header fields makes a request malformed. Ideally this would be handled
// by Netty. RFC 7540 section 8.1.2.2
if (headers.contains(CONNECTION)) {
if (!DISABLE_CONNECTION_HEADER_CHECK && headers.contains(CONNECTION)) {
resetStream(ctx, streamId, Http2Error.PROTOCOL_ERROR.code(), ctx.newPromise());
return;
}
Expand Down

0 comments on commit f1e4898

Please sign in to comment.