mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 12:40:25 +00:00
send resp_headers with websocket responses
This commit is contained in:
parent
0ba3a9a222
commit
e09a856805
3 changed files with 54 additions and 5 deletions
|
@ -152,12 +152,13 @@ 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 = #{
|
||||
RespHeaders = maps:get(resp_headers, Req, #{}),
|
||||
Headers = maps:merge(RespHeaders, #{
|
||||
%% @todo Hmm should those be here or in cowboy_http?
|
||||
<<"connection">> => <<"Upgrade">>,
|
||||
<<"upgrade">> => <<"websocket">>,
|
||||
<<"sec-websocket-accept">> => Challenge
|
||||
},
|
||||
}),
|
||||
Pid ! {{Pid, StreamID}, {switch_protocol, Headers, ?MODULE, {Req, State, HandlerState}}},
|
||||
{ok, Req, Env}.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue