Add `Sec-WebSocket-Protocol` to response header
authorkPherox <admin@mail.kr-kp.com>
Tue, 15 Oct 2019 10:10:22 +0000 (19:10 +0900)
committerkPherox <admin@mail.kr-kp.com>
Tue, 15 Oct 2019 12:09:44 +0000 (21:09 +0900)
lib/pleroma/web/mastodon_api/websocket_handler.ex

index 3c26eb4069b2a2fb7bad3986d680ee0ffe21fd01..1a757363fc92bb17e8657feaa71665e6161a6468 100644 (file)
@@ -35,6 +35,13 @@ defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do
          {_, stream} <- List.keyfind(params, "stream", 0),
          {:ok, user} <- allow_request(stream, [access_token, sec_websocket]),
          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}}
     else
       {:error, code} ->