mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Remove cowboy_req:append_buffer/2
This commit is contained in:
parent
0e68b2a3f5
commit
8905cc44f2
2 changed files with 2 additions and 23 deletions
|
@ -124,7 +124,7 @@ timeout(State=#state{timeout=Timeout,
|
|||
loop(Req, State=#state{timeout_ref=TRef}, Handler, HandlerState) ->
|
||||
receive
|
||||
{timeout, TRef, ?MODULE} ->
|
||||
after_loop(Req, State, Handler, HandlerState, timeout);
|
||||
terminate(Req, State, Handler, HandlerState, timeout);
|
||||
{timeout, OlderTRef, ?MODULE} when is_reference(OlderTRef) ->
|
||||
loop(Req, State, Handler, HandlerState);
|
||||
Message ->
|
||||
|
@ -139,7 +139,7 @@ call(Req, State=#state{resp_sent=RespSent},
|
|||
{ok, Req2, HandlerState2, hibernate} ->
|
||||
after_call(Req2, State#state{hibernate=true}, Handler, HandlerState2);
|
||||
{stop, Req2, HandlerState2} ->
|
||||
after_loop(Req2, State, Handler, HandlerState2, stop)
|
||||
terminate(Req2, State, Handler, HandlerState2, stop)
|
||||
catch Class:Reason ->
|
||||
Stacktrace = erlang:get_stacktrace(),
|
||||
if RespSent -> ok; true ->
|
||||
|
@ -156,22 +156,6 @@ call(Req, State=#state{resp_sent=RespSent},
|
|||
]})
|
||||
end.
|
||||
|
||||
%% It is sometimes important to make a socket passive as it was initially
|
||||
%% and as it is expected to be by cowboy_protocol, right after we're done
|
||||
%% with loop handling. The browser may freely pipeline a bunch of requests
|
||||
%% if previous one was, say, a JSONP long-polling request.
|
||||
after_loop(Req, State, Handler, HandlerState, Reason) ->
|
||||
[Socket, Transport] = cowboy_req:get([socket, transport], Req),
|
||||
Transport:setopts(Socket, [{active, false}]),
|
||||
{OK, _Closed, _Error} = Transport:messages(),
|
||||
Req2 = receive
|
||||
{OK, Socket, Data} ->
|
||||
cowboy_req:append_buffer(Data, Req)
|
||||
after 0 ->
|
||||
Req
|
||||
end,
|
||||
terminate(Req2, State, Handler, HandlerState, Reason).
|
||||
|
||||
terminate(Req, #state{env=Env, timeout_ref=TRef},
|
||||
Handler, HandlerState, Reason) ->
|
||||
_ = case TRef of
|
||||
|
|
|
@ -81,7 +81,6 @@
|
|||
-export([ensure_response/2]).
|
||||
|
||||
%% Private setter/getter API.
|
||||
-export([append_buffer/2]).
|
||||
-export([get/2]).
|
||||
-export([set/2]).
|
||||
|
||||
|
@ -997,10 +996,6 @@ ensure_response(#http_req{}, _) ->
|
|||
|
||||
%% Private setter/getter API.
|
||||
|
||||
-spec append_buffer(binary(), Req) -> Req when Req::req().
|
||||
append_buffer(Suffix, Req=#http_req{buffer=Buffer}) ->
|
||||
Req#http_req{buffer= << Buffer/binary, Suffix/binary >>}.
|
||||
|
||||
-spec get(atom(), req()) -> any(); ([atom()], req()) -> any().
|
||||
get(List, Req) when is_list(List) ->
|
||||
[g(Atom, Req) || Atom <- List];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue