Gun and HTTP2: HEADER and DATA frames in different packets
Luke Bakken
luke@REDACTED
Sun Sep 13 16:03:27 CEST 2020
Hi Stefano,
I may be mistaken, but this might be due to how Wireshark is decoding
the data and presenting it to you. I see that the IP and TCP
information for both "packets" is the same. Most importantly, the Seq
and Ack numbers.
If they were distinct TCP packets I would expect to see different
numbers (https://packetlife.net/blog/2010/jun/7/understanding-tcp-sequence-acknowledgment-numbers/).
Also, your code is making a connection to port 8088 but the Wireshark
output shows port 80.
Thanks,
Luke
On Sun, Sep 13, 2020 at 6:07 AM Stefano Bertuola
<stefano.bertuola@REDACTED> wrote:
>
> 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
More information about the erlang-questions
mailing list