HTTP/2 is a binary protocol. Tool support is needed to analyze HTTP/2 traffic. This post introduces h2c start --dump, an option for h2c that intercepts HTTP/2 traffic and prints it to the console.

TL;DR

This post explains the output of the h2c start --dump command.

Hello, World! Again.

As shown in the Hello, World! post, the h2c tool relies on a h2c process running in the background. This process is started with the h2c start command and, among other things, maintains the connection to the HTTP server.

The option h2c start --dump prints all HTTP/2 traffic to the console.

h2c start --dump

The screenshot above shows the dump of the Hello, World! example from the first blog post:

h2c connect 192.168.59.103:8443
h2c get /hello-world/api/hello-world

Analyzing the Output

-> / <-

The arrows show if the frame is incoming <- or outgoing ->.

SETTINGS(0) / HEADERS(1) / DATA(1)

The headlines show the frame type, and the stream ID. Each stream corresponds to a request/response pair in HTTP/1. The example above shows two streams:

  • An initial stream with ID 0 for negotiating the settings when the connection is established. This has no equivalent in HTTP/1.
  • A stream with ID 1 for the GET request and response. The request is a single outgoing -> HEADERS frame, the response is composed of an incoming <- HEADERS frame and an incoming <- DATA frame.

+ ACK / + END_STREAM / + END_HEADERS

Some frame types support flags that can be either set + or clear -. The END_HEADERS flag for the HEADERS frame defines if all headers are included in the frame, or if the headers are continued with a CONTINUATION frame. As the headers in the example fit into single HEADERS frames, the END_HEADERS flag is always set +.

The END_STREAM flag indicates if there will be more frames for the stream. The request in the example consists only of a HEADERS frame, so END_STREAM is set + for the outgoing -> HEADERS frame. The response consists of a HEADERS frame and a DATA frame, so the END_STREAM flag is clear - for the incoming <- HEADERS frame, and it is set + for the incoming <- DATA frame.

name: value

The actual content of the frame is shown as name/value pairs. For SETTINGS frames, these are the settings. For HEADERS frames, these are the headers.

Current Status

h2c is currently in a very early state. As of release v0.0.5, the only frames implemented are the frames shown above, and the only interaction implemented is the GET request.

The focus in the next few days will be on implementing POST and PUT requests. The next feature after that should be support for server push.