aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-06-22 11:22:34 +0200
committerLoïc Hoguin <[email protected]>2016-06-22 11:22:34 +0200
commit8905cc44f20a42f60a612ba5397ea32a2cea984f (patch)
treed9a9547483b24dcb05161814beeca7ffcfb4dd9a
parent0e68b2a3f579005302ff88a5c0d0a75fd486b9b6 (diff)
downloadcowboy-8905cc44f20a42f60a612ba5397ea32a2cea984f.tar.gz
cowboy-8905cc44f20a42f60a612ba5397ea32a2cea984f.tar.bz2
cowboy-8905cc44f20a42f60a612ba5397ea32a2cea984f.zip
Remove cowboy_req:append_buffer/2
-rw-r--r--src/cowboy_loop.erl20
-rw-r--r--src/cowboy_req.erl5
2 files changed, 2 insertions, 23 deletions
diff --git a/src/cowboy_loop.erl b/src/cowboy_loop.erl
index dc07e13..1418950 100644
--- a/src/cowboy_loop.erl
+++ b/src/cowboy_loop.erl
@@ -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
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index 7528d16..626f4a5 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -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];