Allow to write Http2UnkownFrame when using Http2FrameCodec / Http2MultiplexCodec (#7867)
Motivation: We should allow to write Http2UnkownFrame to allow custom extensions. Modifications: Allow to write Http2UnkownFrame Add unit test Result: Fixes https://github.com/netty/netty/issues/7860.
This commit is contained in:
parent
3f244a94fe
commit
da2e91b33a
@ -296,6 +296,10 @@ public class Http2FrameCodec extends Http2ConnectionHandler {
|
||||
encoder().writeSettings(ctx, ((Http2SettingsFrame) msg).settings(), promise);
|
||||
} else if (msg instanceof Http2GoAwayFrame) {
|
||||
writeGoAwayFrame(ctx, (Http2GoAwayFrame) msg, promise);
|
||||
} else if (msg instanceof Http2UnknownFrame) {
|
||||
Http2UnknownFrame unknownFrame = (Http2UnknownFrame) msg;
|
||||
encoder().writeFrame(ctx, unknownFrame.frameType(), unknownFrame.stream().id(),
|
||||
unknownFrame.flags(), unknownFrame.content(), promise);
|
||||
} else if (!(msg instanceof Http2Frame)) {
|
||||
ctx.write(msg, promise);
|
||||
} else {
|
||||
|
@ -534,6 +534,20 @@ public class Http2FrameCodecTest {
|
||||
assertEquals(Integer.MAX_VALUE, localFlow.windowSize(connection.connectionStream()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeUnknownFrame() {
|
||||
final Http2FrameStream stream = frameCodec.newStream();
|
||||
|
||||
ByteBuf buffer = Unpooled.buffer().writeByte(1);
|
||||
DefaultHttp2UnknownFrame unknownFrame = new DefaultHttp2UnknownFrame(
|
||||
(byte) 20, new Http2Flags().ack(true), buffer);
|
||||
unknownFrame.stream(stream);
|
||||
channel.write(unknownFrame);
|
||||
|
||||
verify(frameWriter).writeFrame(eq(http2HandlerCtx), eq(unknownFrame.frameType()),
|
||||
eq(unknownFrame.stream().id()), eq(unknownFrame.flags()), eq(buffer), any(ChannelPromise.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendSettingsFrame() {
|
||||
Http2Settings settings = new Http2Settings();
|
||||
|
Loading…
x
Reference in New Issue
Block a user