Skip to content

Commit

Permalink
Porting fix for Net::HTTP env proxy (Faraday #1221) (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMacTia committed Dec 25, 2020
1 parent 3278e9d commit 790cb8b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 103 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ spec/reports/
tmp/

*.gem
gemfile.lock

.rvmrc
.ruby-version

.rspec_status
.rspec_status
2 changes: 0 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Metrics/BlockLength:
Exclude:
- spec/**/*.rb
- examples/**/*.rb
Metrics/ClassLength:
Enabled: false
Metrics/AbcSize:
Max: 67
Metrics/ClassLength:
Expand Down
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

87 changes: 0 additions & 87 deletions Gemfile.lock

This file was deleted.

15 changes: 8 additions & 7 deletions lib/faraday/adapter/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ def build_connection(env)
end

def net_http_connection(env)
klass = if (proxy = env[:request][:proxy])
Net::HTTP::Proxy(proxy[:uri].hostname, proxy[:uri].port,
proxy[:user], proxy[:password])
else
Net::HTTP
end
proxy = env[:request][:proxy]
port = env[:url].port || (env[:url].scheme == 'https' ? 443 : 80)
klass.new(env[:url].hostname, port)
if proxy
Net::HTTP.new(env[:url].hostname, port,
proxy[:uri].hostname, proxy[:uri].port,
proxy[:user], proxy[:password])
else
Net::HTTP.new(env[:url].hostname, port, nil)
end
end

def call(env)
Expand Down

0 comments on commit 790cb8b

Please sign in to comment.