diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b55f78a..b33f000 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,13 +1,12 @@ --- name: Bug report about: Create a report to help us improve - --- ### Environment -* Elixir & Erlang/OTP versions (`elixir --version`): -* Operating system: +- Elixir & Erlang/OTP versions (`elixir --version`): +- Operating system: ### Current behavior diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index f6e0c2e..236f9d2 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,7 +1,6 @@ --- name: Feature request about: Suggest an idea for this project - --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3628d76 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + prettier: + name: Prettier + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: Install Prettier + run: npm install --global prettier + - name: Run Prettier + run: prettier --check --no-error-on-unmatched-pattern "**/*.{json,md,yml,yaml}" + check: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: "1.17.2" + otp-version: "27.0.1" + - name: Restore dependencies cache + uses: actions/cache@v3 + with: + path: deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-mix- + - name: Install dependencies + run: mix deps.get + - name: Run formatter + run: mix format --check-formatted + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + elixir-version: "1.17.2" + otp-version: "27.0.1" + - name: Restore dependencies cache + uses: actions/cache@v3 + with: + path: deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-mix- + - name: Install dependencies + run: mix deps.get + - name: Run tests + run: mix test diff --git a/.tool-versions b/.tool-versions index fa6f17c..b7c4c5b 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1,2 @@ -elixir 1.11.3 +elixir 1.17.2-otp-27 +erlang 27.0.1 diff --git a/lib/encodable.ex b/lib/encodable.ex index b1db780..5d45853 100644 --- a/lib/encodable.ex +++ b/lib/encodable.ex @@ -13,8 +13,7 @@ defprotocol Kadabra.Encodable do <<0, 0, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>> iex> %Kadabra.Connection.Settings{enable_push: false} |> to_bin() - <<0, 5, 0, 0, 64, 0, 0, 4, 0, 0, 255, 255, 0, 1, 0, 0, 16, 0, 0, 2, - 0, 0, 0, 0>> + <<0, 1, 0, 0, 16, 0, 0, 2, 0, 0, 0, 0, 0, 4, 0, 0, 255, 255, 0, 5, 0, 0, 64, 0>> iex> %Kadabra.Frame.Continuation{end_headers: true, ...> stream_id: 1, header_block_fragment: <<255, 255, 255>>} |> to_bin() @@ -135,6 +134,7 @@ defimpl Kadabra.Encodable, for: Kadabra.Connection.Settings do settings |> Map.from_struct() |> to_encoded_list() + |> Enum.sort() |> Enum.join() end diff --git a/lib/frame/continuation.ex b/lib/frame/continuation.ex index f6e2195..d25def8 100644 --- a/lib/frame/continuation.ex +++ b/lib/frame/continuation.ex @@ -3,7 +3,7 @@ defmodule Kadabra.Frame.Continuation do defstruct [:header_block_fragment, :stream_id, end_headers: false] - use Bitwise + import Bitwise @type t :: %__MODULE__{ end_headers: boolean, diff --git a/lib/frame/data.ex b/lib/frame/data.ex index fc6d127..2608be0 100644 --- a/lib/frame/data.ex +++ b/lib/frame/data.ex @@ -3,7 +3,7 @@ defmodule Kadabra.Frame.Data do defstruct [:stream_id, :data, end_stream: false] - use Bitwise + import Bitwise alias Kadabra.Frame diff --git a/lib/frame/headers.ex b/lib/frame/headers.ex index 94b07e7..7c7310c 100644 --- a/lib/frame/headers.ex +++ b/lib/frame/headers.ex @@ -21,7 +21,7 @@ defmodule Kadabra.Frame.Headers do weight: non_neg_integer } - use Bitwise + import Bitwise alias Kadabra.Frame diff --git a/lib/frame/ping.ex b/lib/frame/ping.ex index 95f29f2..80cfd0f 100644 --- a/lib/frame/ping.ex +++ b/lib/frame/ping.ex @@ -3,7 +3,7 @@ defmodule Kadabra.Frame.Ping do defstruct [:data, stream_id: 0, ack: false] - use Bitwise + import Bitwise alias Kadabra.Frame diff --git a/lib/frame/push_promise.ex b/lib/frame/push_promise.ex index 581aa6d..461a3a2 100644 --- a/lib/frame/push_promise.ex +++ b/lib/frame/push_promise.ex @@ -5,7 +5,7 @@ defmodule Kadabra.Frame.PushPromise do header_block_fragment: nil, stream_id: nil - use Bitwise + import Bitwise alias Kadabra.Frame diff --git a/lib/frame/settings.ex b/lib/frame/settings.ex index ec09b29..b36e553 100644 --- a/lib/frame/settings.ex +++ b/lib/frame/settings.ex @@ -3,7 +3,7 @@ defmodule Kadabra.Frame.Settings do defstruct [:settings, ack: false] - use Bitwise + import Bitwise alias Kadabra.Connection diff --git a/lib/kadabra.ex b/lib/kadabra.ex index 10b4558..7a59a79 100644 --- a/lib/kadabra.ex +++ b/lib/kadabra.ex @@ -9,7 +9,7 @@ defmodule Kadabra do ## Usage - {:ok, pid} = Kadabra.open("https://http2.golang.org") + {:ok, pid} = Kadabra.open("https://http2.codedge.dev") Kadabra.get(pid, "/") receive do {:end_stream, %Kadabra.Stream.Response{} = stream} -> @@ -32,7 +32,7 @@ defmodule Kadabra do ## Making Requests Manually - {:ok, pid} = Kadabra.open("https://http2.golang.org") + {:ok, pid} = Kadabra.open("https://http2.codedge.dev") path = "/ECHO" # Route echoes PUT body in uppercase body = "sample echo request" @@ -97,11 +97,11 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open("http://http2.golang.org") + iex> {:ok, pid} = Kadabra.open("http://http2.codedge.dev") iex> is_pid(pid) true - iex> {:ok, pid} = Kadabra.open("https://http2.golang.org") + iex> {:ok, pid} = Kadabra.open("https://http2.codedge.dev") iex> is_pid(pid) true """ @@ -127,7 +127,7 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open("https://http2.golang.org") + iex> {:ok, pid} = Kadabra.open("https://http2.codedge.dev") iex> Kadabra.close(pid) iex> receive do ...> {:closed, _pid} -> "connection closed!" @@ -144,7 +144,7 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open('https://http2.golang.org') + iex> {:ok, pid} = Kadabra.open(~c"https://http2.codedge.dev") iex> Kadabra.ping(pid) iex> receive do ...> {:pong, _pid} -> "got pong!" @@ -161,7 +161,7 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open('https://http2.golang.org') + iex> {:ok, pid} = Kadabra.open(~c"https://http2.codedge.dev") iex> path = "/ECHO" # Route echoes PUT body in uppercase iex> body = "sample echo request" iex> headers = [ @@ -195,14 +195,14 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open('https://http2.golang.org') - iex> Kadabra.head(pid, "/reqinfo") + iex> {:ok, pid} = Kadabra.open(~c"https://http2.codedge.dev") + iex> Kadabra.get(pid, "/") :ok iex> response = receive do ...> {:end_stream, response} -> response ...> end iex> {response.id, response.status, response.body} - {1, 200, ""} + {1, 200, "GET OK"} """ @spec get(pid, String.t(), Keyword.t()) :: no_return def get(pid, path, opts \\ []) do @@ -214,7 +214,7 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open('https://http2.golang.org') + iex> {:ok, pid} = Kadabra.open(~c"https://http2.codedge.dev") iex> Kadabra.head(pid, "/") :ok iex> response = receive do @@ -233,7 +233,7 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open('https://http2.golang.org') + iex> {:ok, pid} = Kadabra.open(~c"https://http2.codedge.dev") iex> Kadabra.post(pid, "/", body: "test=123") :ok iex> response = receive do @@ -252,16 +252,14 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open('https://http2.golang.org') - iex> Kadabra.put(pid, "/crc32", body: "test") + iex> {:ok, pid} = Kadabra.open(~c"https://http2.codedge.dev") + iex> Kadabra.put(pid, "/", body: "test") :ok iex> stream = receive do ...> {:end_stream, stream} -> stream ...> end iex> stream.status 200 - iex> stream.body - "bytes=4, CRC32=d87f7e0c" """ @spec put(pid, String.t(), Keyword.t()) :: no_return def put(pid, path, opts \\ []) do @@ -273,7 +271,7 @@ defmodule Kadabra do ## Examples - iex> {:ok, pid} = Kadabra.open('https://http2.golang.org') + iex> {:ok, pid} = Kadabra.open(~c"https://http2.codedge.dev") iex> Kadabra.delete(pid, "/") :ok iex> stream = receive do diff --git a/mix.exs b/mix.exs index dbf7cb8..3b2b2c6 100644 --- a/mix.exs +++ b/mix.exs @@ -49,7 +49,7 @@ defmodule Kadabra.Mixfile do {:dialyxir, "~> 1.0", only: [:dev], runtime: false}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:excoveralls, "~> 0.7", only: :test, runtime: false}, - {:hpack, "~> 0.2.3", hex: :hpack_erl} + {:hpack, "~> 0.3.0", hex: :hpack_erl} ] end diff --git a/mix.lock b/mix.lock index 6cc4e03..1bd35a7 100644 --- a/mix.lock +++ b/mix.lock @@ -1,30 +1,32 @@ %{ "benchee": {:hex, :benchee, "0.11.0", "cf96e328ff5d69838dd89c21a9db22716bfcc6ef772e9d9dddf7ba622102722d", [], [{:deep_merge, "~> 0.1", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"}, - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "certifi": {:hex, :certifi, "2.5.3", "70bdd7e7188c804f3a30ee0e7c99655bc35d8ac41c23e12325f36ab449b70651", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "ed516acb3929b101208a9d700062d520f3953da3b6b918d866106ffa980e1c10"}, - "credo": {:hex, :credo, "1.5.5", "e8f422026f553bc3bebb81c8e8bf1932f498ca03339856c7fec63d3faac8424b", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "dd8623ab7091956a855dc9f3062486add9c52d310dfd62748779c4315d8247de"}, + "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, + "certifi": {:hex, :certifi, "2.13.0", "e52be248590050b2dd33b0bb274b56678f9068e67805dca8aa8b1ccdb016bbf6", [:rebar3], [], "hexpm", "8f3d9533a0f06070afdfd5d596b32e21c6580667a492891851b0e2737bc507a1"}, + "credo": {:hex, :credo, "1.7.7", "771445037228f763f9b2afd612b6aa2fd8e28432a95dbbc60d8e03ce71ba4446", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8bc87496c9aaacdc3f90f01b7b0582467b69b4bd2441fe8aae3109d843cc2f2e"}, "deep_merge": {:hex, :deep_merge, "0.1.1", "c27866a7524a337b6a039eeb8dd4f17d458fd40fbbcb8c54661b71a22fffe846", [], [], "hexpm"}, - "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, + "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, "dogma": {:hex, :dogma, "0.1.16", "3c1532e2f63ece4813fe900a16704b8e33264da35fdb0d8a1d05090a3022eef9", [:mix], [{:poison, ">= 2.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, - "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"}, - "excoveralls": {:hex, :excoveralls, "0.14.0", "4b562d2acd87def01a3d1621e40037fdbf99f495ed3a8570dfcf1ab24e15f76d", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "94f17478b0cca020bcd85ce7eafea82d2856f7ed022be777734a2f864d36091a"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"}, + "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, + "ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"}, + "excoveralls": {:hex, :excoveralls, "0.18.2", "86efd87a0676a3198ff50b8c77620ea2f445e7d414afa9ec6c4ba84c9f8bdcc2", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "230262c418f0de64077626a498bd4fdf1126d5c2559bb0e6b43deac3005225a4"}, "exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"}, - "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, + "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, "gen_stage": {:hex, :gen_stage, "0.13.1", "edff5bca9cab22c5d03a834062515e6a1aeeb7665fb44eddae086252e39c4378", [:mix], [], "hexpm"}, "hackney": {:hex, :hackney, "1.17.0", "717ea195fd2f898d9fe9f1ce0afcc2621a41ecfe137fae57e7fe6e9484b9aa99", [:rebar3], [{:certifi, "~>2.5", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "64c22225f1ea8855f584720c0e5b3cd14095703af1c9fbc845ba042811dc671c"}, - "hpack": {:hex, :hpack_erl, "0.2.3", "17670f83ff984ae6cd74b1c456edde906d27ff013740ee4d9efaa4f1bf999633", [:rebar3], [], "hexpm", "06f580167c4b8b8a6429040df36cc93bba6d571faeaec1b28816523379cbb23a"}, + "hpack": {:hex, :hpack_erl, "0.3.0", "2461899cc4ab6a0ef8e970c1661c5fc6a52d3c25580bc6dd204f84ce94669926", [:rebar3], [], "hexpm", "d6137d7079169d8c485c6962dfe261af5b9ef60fbc557344511c1e65e3d95fb0"}, + "hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "inch_ex": {:hex, :inch_ex, "0.5.6", "418357418a553baa6d04eccd1b44171936817db61f4c0840112b420b8e378e67", [:mix], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"}, - "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "pane": {:hex, :pane, "0.1.1", "4a9b46957a02991acbce012169ab7e8ecff74ad24886f94b142680062b10f167", [:mix], [], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"}, diff --git a/test/connection/settings_test.exs b/test/connection/settings_test.exs index 77498e9..3ff4f73 100644 --- a/test/connection/settings_test.exs +++ b/test/connection/settings_test.exs @@ -9,8 +9,8 @@ defmodule Kadabra.Connection.SettingsTest do |> Kadabra.Encodable.to_bin() assert bin_settings == - <<0, 5, 0, 0, 64, 0, 0, 3, 0, 0, 0, 250, 0, 4, 0, 0, 255, 255, 0, - 1, 0, 0, 16, 0, 0, 2, 0, 0, 0, 1>> + <<0, 1, 0, 0, 16, 0, 0, 2, 0, 0, 0, 1, 0, 3, 0, 0, 0, 250, 0, 4, + 0, 0, 255, 255, 0, 5, 0, 0, 64, 0>> end test "encodes max_header_list_size" do @@ -19,8 +19,8 @@ defmodule Kadabra.Connection.SettingsTest do |> Kadabra.Encodable.to_bin() assert bin_settings == - <<0, 6, 0, 0, 0, 24, 0, 5, 0, 0, 64, 0, 0, 4, 0, 0, 255, 255, 0, - 1, 0, 0, 16, 0, 0, 2, 0, 0, 0, 1>> + <<0, 1, 0, 0, 16, 0, 0, 2, 0, 0, 0, 1, 0, 4, 0, 0, 255, 255, 0, + 5, 0, 0, 64, 0, 0, 6, 0, 0, 0, 24>> end end end diff --git a/test/connection_test.exs b/test/connection_test.exs index 30bf975..2384867 100644 --- a/test/connection_test.exs +++ b/test/connection_test.exs @@ -2,7 +2,7 @@ defmodule Kadabra.ConnectionTest do use ExUnit.Case test "closes active streams on socket close" do - uri = 'https://http2.golang.org' + uri = ~c"https://http2.codedge.dev" {:ok, pid} = Kadabra.open(uri) ref = Process.monitor(pid) diff --git a/test/kadabra_test.exs b/test/kadabra_test.exs index 7d6f9e6..cbb372d 100644 --- a/test/kadabra_test.exs +++ b/test/kadabra_test.exs @@ -6,11 +6,11 @@ defmodule KadabraTest do alias Kadabra.Stream - @golang_uri "https://http2.golang.org" + @base_uri "https://http2.codedge.dev" setup do pid = - @golang_uri + @base_uri |> Kadabra.open() |> elem(1) @@ -18,10 +18,9 @@ defmodule KadabraTest do end describe "open/2" do - @tag :golang test "sets port if specified", _context do opts = [port: 443] - {:ok, pid} = Kadabra.open(@golang_uri, opts) + {:ok, pid} = Kadabra.open(@base_uri, opts) conn_pid = :sys.get_state(pid).connection conn = :sys.get_state(conn_pid) @@ -32,7 +31,6 @@ defmodule KadabraTest do end describe "request/2" do - @tag :golang test "can take a list of requests", context do headers = [ {":method", "GET"}, @@ -48,7 +46,6 @@ defmodule KadabraTest do end end - @tag :golang test "can take a single request", context do headers = [ {":method", "GET"}, @@ -75,7 +72,6 @@ defmodule KadabraTest do end describe "GET" do - @tag :golang test "can take an options keyword list", context do headers = [ {":method", "GET"}, @@ -87,26 +83,11 @@ defmodule KadabraTest do assert_receive {:end_stream, %Stream.Response{id: 1}}, 5_000 end - @tag :golang - test "https://http2.golang.org/reqinfo", context do - Kadabra.get(context[:conn], "/reqinfo") - - receive do - {:end_stream, response} -> - assert response.id == 1 - assert response.status == 200 - after - 5_000 -> - flunk("No stream response received.") - end - end - - @tag :golang - test "https://http2.golang.org/reqinfo a lot", context do - count = 5_000 + test "handles a lot of requests", context do + count = 500 for _x <- 1..count do - Kadabra.get(context[:conn], "/reqinfo") + Kadabra.get(context[:conn], "/") end is_odd = fn x -> rem(x, 2) == 1 end @@ -117,48 +98,28 @@ defmodule KadabraTest do end end - @tag :golang - test "https://http2.golang.org/redirect", context do - Kadabra.get(context[:conn], "/redirect") - - expected_body = "Found.\n\n" - expected_status = 302 - - receive do - {:end_stream, response} -> - assert response.id == 1 - assert response.status == expected_status - assert response.body == expected_body - after - 5_000 -> - flunk("No stream response received.") - end - end - - @tag :golang - test "https://http2.golang.org/file/gopher.png", context do - Kadabra.get(context[:conn], "/file/gopher.png") + test "https://http2.codedge.dev/file/hpopp.jpg", context do + Kadabra.get(context[:conn], "/file/hpopp.jpg") receive do {:end_stream, response} -> assert response.id == 1 assert response.status == 200 - assert byte_size(response.body) == 17_668 + assert byte_size(response.body) == 316_853 after 5_000 -> flunk("No stream response received.") end end - @tag :golang - test "https://http2.golang.org/file/go.src.tar.gz", context do - Kadabra.get(context[:conn], "/file/go.src.tar.gz") + test "https://http2.codedge.dev/file/eclipse.jpg", context do + Kadabra.get(context[:conn], "/file/eclipse.jpg") receive do {:end_stream, response} -> assert response.id == 1 assert response.status == 200 - assert byte_size(response.body) == 10_921_353 + assert byte_size(response.body) == 9_026_709 other -> flunk("Unexpected response: #{inspect(other)}") @@ -168,25 +129,24 @@ defmodule KadabraTest do end end - @tag :golang - test "https://http2.golang.org/serverpush", context do - Kadabra.get(context[:conn], "/serverpush") - - receive do - {:push_promise, response} -> - assert response.id == 2 - refute response.status - assert Stream.Response.get_header(response.headers, ":path") - after - 5_000 -> - flunk("No push promise received.") - end - end + # @tag :golang + # test "https://http2.golang.org/serverpush", context do + # Kadabra.get(context[:conn], "/serverpush") + + # receive do + # {:push_promise, response} -> + # assert response.id == 2 + # refute response.status + # assert Stream.Response.get_header(response.headers, ":path") + # after + # 5_000 -> + # flunk("No push promise received.") + # end + # end end describe "PUT" do - @tag :golang - test "https://http2.golong.org/ECHO", context do + test "https://http2.codedge.dev/ECHO", context do payload = String.duplicate("test", 10) Kadabra.put(context[:conn], "/ECHO", body: payload) @@ -203,9 +163,8 @@ defmodule KadabraTest do end end - @tag :golang - test "https://http2.golong.org/ECHO with large payload", context do - payload = String.duplicate("test", 1_000_000) + test "https://http2.codedge.dev/ECHO with large payload", context do + payload = String.duplicate("test", 500_000) Kadabra.put(context[:conn], "/ECHO", body: payload) expected_body = String.upcase(payload) @@ -220,29 +179,11 @@ defmodule KadabraTest do flunk("No stream response received.") end end - - @tag :golang - test "https://http2.golong.org/crc32", context do - payload = "test" - Kadabra.put(context[:conn], "/crc32", body: payload) - - expected_body = "bytes=4, CRC32=d87f7e0c" - - receive do - {:end_stream, response} -> - assert response.id == 1 - assert response.status == 200 - assert response.body == expected_body - after - 5_000 -> - flunk("No stream response received.") - end - end end test "socket close message closes connection", _context do pid = - @golang_uri + @base_uri |> Kadabra.open() |> elem(1) diff --git a/test/request_test.exs b/test/request_test.exs index 3f8ae66..c7ffcc7 100644 --- a/test/request_test.exs +++ b/test/request_test.exs @@ -3,7 +3,7 @@ defmodule Kadabra.RequestTest do doctest Kadabra.Request test "processes on_response on END_STREAM" do - uri = 'https://http2.golang.org' + uri = ~c"https://http2.codedge.dev" pid = self() on_resp = fn _resp -> send(pid, :done) end diff --git a/test/test_helper.exs b/test/test_helper.exs index 6a0af57..869559e 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1 +1 @@ -ExUnit.start(capture_log: true) +ExUnit.start()