Gun and HTTP2: HEADER and DATA frames in different packets

Loïc Hoguin essen@REDACTED
Sun Sep 13 17:12:35 CEST 2020

On 13/09/2020 11:13, Stefano Bertuola 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:
> [...]
> Why Gun is acting in this way? How to get both HEADER and DATA in the 
> same HTTP2 request?

They're distinct send calls because HTTP/2 has flow control for the DATA 
frames and the body for the request may be queued partially or fully.

 > 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.

What's the exact error though? Cowboy is tested with Gun so if there's a 
client that should work it's this one. :-)

Loïc Hoguin

More information about the erlang-questions mailing list