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

Proxy support #18

Closed
semaperepelitsa opened this issue May 28, 2020 · 3 comments
Closed

Proxy support #18

semaperepelitsa opened this issue May 28, 2020 · 3 comments

Comments

@semaperepelitsa
Copy link

It seems to be ignoring :proxy parameter (or http_proxy environment variable). Is this not supported?

> Faraday.new(proxy: "http://example.com") { |f| f.adapter :async_http }.get("http://google.com").headers
=> {"Location"=>"http://www.google.com/",
 "Content-Type"=>"text/html; charset=UTF-8",
 "Date"=>"Thu, 28 May 2020 21:42:59 GMT",
 "Expires"=>"Sat, 27 Jun 2020 21:42:59 GMT",
 "Cache-Control"=>"public, max-age=2592000",
 "Server"=>"gws",
 "X-XSS-Protection"=>"0",
 "X-Frame-Options"=>"SAMEORIGIN"}

> Faraday.new(proxy: "http://example.com") { |f| f.adapter :net_http }.get("http://google.com").headers
=> {"content-type"=>"text/html", "date"=>"Thu, 28 May 2020 21:42:48 GMT", "server"=>"ECS (nyb/1D2F)", "content-length"=>"345"}
@ioquatix
Copy link
Member

The underlying async-http library supports it but I don't know how faraday works. Can you point me at the documentation for how faraday expects the underlying adapters to work?

@semaperepelitsa
Copy link
Author

I don't know if there are any guides on making custom adapters. I would just look at the official implementations and imitate what they are doing. For example, Net HTTP:
https://github.com/lostisland/faraday/blob/f6130995eb4db72a46d612f5d8e212b4dd2cf5b9/lib/faraday/adapter/net_http.rb

Since Async does persistent connections, Net HTTP Persistent adapter could also be helpful to see:
https://github.com/lostisland/faraday/blob/f6130995eb4db72a46d612f5d8e212b4dd2cf5b9/lib/faraday/adapter/net_http_persistent.rb

Proxy parameter is available in env.request[:proxy], so it is expected to be customisable per request.
https://www.rubydoc.info/gems/faraday/Faraday/Env#request-instance_method

I see that Async::HTTP::Internet is used in the adapter but it does not have proxy parameters. And Async::HTTP::Proxy is a lower-level class. That means the underlying library will probably require changes before adapter support can be implemented.

@ioquatix
Copy link
Member

Thanks for the links I will take a look.

ioquatix added a commit that referenced this issue Jun 17, 2021
ioquatix added a commit that referenced this issue Jun 17, 2021
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