0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00
This commit is contained in:
Loïc Hoguin 2016-08-12 17:01:01 +02:00
commit e44ac98c83
4 changed files with 55 additions and 5 deletions

View file

@ -77,6 +77,9 @@
-export([push/3]).
-export([push/4]).
%% Internal.
-export([response_headers/2]).
-type cookie_opts() :: cow_cookie:cookie_opts().
-export_type([cookie_opts/0]).

View file

@ -158,12 +158,11 @@ websocket_handshake(State=#state{key=Key},
Req=#{pid := Pid, streamid := StreamID}, HandlerState, Env) ->
Challenge = base64:encode(crypto:hash(sha,
<< Key/binary, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" >>)),
Headers = #{
%% @todo Hmm should those be here or in cowboy_http?
Headers = cowboy_req:response_headers(#{
<<"connection">> => <<"Upgrade">>,
<<"upgrade">> => <<"websocket">>,
<<"sec-websocket-accept">> => Challenge
},
}, Req),
Pid ! {{Pid, StreamID}, {switch_protocol, Headers, ?MODULE, {Req, State, HandlerState}}},
{ok, Req, Env}.