Gun and HTTP2: HEADER and DATA frames in different packets

Stefano Bertuola stefano.bertuola@REDACTED
Sun Sep 13 16:14:32 CEST 2020


Hi Luke.

Thanks for your email.

I can confirm the two frames (HEADER and DATA) are sent in two different
HTTP2 messages by Gun. In fact, when receiving the 1st one containing the
HEADER, Cowboy is complaining the body is missing.

Br. Stefano

On Sun, Sep 13, 2020 at 4:03 PM Luke Bakken <luke@REDACTED> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200913/29525b27/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gun_http2_frag.pcapng
Type: application/octet-stream
Size: 2416 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200913/29525b27/attachment.obj>


More information about the erlang-questions mailing list