diff options
author | Loïc Hoguin <[email protected]> | 2012-09-15 21:18:53 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2012-09-15 21:18:53 +0200 |
commit | cd54214deff03d5ed4a487f9976c3db14f579961 (patch) | |
tree | baf69bf0d1891e12e6b56d5251207a450fbae9e3 /src/cowboy_websocket.erl | |
parent | 35ebe0b108fa82714e4f286ca016777d304e9de3 (diff) | |
download | cowboy-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.erl | 9 |
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. |