aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-09-17 00:58:02 +0200
committerLoïc Hoguin <[email protected]>2012-09-17 13:57:29 +0200
commit58edd4c35a0490701a87d94676a63c87e8dec8a0 (patch)
tree1e9ce74ffe5c4201cd5a61bfd456ad0412de5257
parentcf0e905c52dbd6ada6c260b5e95a78f3cc59d558 (diff)
downloadcowboy-58edd4c35a0490701a87d94676a63c87e8dec8a0.tar.gz
cowboy-58edd4c35a0490701a87d94676a63c87e8dec8a0.tar.bz2
cowboy-58edd4c35a0490701a87d94676a63c87e8dec8a0.zip
Add the private get_connection/1 function used by cowboy_protocol
This removes cowboy_protocol's dependency on http.hrl!
-rw-r--r--src/cowboy_protocol.erl5
-rw-r--r--src/cowboy_req.erl6
2 files changed, 8 insertions, 3 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl
index ed51b85..d2f97a7 100644
--- a/src/cowboy_protocol.erl
+++ b/src/cowboy_protocol.erl
@@ -42,7 +42,6 @@
-export([parse_request/1]).
-export([handler_loop/3]).
--include("http.hrl").
-include_lib("eunit/include/eunit.hrl").
-record(state, {
@@ -390,7 +389,7 @@ terminate_request(HandlerState, Req, State) ->
next_request(Req, State, HandlerRes).
-spec next_request(cowboy_req:req(), #state{}, any()) -> ok.
-next_request(Req=#http_req{connection=Conn}, State=#state{
+next_request(Req, State=#state{
req_keepalive=Keepalive}, HandlerRes) ->
cowboy_req:ensure_response(Req, 204),
{BodyRes, Buffer} = case cowboy_req:skip_body(Req) of
@@ -399,7 +398,7 @@ next_request(Req=#http_req{connection=Conn}, State=#state{
end,
%% Flush the resp_sent message before moving on.
receive {cowboy_req, resp_sent} -> ok after 0 -> ok end,
- case {HandlerRes, BodyRes, Conn} of
+ case {HandlerRes, BodyRes, cowboy_req:get_connection(Req)} of
{ok, ok, keepalive} ->
?MODULE:parse_request(State#state{
buffer=Buffer, host_tokens=undefined, path_tokens=undefined,
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index e067ea5..98fc895 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -110,6 +110,7 @@
-export([set_bindings/4]).
-export([get_resp_state/1]).
-export([get_buffer/1]).
+-export([get_connection/1]).
%% Misc API.
-export([compact/1]).
@@ -961,6 +962,11 @@ get_resp_state(#http_req{resp_state=RespState}) ->
get_buffer(#http_req{buffer=Buffer}) ->
Buffer.
+%% @private
+-spec get_connection(req()) -> keepalive | close.
+get_connection(#http_req{connection=Connection}) ->
+ Connection.
+
%% Misc API.
%% @doc Compact the request data by removing all non-system information.