[#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.
This commit is contained in:
Norman Maurer 2016-03-16 08:47:40 +01:00
parent 8d499a2419
commit ed9d6c79bc
2 changed files with 4 additions and 10 deletions

View File

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

View File

@ -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);
}