Add Sec-WebSocket-Protocol to response header

This commit is contained in:
kPherox 2019-10-15 19:10:22 +09:00
parent 8b39d6f93c
commit 5bd0717de2
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D

View File

@ -35,6 +35,13 @@ def init(%{qs: qs} = req, state) do
{_, stream} <- List.keyfind(params, "stream", 0), {_, stream} <- List.keyfind(params, "stream", 0),
{:ok, user} <- allow_request(stream, [access_token, sec_websocket]), {:ok, user} <- allow_request(stream, [access_token, sec_websocket]),
topic when is_binary(topic) <- expand_topic(stream, params) do topic when is_binary(topic) <- expand_topic(stream, params) do
req =
if sec_websocket != nil do
:cowboy_req.set_resp_header("sec-websocket-protocol", sec_websocket, req)
else
req
end
{:cowboy_websocket, req, %{user: user, topic: topic}, %{idle_timeout: @timeout}} {:cowboy_websocket, req, %{user: user, topic: topic}, %{idle_timeout: @timeout}}
else else
{:error, code} -> {:error, code} ->