0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Fix lingering_data_frame when data length is 0

This commit is contained in:
Tony Han 2019-07-26 10:07:00 +08:00
parent 5b4e78fac4
commit ae02f21a5c
2 changed files with 5 additions and 2 deletions

View file

@ -309,10 +309,12 @@ data_frame(State=#state{opts=Opts, streams=Streams}, StreamID, IsFin, Data) ->
end.
lingering_data_frame(State=#state{socket=Socket, transport=Transport,
http2_machine=HTTP2Machine0}, DataLen) ->
http2_machine=HTTP2Machine0}, DataLen) when DataLen > 0 ->
Transport:send(Socket, cow_http2:window_update(DataLen)),
HTTP2Machine1 = cow_http2_machine:update_window(DataLen, HTTP2Machine0),
State#state{http2_machine=HTTP2Machine1}.
State#state{http2_machine=HTTP2Machine1};
lingering_data_frame(State, _) ->
State.
headers_frame(State, StreamID, IsFin, Headers,
PseudoHeaders=#{method := <<"CONNECT">>}, _)

View file

@ -3153,6 +3153,7 @@ lingering_data_counts_toward_connection_window(Config0) ->
% Make sure server send RST_STREAM.
timer:sleep(100),
ok = gen_tcp:send(Socket, [
cow_http2:data(1, nofin, <<0:0/unit:8>>),
cow_http2:data(1, fin, <<0:1000/unit:8>>)
]),
{ok, << SkipLen:24, 1:8, _:8, 1:32 >>} = gen_tcp:recv(Socket, 9, 1000),