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.
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.
h2c start --dump prints all HTTP/2 traffic to the console.
The screenshot above shows the dump of the Hello, World! example from the first blog post:
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
->HEADERS frame, the response is composed of an incoming
<-HEADERS frame and an incoming
+ 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
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.
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.