Skip to content

Commit

Permalink
Merge #2488 into 2.0.0-M2
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Sep 15, 2022
2 parents 9015d2b + 2662ecc commit a51c5b7
Showing 1 changed file with 22 additions and 18 deletions.
Expand Up @@ -862,27 +862,31 @@ static final class H2OrHttp11Codec extends ChannelHandlerAdapter {

@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 a51c5b7

Please sign in to comment.