Skip to content

Commit

Permalink
mix format
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jan 13, 2023
1 parent cc4c776 commit 425f7c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
9 changes: 5 additions & 4 deletions lib/plug/cowboy/translator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ defmodule Plug.Cowboy.Translator do
| Exception.format(:exit, reason, [])
]

metadata = [
crash_reason: reason,
domain: [:cowboy]
] ++ maybe_conn_metadata(conn)
metadata =
[
crash_reason: reason,
domain: [:cowboy]
] ++ maybe_conn_metadata(conn)

{:ok, message, metadata}
else
Expand Down
16 changes: 8 additions & 8 deletions test/plug/cowboy/conn_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ defmodule Plug.Cowboy.ConnTest do
end

test "upgrades the connection when the connection is a valid websocket" do
{:ok, socket} = :gen_tcp.connect('localhost', 8003, active: false, mode: :binary)
{:ok, socket} = :gen_tcp.connect(~c"localhost", 8003, active: false, mode: :binary)

:gen_tcp.send(socket, """
GET /upgrade_websocket HTTP/1.1\r
Expand Down Expand Up @@ -610,7 +610,7 @@ defmodule Plug.Cowboy.ConnTest do

opts = [
pool: :https,
ssl_options: [cacertfile: @https_options[:certfile], server_name_indication: 'localhost']
ssl_options: [cacertfile: @https_options[:certfile], server_name_indication: ~c"localhost"]
]

assert {:ok, 200, _headers, client} =
Expand All @@ -622,7 +622,7 @@ defmodule Plug.Cowboy.ConnTest do

@http2_opts [
cacertfile: @https_options[:certfile],
server_name_indication: 'localhost',
server_name_indication: ~c"localhost",
port: 8004
]

Expand All @@ -646,29 +646,29 @@ defmodule Plug.Cowboy.ConnTest do
end

test "http2 response" do
{:ok, pid} = Kadabra.open('localhost', :https, @http2_opts)
{:ok, pid} = Kadabra.open(~c"localhost", :https, @http2_opts)
Kadabra.get(pid, "/http2")

assert_receive({:end_stream, %Kadabra.Stream.Response{body: "HTTP/2", status: 200}}, 1_000)
end

test "http2 early hints" do
{:ok, pid} = Kadabra.open('localhost', :https, @http2_opts)
{:ok, pid} = Kadabra.open(~c"localhost", :https, @http2_opts)
Kadabra.get(pid, "/http2?earlyhints=true")
assert_receive({:end_stream, %Kadabra.Stream.Response{headers: headers}})
assert {"link", "</style.css>; rel=preload; as=style"} in headers
end

test "http2 server push" do
{:ok, pid} = Kadabra.open('localhost', :https, @http2_opts)
{:ok, pid} = Kadabra.open(~c"localhost", :https, @http2_opts)
Kadabra.get(pid, "/http2")
assert_receive({:push_promise, %Kadabra.Stream.Response{headers: headers}})
assert {"accept", "text/css"} in headers
assert {":path", "/static/assets.css"} in headers
end

test "http2 server push without automatic mime type" do
{:ok, pid} = Kadabra.open('localhost', :https, @http2_opts)
{:ok, pid} = Kadabra.open(~c"localhost", :https, @http2_opts)
Kadabra.get(pid, "/http2?noinfer=true")
assert_receive({:push_promise, %Kadabra.Stream.Response{headers: headers}})
assert {"accept", "text/plain"} in headers
Expand All @@ -691,7 +691,7 @@ defmodule Plug.Cowboy.ConnTest do

opts = [
pool: :client_ssl_pool,
ssl_options: [server_name_indication: 'localhost'] ++ @client_ssl_opts
ssl_options: [server_name_indication: ~c"localhost"] ++ @client_ssl_opts
]

assert {:ok, 200, _headers, client} =
Expand Down
2 changes: 1 addition & 1 deletion test/plug/cowboy/websocket_handler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ defmodule WebSocketHandlerTest do
# Simple WebSocket client

def tcp_client(context) do
{:ok, socket} = :gen_tcp.connect('localhost', context[:port], active: false, mode: :binary)
{:ok, socket} = :gen_tcp.connect(~c"localhost", context[:port], active: false, mode: :binary)

socket
end
Expand Down

0 comments on commit 425f7c8

Please sign in to comment.