Skip to content

Commit

Permalink
Merge #2488 into 1.1.0-RC1
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Sep 15, 2022
2 parents 59ea433 + 44f7fba commit 2662ecc
Showing 1 changed file with 22 additions and 18 deletions.
Expand Up @@ -867,27 +867,31 @@ static final class H2OrHttp11Codec extends ChannelInboundHandlerAdapter {

@Override
public void channelActive(ChannelHandlerContext ctx) {
SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
if (sslHandler == null) {
throw new IllegalStateException("Cannot determine negotiated application-level protocol.");
}
String protocol = sslHandler.applicationProtocol() != null ? sslHandler.applicationProtocol() : ApplicationProtocolNames.HTTP_1_1;
if (log.isDebugEnabled()) {
log.debug(format(ctx.channel(), "Negotiated application-level protocol [" + protocol + "]"));
}
if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
configureHttp2Pipeline(ctx.channel().pipeline(), acceptGzip, decoder, http2Settings, observer);
}
else if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
configureHttp11Pipeline(ctx.channel().pipeline(), acceptGzip, decoder, metricsRecorder, uriTagValue);
ChannelHandler handler = ctx.pipeline().get(NettyPipeline.SslHandler);
if (handler instanceof SslHandler) {
SslHandler sslHandler = (SslHandler) handler;

String protocol = sslHandler.applicationProtocol() != null ? sslHandler.applicationProtocol() : ApplicationProtocolNames.HTTP_1_1;
if (log.isDebugEnabled()) {
log.debug(format(ctx.channel(), "Negotiated application-level protocol [" + protocol + "]"));
}
if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
configureHttp2Pipeline(ctx.channel().pipeline(), acceptGzip, decoder, http2Settings, observer);
}
else if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
configureHttp11Pipeline(ctx.channel().pipeline(), acceptGzip, decoder, metricsRecorder, uriTagValue);
}
else {
throw new IllegalStateException("unknown protocol: " + protocol);
}

ctx.fireChannelActive();

ctx.channel().pipeline().remove(this);
}
else {
throw new IllegalStateException("unknown protocol: " + protocol);
throw new IllegalStateException("Cannot determine negotiated application-level protocol.");
}

ctx.fireChannelActive();

ctx.channel().pipeline().remove(this);
}
}

Expand Down

0 comments on commit 2662ecc

Please sign in to comment.