question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DefaultHttp2ConnectionEncoder writeHeaders method always send an header frame with a priority

See original GitHub issue

Expected 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:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vietjcommented, Dec 4, 2019

yes I will try soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Netty 4.1.44.Final released - Netty.news
... DefaultHttp2ConnectionEncoder writeHeaders method always send an header frame with a priority (#9852); Prevent any leaks when ...
Read more >
Access-Control-Allow-Headers - HTTP - MDN Web Docs
The preflight request below tells the server that we want to send a CORS GET request with the headers listed in Access-Control-Request-Headers ( ......
Read more >
How to set header and options in axios? - Stack Overflow
There are several ways to do this: For a single request: let config = { headers: { header1: value, } } let data...
Read more >
Using the Authorization Header (AWS Signature Version 4)
Using the HTTP Authorization header is the most common method of providing authentication ... <aws-service> value is s3 when sending request to Amazon...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found