Gun and HTTP2: HEADER and DATA frames in different packets

Stefano Bertuola <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAHeTMT6cVbQ8t42Qj0+aw4xfMTspsMT5CGvOJrPA6eNFdhX3sQ@mail.gmail.com>
Hi all.

When sending an HTTP2 request using Gun:

  {ok, ConnPid} = gun:open({127,0,0,1}, 8088, #{protocols => [http2]}).
  gun:post(ConnPid, "/test", [ {<<"content-type">>, <<"application/json">>}
], <<"{\"test\": \"test\" }">>).

the HEADER and DATA frames are sent in different HTTPs packets:

  Internet Protocol Version 4, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1
(127.0.0.1)
  Transmission Control Protocol, Src Port: 1299, Dst Port: 80, Seq: 266,
Ack: 229, Len: 46
  HyperText Transfer Protocol 2
      Stream: HEADERS, Stream ID: 1, Length 37, POST /test
          Length: 37
          Type: HEADERS (1)
          Flags: 0x04
          0... .... .... .... .... .... .... .... = Reserved: 0x0
          .000 0000 0000 0000 0000 0000 0000 0001 = Stream Identifier: 1
          [Pad Length: 0]
          Header Block Fragment:
8644846125427f83418a089d5c0b8170dc780f3d5f8b1d75…
          [Header Length: 148]
          [Header Count: 6]
          Header: :scheme: http
          Header: :path: /test
          Header: :method: POST
          Header: :authority: 127.0.0.1:8088
          Header: content-type: application/json
         Header: content-length: 17

  Internet Protocol Version 4, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1
(127.0.0.1)
  Transmission Control Protocol, Src Port: 1299, Dst Port: 80, Seq: 266,
Ack: 229, Len: 46
  HyperText Transfer Protocol 2
      Stream: DATA, Stream ID: 1, Length 17
          Length: 17
          Type: DATA (0)
          Flags: 0x01
          0... .... .... .... .... .... .... .... = Reserved: 0x0
          .000 0000 0000 0000 0000 0000 0000 0001 = Stream Identifier: 1
          [Pad Length: 0]
          Data: 7b2274657374223a20227465737422207d
      JavaScript Object Notation: application/json
          JSON compact form: {...}
              test: "test"
          Object
              Member Key: test
                  String value: test
                  Key: test

Why Gun is acting in this way? How to get both HEADER and DATA in the same
HTTP2 request?

I did the test with both 1.3.3 and 2.0.0-pre.2 releases.

Br. Stefano
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.