From ed9d6c79bca67c181b1325a5059af47d40952a01 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 16 Mar 2016 08:47:40 +0100 Subject: [PATCH] [#4972] Remove misleading argument from HttpServerUpgradeHandler.UpgradeCodec.upgradeTo Motivation: upgradeTo(...) takes the response as paramater, but the respone itself was already written to the Channel. This gives the user the impression the response can be changed or even act on it which may not be safe anymore once it was written and has been released. Modifications: Remove the response param from the method. Result: Less confusion and safer usage. --- .../handler/codec/http/HttpServerUpgradeHandler.java | 11 +++-------- .../handler/codec/http2/Http2ServerUpgradeCodec.java | 3 +-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java index 691d37e767..1c9f8cda85 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java @@ -70,14 +70,9 @@ public class HttpServerUpgradeHandler extends HttpObjectAggregator { * adding all handlers required for the new protocol. * * @param ctx the context for the current handler. - * @param upgradeRequest the request that triggered the upgrade to this protocol. The - * upgraded protocol is responsible for sending the response. - * @param upgradeResponse a 101 Switching Protocols response that is populated with the - * {@link HttpHeaderNames#CONNECTION} and {@link HttpHeaderNames#UPGRADE} headers. - * The protocol is required to send this before sending any other frames back to the client. - * The headers may be augmented as necessary by the protocol before sending. + * @param upgradeRequest the request that triggered the upgrade to this protocol. */ - void upgradeTo(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest, FullHttpResponse upgradeResponse); + void upgradeTo(ChannelHandlerContext ctx, FullHttpRequest upgradeRequest); } /** @@ -320,7 +315,7 @@ public class HttpServerUpgradeHandler extends HttpObjectAggregator { if (future.isSuccess()) { // Perform the upgrade to the new protocol. sourceCodec.upgradeFrom(ctx); - finalUpgradeCodec.upgradeTo(ctx, request, upgradeResponse); + finalUpgradeCodec.upgradeTo(ctx, request); // Notify that the upgrade has occurred. Retain the event to offset // the release() in the finally block. diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ServerUpgradeCodec.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ServerUpgradeCodec.java index fa00076ad7..3382fc2938 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ServerUpgradeCodec.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ServerUpgradeCodec.java @@ -98,8 +98,7 @@ public class Http2ServerUpgradeCodec implements HttpServerUpgradeHandler.Upgrade } @Override - public void upgradeTo(final ChannelHandlerContext ctx, FullHttpRequest upgradeRequest, - FullHttpResponse upgradeResponse) { + public void upgradeTo(final ChannelHandlerContext ctx, FullHttpRequest upgradeRequest) { // Add the HTTP/2 connection handler to the pipeline immediately following the current handler. ctx.pipeline().addAfter(ctx.name(), handlerName, connectionHandler); }