DefaultHttp2ConnectionEncoder writeHeaders method always send an header frame with a priority
See original GitHub issueExpected behavior
The DefaultHttp2ConnectionEncoder
sends an header frame without priority when the writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, ChannelPromise promise)
method is used
Actual behavior
The current implementation delegates to writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream, ChannelPromise promise)
that will send an header frame with the priority flag set and the default priority values.
Steps to reproduce
Use DefaultHttp2ConnectionEncoder#writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream, ChannelPromise promise)
with an Http2FrameWriter
, the frame writer will have the writeHeaders(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream, ChannelPromise promise)
called.
On the wire, this will encode a different headers frame with the priority flag set instead of being unset.
Minimal yet complete reproducer code (or URL to code)
I believe this in DefaultHttp2ConnectionEncoderTest
should do the job
@Test
public void headersWithNoPriority() {
writeAllFlowControlledFrames();
final int streamId = 6;
ChannelPromise promise = newPromise();
encoder.writeHeaders(ctx, streamId, EmptyHttp2Headers.INSTANCE, 0, false, promise);
verify(writer, times(1)).writeHeaders(eq(ctx), eq(streamId), eq(EmptyHttp2Headers.INSTANCE), eq(0), eq(false), eq(promise));
}
This fails with
Argument(s) are different! Wanted:
writer.writeHeaders(
ctx,
6,
EmptyHttp2Headers[],
0,
false,
DefaultChannelPromise@2374d36a(success)
);
-> at io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoderTest.headersWithNoPriority(DefaultHttp2ConnectionEncoderTest.java:403)
Actual invocation has different arguments:
writer.writeHeaders(
ctx,
6,
EmptyHttp2Headers[],
0,
(short) 16,
false,
0,
false,
DefaultChannelPromise@2374d36a(success)
);
-> at io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder.writeHeaders(DefaultHttp2ConnectionEncoder.java:208)
Netty version
All of 4.1 branch
JVM version (e.g. java -version
)
Does not matter
OS version (e.g. uname -a
)
Does not matter
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
@vietj PTAL https://github.com/netty/netty/pull/9852
yes I will try soon.