Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
local_certs
skip_install_trust
storage file_system /caddy_storage
servers :{$HTTPBIN_HTTP_PORT:8080} {
protocols h1 h2c
}
}

https://localhost:{$HTTPBIN_HTTPS_PORT:8443} {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ TINYPROXY_PORT=8887 docker compose up --detach
TINYPROXY_PORT=8887 mix test --include proxy
```

Available port variables: `TINYPROXY_PORT` (default 8888), `TINYPROXY_AUTH_PORT` (default 8889), `HTTPBIN_HTTP_PORT` (default 8080), `HTTPBIN_HTTPS_PORT` (default 8443).
Available port variables: `TINYPROXY_PORT` (default 8888), `TINYPROXY_AUTH_PORT` (default 8889), `HTTPBIN_HTTP_PORT` (default 8080), `HTTPBIN_HTTPS_PORT` (default 8443), `HTTPBIN_H2C_PORT` (default 8081).

## License

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ services:
- "./Caddyfile:/etc/caddy/Caddyfile:z"
ports:
- "${HTTPBIN_HTTPS_PORT:-8443}:${HTTPBIN_HTTPS_PORT:-8443}"
- "${HTTPBIN_H2C_PORT:-8081}:${HTTPBIN_HTTP_PORT:-8080}"
38 changes: 4 additions & 34 deletions test/mint/http2/integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ defmodule HTTP2.IntegrationTest do
end
end

test "TCP - nghttp2.org" do
assert {:ok, %HTTP2{} = conn} = HTTP2.connect(:http, "nghttp2.org", 80)
test "TCP - h2c prior knowledge" do
assert {:ok, %HTTP2{} = conn} = HTTP2.connect(:http, HttpBin.host(), HttpBin.h2c_port())

assert {:ok, %HTTP2{} = conn, ref} = HTTP2.request(conn, "GET", "/httpbin/", [], nil)

# For some reason, we get an SSL message sneaking in here. Instead of going
# crazy trying to debug it, for now let's just swallow it.
assert_receive {:ssl, _socket, _data}, 1000
assert {:ok, %HTTP2{} = conn, ref} = HTTP2.request(conn, "GET", "/", [], nil)

assert {:ok, %HTTP2{} = conn, responses} = receive_stream(conn)

Expand Down Expand Up @@ -105,7 +101,7 @@ defmodule HTTP2.IntegrationTest do
end

describe "twitter.com" do
@moduletag connect: {"twitter.com", 443}
@describetag connect: {"twitter.com", 443}
@browser_user_agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"

test "ping", %{conn: conn} do
Expand Down Expand Up @@ -159,32 +155,6 @@ defmodule HTTP2.IntegrationTest do
end
end

describe "nghttp2.org/httpbin" do
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests duplicated mint code paths already covered by the "httpbin.org" describe block (local Caddy over HTTPS/h2): HTTP2.ping/1 and HTTP2.request/5.

@describetag connect: {"nghttp2.org", 443}

test "ping", %{conn: conn} do
assert {:ok, %HTTP2{} = conn, ref} = HTTP2.ping(conn)
assert {:ok, %HTTP2{} = conn, [{:pong, ^ref}]} = receive_stream(conn)
assert conn.buffer == ""
assert HTTP2.open?(conn)
end

test "GET /", %{conn: conn} do
assert {:ok, %HTTP2{} = conn, ref} = HTTP2.request(conn, "GET", "/httpbin/", [], nil)

assert {:ok, %HTTP2{} = conn, responses} = receive_stream(conn)

assert [{:status, ^ref, status}, {:headers, ^ref, headers} | rest] = responses
assert {_, [{:done, ^ref}]} = Enum.split_while(rest, &match?({:data, ^ref, _}, &1))

assert status == 200
assert is_list(headers)

assert conn.buffer == ""
assert HTTP2.open?(conn)
end
end

describe "robynthinks.wordpress.com" do
@describetag connect: {"robynthinks.wordpress.com", 443}

Expand Down
4 changes: 4 additions & 0 deletions test/support/mint/http_bin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ defmodule Mint.HttpBin do
get_env_port("HTTPBIN_HTTPS_PORT", 8443)
end

def h2c_port() do
get_env_port("HTTPBIN_H2C_PORT", 8081)
end

def proxy_port() do
get_env_port("TINYPROXY_PORT", 8888)
end
Expand Down
Loading