aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_rest.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-12-08 18:30:13 +0100
committerLoïc Hoguin <[email protected]>2011-12-08 18:30:13 +0100
commit8d2102fe1174d5fb82d80ca3beba83b9d5bbb238 (patch)
tree0197df52297c60b63f1af303e0a7ea84781f8ac1 /src/cowboy_http_rest.erl
parent7f46e5343625ba32b6e93e6a9a1ba76b4447b7a8 (diff)
downloadcowboy-8d2102fe1174d5fb82d80ca3beba83b9d5bbb238.tar.gz
cowboy-8d2102fe1174d5fb82d80ca3beba83b9d5bbb238.tar.bz2
cowboy-8d2102fe1174d5fb82d80ca3beba83b9d5bbb238.zip
Allow HTTP protocol upgrades to use keepalive
REST needed this to be allowed to chain requests on the same connection.
Diffstat (limited to 'src/cowboy_http_rest.erl')
-rw-r--r--src/cowboy_http_rest.erl8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cowboy_http_rest.erl b/src/cowboy_http_rest.erl
index 9bb66fa..3ef730f 100644
--- a/src/cowboy_http_rest.erl
+++ b/src/cowboy_http_rest.erl
@@ -53,7 +53,7 @@
%% You do not need to call this function manually. To upgrade to the REST
%% protocol, you simply need to return <em>{upgrade, protocol, {@module}}</em>
%% in your <em>cowboy_http_handler:init/3</em> handler function.
--spec upgrade(pid(), module(), any(), #http_req{}) -> ok.
+-spec upgrade(pid(), module(), any(), #http_req{}) -> {ok, #http_req{}}.
upgrade(_ListenerPid, Handler, Opts, Req) ->
try
case erlang:function_exported(Handler, rest_init, 2) of
@@ -753,6 +753,8 @@ respond(Req, State, StatusCode) ->
terminate(Req, #state{handler=Handler, handler_state=HandlerState}) ->
case erlang:function_exported(Handler, rest_terminate, 2) of
- true -> ok = Handler:rest_terminate(Req, HandlerState);
+ true -> ok = Handler:rest_terminate(
+ Req#http_req{resp_state=locked}, HandlerState);
false -> ok
- end.
+ end,
+ {ok, Req}.