Gun and HTTP2: HEADER and DATA frames in different packets

Stefano Bertuola stefano.bertuola@REDACTED
Sun Sep 13 11:13:13 CEST 2020


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200913/ad19cdad/attachment.htm>


More information about the erlang-questions mailing list