An HTTP/2 server may send responses to a client without waiting for the request.

This is typically used in Web page scenarios: If a server receives a request to /index.html, the server knows that the client will most probably request all included image, CSS, and JavaScript files. Instead of waiting for these requests, the server may proactively create push requests for these resources, and send responses immediately.

Push Echo Servlet Demo

As a demo, I created a push echo Servlet, which can be downloaded and built as follows:

git clone
cd http2-examples/jetty-http2-echo-server
mvn package

In order to run it, you need to find out the correct ALPN version for your JDK (see table 14.1), and download the ALPN boot JAR from Maven Central. Given the correct <path-to-alpn-boot.jar>, run the demo as follows:

java -Xbootclasspath/p:<path-to-alpn-boot.jar> \
    -jar target/jetty-http2-echo-server.jar

The demo is an echo Servlet: You can POST data to /data, and then GET that data from /data.

However, the GET request is implemented as a Server Push. The GET request does not perform actual network traffic, because the response is already available on the client.

h2c push-list

Using the h2c command line client, the demo can be run as follows:

In one terminal, run h2c start --dump.

In another terminal, run

h2c connect localhost:8443
h2c post --data 'hello world' /data
h2c get /data

The GET request will return the message I received the following data: hello world.

In the other h2c terminal, the dumped traffic shows that the GET request is never sent, because it is anticipated by the server as a PUSH_PROMISE.

Push Demo Traffic

Using h2c push-list, you can view which paths are currently available as pushed responses on the client. Once a path is fetched with h2c get, the pused path is will be removed from the list.

h2c post --data 'hello world' /data
h2c push-list

The commands above will show the path /data, meaning that the next GET request to /data will be responded locally with the available push response.