Propagate h2c upgrade success event to the next handler before removing source codec
Motivation: When upgrading h2c, I found that sometimes both of http2 settings frame and http response message was arrived before receiving upgrade success event. It was because ByteToMessageDecoder propagated its internally buffered message to the next handler when removing itself from pipeline.(refer to ByteToMessageDecoder#handlerRemoved) I think it's better to propagate upgrade success event when handling 101 switching protocol response. Modifications: Upgrade success event will be propagated before removing source codec. Result: It guarantees that upgrade success event will be arrived first at the next handler.
This commit is contained in:
parent
e053b96b5c
commit
24254b159f
@ -231,11 +231,14 @@ public class HttpClientUpgradeHandler extends HttpObjectAggregator implements Ch
|
||||
// Upgrade to the new protocol.
|
||||
sourceCodec.prepareUpgradeFrom(ctx);
|
||||
upgradeCodec.upgradeTo(ctx, response);
|
||||
sourceCodec.upgradeFrom(ctx);
|
||||
|
||||
// Notify that the upgrade to the new protocol completed successfully.
|
||||
ctx.fireUserEventTriggered(UpgradeEvent.UPGRADE_SUCCESSFUL);
|
||||
|
||||
// We guarantee UPGRADE_SUCCESSFUL event will be arrived at the next handler
|
||||
// before http2 setting frame and http response.
|
||||
sourceCodec.upgradeFrom(ctx);
|
||||
|
||||
// We switched protocols, so we're done with the upgrade response.
|
||||
// Release it and clear it from the output.
|
||||
response.release();
|
||||
|
Loading…
Reference in New Issue
Block a user