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

no_proxy does not work when using Faraday.get #701

Closed
JasonBarnabe opened this issue Jun 9, 2017 · 2 comments
Closed

no_proxy does not work when using Faraday.get #701

JasonBarnabe opened this issue Jun 9, 2017 · 2 comments

Comments

@JasonBarnabe
Copy link

In this test, 404 is the expected response. 503 is the response from the proxy.

[web@CDLXUTL301 Canadadrugs-Build]$ bundle show faraday
/home/web/.rvm/gems/ruby-2.3.3@canadadrugs/gems/faraday-0.12.1
[web@CDLXUTL301 Canadadrugs-Build]$ RAILS_ENV=test rails console
Loading test environment (Rails 5.0.3)
[1] pry(main)> ENV['http_proxy']
=> "http://lxgw103.candrugcorp.net:3128"
[2] pry(main)> ENV['no_proxy']
=> "localhost,127.0.0.1,172.22.24.151,cdlxutl301.candrugcorp.net"
[3] pry(main)> Faraday.get('http://localhost:8983/select?wt=json&q=*%3A*').status
no_proxy is unsupported
=> 503
[4] pry(main)> Faraday.new(url: 'http://localhost:8983').get('http://localhost:8983/select?wt=json&q=*%3A*').status
=> 404
@iMacTia
Copy link
Member

iMacTia commented Jun 9, 2017

Hi @JasonBarnabe,

when you call Faraday.get without first initialising the connection, a Faraday::Connection with no url is created to perform the request. This causes the find_default_proxy method to be triggered, without no_proxy support (second case I highlighted in #700).
This was raised (#670 (review)) and should be fixed in the next small release.
For the time being, you can make it working using the Faraday.new initialiser as you noticed already.

However your code can be simplified a bit:

Faraday.new('http://localhost:8983').get('/select?wt=json&q=*%3A*').status

@iMacTia
Copy link
Member

iMacTia commented Jul 14, 2017

@JasonBarnabe I'm sorry this was a bit later than expected, but I think I finally got on top of the issue and nicely refactored the environment proxy management to work efficiently in all cases.
A little harder than what I initially thought 😅
I'm going to add new tests before merging #712, but please feel free to give it a shot in your app and leave some feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants