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 string handling is not uniform #150

Closed
j-manu opened this issue May 1, 2012 · 4 comments
Closed

Proxy string handling is not uniform #150

j-manu opened this issue May 1, 2012 · 4 comments
Labels

Comments

@j-manu
Copy link

j-manu commented May 1, 2012

If you use the proxy option as documented, an exception will be raised. For the proxy option to work, you need to pass
:proxy => URI.parse(proxy_string). Is this an error in documentation bug or a bug in code ?

/Users/manu/.rvm/gems/ruby-1.9.3-p125@pf3/gems/faraday-0.8.0/lib/faraday/adapter/net_http.rb:78:in `net_http_connection': undefined method `host' for "http://example.org/":String (NoMethodError)
        from /Users/manu/.rvm/gems/ruby-1.9.3-p125@pf3/gems/faraday-0.8.0/lib/faraday/adapter/net_http.rb:27:in `call'
        from /Users/manu/.rvm/gems/ruby-1.9.3-p125@pf3/gems/faraday-0.8.0/lib/faraday/response.rb:8:in `call'
        from /Users/manu/.rvm/gems/ruby-1.9.3-p125@pf3/gems/faraday-0.8.0/lib/faraday/response/logger.rb:20:in `call'
        from /Users/manu/.rvm/gems/ruby-1.9.3-p125@pf3/gems/faraday-0.8.0/lib/faraday/request/url_encoded.rb:14:in `call'
        from /Users/manu/.rvm/gems/ruby-1.9.3-p125@pf3/gems/faraday-0.8.0/lib/faraday/connection.rb:226:in `run_request'
        from /Users/manu/.rvm/gems/ruby-1.9.3-p125@pf3/gems/faraday-0.8.0/lib/faraday/connection.rb:87:in `get'
        from test.rb:13:in `<main>'
@technoweenie
Copy link
Member

Well, according to you it's a doc bug :) I think this goes with #136. We need to be stricter about validating these multi-level hashes, and more consistent about using them in adapters.

Were you getting the same error with 0.7.6?

@j-manu
Copy link
Author

j-manu commented May 1, 2012

I was leaning more towards bug in code because it is supported when calling connection directly :)

#works

con = Faraday::Connection.new('http://sushi.com', :proxy => "http://localhost:8080")
con.get '/nigiri/sake.json'

This piece of code - https://github.com/technoweenie/faraday/blob/master/lib/faraday/connection.rb#L153 - is probably responsible for that.

I haven't tried it on 0.7.6

@mislav mislav closed this as completed in 5ddf788 May 6, 2012
@mislav
Copy link
Contributor

mislav commented May 6, 2012

Thanks for reporting. Right now I've removed the faulty example from Readme. I hope you don't actually need a per-request proxy setting. It's much easier to set it per-connection.

We're going to improve passing such options around. Follow #136 for updates

@j-manu
Copy link
Author

j-manu commented May 7, 2012

No only per connection. I was writing some throwaway code which dealt with proxies and grabbed the sample code and modified. You should probably add an example which shows proxy being used at connection level. I knew proxy option was possible at connection level only because I searched issues.

mislav added a commit that referenced this issue Nov 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants