mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 05:00:24 +00:00
Ensure we can fetch the body in the info/3 function of loop handlers
This commit is contained in:
parent
1eb2bda304
commit
2aabc73045
3 changed files with 33 additions and 1 deletions
|
@ -214,7 +214,18 @@ handler_loop(Req, State=#state{loop_buffer_size=NbBytes,
|
|||
{timeout, OlderTRef, ?MODULE} when is_reference(OlderTRef) ->
|
||||
handler_before_loop(Req, State, Handler, HandlerState);
|
||||
Message ->
|
||||
handler_call(Req, State, Handler, HandlerState, Message)
|
||||
%% We set the socket back to {active, false} mode in case
|
||||
%% the handler is going to call recv. We also flush any
|
||||
%% data received after that and put it into the buffer.
|
||||
%% We do not check the size here, if data keeps coming
|
||||
%% we'll error out on the next packet received.
|
||||
Transport:setopts(Socket, [{active, false}]),
|
||||
Req2 = receive {OK, Socket, Data} ->
|
||||
cowboy_req:append_buffer(Data, Req)
|
||||
after 0 ->
|
||||
Req
|
||||
end,
|
||||
handler_call(Req2, State, Handler, HandlerState, Message)
|
||||
end.
|
||||
|
||||
-spec handler_call(Req, #state{}, module(), any(), any())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue