lostisland / lostisland/faraday

faraday does not support ipv6 in URL

Open
#589 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature help wanted
Dominant language
Ruby
Stars
5.9k
Forks
1k
Avg merge
5d 17h
Merged PRs (30d)
6

Description

Issue:
faraday does not support ipv6 in URL.
For example:
http://[::1]/
http://[::1]:80/

Steps to reproduce:

  1. Prepare a server with ipv6 environment.
  2. Start a HTTP server. (This step can be skipped because the issue is occurred before request is sent)
  3. Run the following sample.
require 'faraday'
conn = Faraday.new(:url => 'http://[::1]:80') do |faraday|
  faraday.request  :url_encoded             # form-encode POST params
  faraday.response :logger                  # log requests to STDOUT
  faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
end
resp = conn.get '/'

Finally it'll throw the exception below.

/usr/local/lib/ruby/2.1.0/net/http.rb:879:in `initialize': getaddrinfo: Name or service not known (Faraday::ConnectionFailed)
        from /usr/local/lib/ruby/2.1.0/net/http.rb:879:in `open'
        from /usr/local/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'
        from /usr/local/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
        from /usr/local/lib/ruby/2.1.0/net/http.rb:878:in `connect'
        from /usr/local/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
        from /usr/local/lib/ruby/2.1.0/net/http.rb:852:in `start'
        from /usr/local/lib/ruby/2.1.0/net/http.rb:1369:in `request'
        from /usr/local/lib/ruby/2.1.0/net/http.rb:1128:in `get'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:80:in `perform_request'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:40:in `block in call'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/adapter/net_http.rb:32:in `call'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/response.rb:8:in `call'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/response/logger.rb:24:in `call'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb:15:in `call'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/rack_builder.rb:139:in `build_response'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/connection.rb:377:in `run_request'
        from /usr/local/lib/ruby/gems/2.1.0/gems/faraday-0.9.2/lib/faraday/connection.rb:140:in `get'
        from f.rb:9:in `<main>'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The failure reaches Faraday's Net::HTTP adapter at lib/faraday/adapter/net_http.rb; begin by tracing how bracketed IPv6 hosts from the connection URL are passed to Net::HTTP. Reproduce both URL forms against an IPv6 server and add coverage so they connect successfully without the getaddrinfo error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.