aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_websocket.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-09-15 21:18:53 +0200
committerLoïc Hoguin <[email protected]>2012-09-15 21:18:53 +0200
commitcd54214deff03d5ed4a487f9976c3db14f579961 (patch)
treebaf69bf0d1891e12e6b56d5251207a450fbae9e3 /src/cowboy_websocket.erl
parent35ebe0b108fa82714e4f286ca016777d304e9de3 (diff)
downloadcowboy-cd54214deff03d5ed4a487f9976c3db14f579961.tar.gz
cowboy-cd54214deff03d5ed4a487f9976c3db14f579961.tar.bz2
cowboy-cd54214deff03d5ed4a487f9976c3db14f579961.zip
Avoid a duplicate HTTP reply in cowboy_websocket:upgrade_error/1
Do this by checking whether we received the resp_sent message.
Diffstat (limited to 'src/cowboy_websocket.erl')
-rw-r--r--src/cowboy_websocket.erl9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cowboy_websocket.erl b/src/cowboy_websocket.erl
index 4d77b73..04082e1 100644
--- a/src/cowboy_websocket.erl
+++ b/src/cowboy_websocket.erl
@@ -140,9 +140,12 @@ handler_init(State=#state{transport=Transport, handler=Handler, opts=Opts},
-spec upgrade_error(cowboy_req:req()) -> closed.
upgrade_error(Req) ->
- {ok, _Req2} = cowboy_req:reply(400, [], [],
- Req#http_req{resp_state=waiting}),
- closed.
+ receive
+ {cowboy_req, resp_sent} -> closed
+ after 0 ->
+ _ = cowboy_req:reply(400, [], [], Req),
+ closed
+ end.
%% @see cowboy_protocol:ensure_response/1
-spec upgrade_denied(cowboy_req:req()) -> closed.