I'm trying to test HTTP/2 push promise with Netty, but doesn't seem to work. Use case is as simple as:
- Request home/index page
- Index page depends on a
index.js
file so I want to send aPUSH_PROMISE
forindex.js
- Write and flush content for
index
page.
Here is what I did:
int nextStreamId = encoder.connection().local().incrementAndGetNextStreamId();
String authority = request.headers().get("host");
Http2Headers pushHeaders = new DefaultHttp2Headers()
.method("GET")
.path("/assets/index.js")
.authority(authority)
.scheme("https");
encoder.writePushPromise(ctx, Integer.parseInt(streamId), nextStreamId, pushHeaders, 0, ctx.newPromise());
It successfully send a PUSH_PROMISE
to the browser but then the /assets/index.js
file isn't loaded at all (browser waits indefinitely for a response)
This only happens when I send the PUSH_PROMISE
, if I remove those line everything works fine and both files (HTML+js) are served properly via H2.
A full demo is available here (it uses a self-signed certificate so you must accept the unsafe warning)
The source code for PUSH_PROMISE
is here.
Am I doing something wrong?
Thanks.