Skip to content

Commit

Permalink
Implement no-op support for Plug.Conn.Adapter.upgrade/3
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrudel committed Oct 29, 2022
1 parent d5b5403 commit 6d3725d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/plug/cowboy/conn.ex
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ defmodule Plug.Cowboy.Conn do
:cowboy_req.inform(status, to_headers_map(headers), req)
end

@impl true
def upgrade(_req, _protocol, _args), do: {:error, :not_supported}

@impl true
def push(req, path, headers) do
opts =
Expand Down
10 changes: 10 additions & 0 deletions test/plug/cowboy/conn_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,16 @@ defmodule Plug.Cowboy.ConnTest do
request(:get, "/inform")
end

def upgrade_unsupported(conn) do
conn
|> upgrade_adapter(:unsupported, opt: :unsupported)
end

test "upgrade will not set the response" do
assert {500, _, body} = request(:get, "/upgrade_unsupported")
assert body =~ "upgrade to unsupported not supported by Plug.Cowboy.Conn"
end

def push(conn) do
conn
|> push("/static/assets.css")
Expand Down

0 comments on commit 6d3725d

Please sign in to comment.