From 8d2102fe1174d5fb82d80ca3beba83b9d5bbb238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 8 Dec 2011 18:30:13 +0100 Subject: Allow HTTP protocol upgrades to use keepalive REST needed this to be allowed to chain requests on the same connection. --- src/cowboy_http_rest.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/cowboy_http_rest.erl') 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 {upgrade, protocol, {@module}} %% in your cowboy_http_handler:init/3 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}. -- cgit v1.2.3