diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fbbdc9..f864e55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +- Added transparent support for IPv6. + +## v2.2.0 - 2024-04-19 + - Added the `dispatch`, `dispatch_bits`, `verify_tls`, and `configure` functions. diff --git a/src/gleam/httpc.gleam b/src/gleam/httpc.gleam index bed0dad..5b6e354 100644 --- a/src/gleam/httpc.gleam +++ b/src/gleam/httpc.gleam @@ -25,6 +25,15 @@ type BodyFormat { type ErlOption { BodyFormat(BodyFormat) + SocketOpts(List(SocketOpt)) +} + +type SocketOpt { + Ipfamily(Inet6fb4) +} + +type Inet6fb4 { + Inet6fb4 } type ErlSslOption { @@ -94,7 +103,7 @@ pub fn dispatch_bits( True -> [] False -> [Ssl([Verify(VerifyNone)])] } - let erl_options = [BodyFormat(Binary)] + let erl_options = [BodyFormat(Binary), SocketOpts([Ipfamily(Inet6fb4)])] use response <- result.then(case req.method { http.Options | http.Head | http.Get -> { diff --git a/test/gleam_httpc_test.gleam b/test/gleam_httpc_test.gleam index a1fd368..d3db240 100644 --- a/test/gleam_httpc_test.gleam +++ b/test/gleam_httpc_test.gleam @@ -85,3 +85,10 @@ pub fn invalid_tls_test() { |> httpc.dispatch(req) let assert 200 = response.status } + +pub fn ipv6_test() { + // This URL is ipv6 only + let assert Ok(req) = request.to("https://ipv6.google.com") + let assert Ok(resp) = httpc.send(req) + let assert 200 = resp.status +}