Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion lib/req/finch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ defmodule Req.Finch do

cond do
name = request.options[:finch] ->
if custom_options? do
if Map.has_key?(request.options, :connect_options) do
raise ArgumentError, "cannot set both :finch and :connect_options"
else
name
Expand Down
39 changes: 39 additions & 0 deletions test/req/finch_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,45 @@ defmodule Req.FinchTest do
end
end

test ":finch and :inet6" do
# :inet6 can be auto-set for IPv6 URLs; it should not conflict with :finch
assert_raise ArgumentError, "unknown registry: MyFinch", fn ->
Req.get!("http://localhost", finch: MyFinch, inet6: true)
end
Comment thread
meox marked this conversation as resolved.
Outdated
end

test ":finch with IPv6 URL" do
start_supervised!(
{Plug.Cowboy,
scheme: :http,
plug: ExamplePlug,
ref: ExamplePlug.IPv6Named,
port: 0,
net: :inet6,
ipv6_v6only: true}
)

ipv6_port = :ranch.get_port(ExamplePlug.IPv6Named)

finch_name = __MODULE__.IPv6Finch

start_supervised!(
{Finch,
name: finch_name,
pools: %{
default: [
protocols: [:http1],
conn_opts: [transport_opts: [inet6: true]]
]
}}
)

# Before the fix, this would raise "cannot set both :finch and :connect_options"
# because Req auto-sets inet6: true for IPv6 URLs like [::1]
Comment thread
meox marked this conversation as resolved.
Outdated
req = Req.new(url: "http://[::1]:#{ipv6_port}", finch: finch_name)
assert Req.request!(req).body == "ok"
end

def send_telemetry_metadata_pid(_name, _measurements, metadata, _) do
if pid = metadata.request.private[:pid] do
send(pid, :telemetry_private)
Expand Down