]> git.kaiwu.me - haproxy.git/commit
DEV: h2: add h2dec, a raw HTTP/2 frame decoder
authorWilly Tarreau <w@1wt.eu>
Mon, 16 Nov 2026 14:53:27 +0000 (14:53 +0000)
committerWilly Tarreau <w@1wt.eu>
Tue, 17 Nov 2026 10:08:46 +0000 (11:08 +0100)
commit4773afcce7abf9b317d833b9585c4952fca68816
tree704cbd2ae36e31a12ca19311bb528b38a4e29a92
parente6c0c0e639fc9ce7b7044c93266b97b435729ced
DEV: h2: add h2dec, a raw HTTP/2 frame decoder

mkhdr.sh produces raw HTTP/2 frames but nothing permits to decode them
back, nor to inspect a captured stream. h2dec reads a raw HTTP/2 byte
stream on stdin and prints one line per frame with the 9 header bytes
in hex followed by the decoded type, stream ID, length, flags and pad
length when present. An optional connection preface is detected.

For HEADERS, PUSH_PROMISE and CONTINUATION frames, the header block is
reassembled (padding, priority and promised stream ID are stripped),
and once END_HEADERS is seen, it is decoded with haproxy's own HPACK
decoder (as dev/hpack/decode does) and each field is printed indented
below the frame, in HTTP/1 form ("name: value"), pseudo-headers
appearing as ":name: value". Non-printable characters are escaped. A
single dynamic table is maintained for the whole input, whose size may
be changed with "-s".

Example:

  $ dev/h2/mkhdr.sh -t h -i 1 -f es,eh -e :method GET -e :path / | dev/h2/h2dec
  00 00 16 01 05 00 00 00 01  type=HEADERS sid=1 len=22 flags=0x05(ES,EH)
      :method: GET
      :path: /

It's built with "make dev/h2/h2dec".
.gitignore
Makefile
dev/h2/h2dec.c [new file with mode: 0644]