Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipv6 #33

Merged
merged 2 commits into from
Sep 11, 2024
Merged

Ipv6 #33

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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
11 changes: 10 additions & 1 deletion src/gleam/httpc.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ type BodyFormat {

type ErlOption {
BodyFormat(BodyFormat)
SocketOpts(List(SocketOpt))
}

type SocketOpt {
Ipfamily(Inet6fb4)
}

type Inet6fb4 {
Inet6fb4
}

type ErlSslOption {
Expand Down Expand Up @@ -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 -> {
Expand Down
7 changes: 7 additions & 0 deletions test/gleam_httpc_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading