This project is archived and is in readonly mode.
ActiveResource & HTTP proxy support
Reported by Sébastien Dabet | March 5th, 2009 @ 09:43 AM | in 2.3.4
The ActiveResource::Connection#help method does not support HTTP proxy connections.
Fix:
def http
http = http_agent.new(@site.host, @site.port)
http.use_ssl = @site.is_a?(URI::HTTPS)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl
http.read_timeout = @timeout if @timeout # If timeout is not set, the default Net::HTTP timeout (60s) is used.
http
end
def http_agent
unless @http_agent
proxy = ENV['HTTP_PROXY'] || ENV['http_proxy']
if proxy
proxy = URI.parse(ENV['HTTP_PROXY'] || ENV['http_proxy'])
@http_agent = Net::HTTP::Proxy(proxy.host,proxy.port)
else
@http_agent = Net::HTTP
end
end
@http_agent
end
Comments and changes to this ticket
-
Marshall Huss May 15th, 2009 @ 07:40 PM
I was just working on a fix for this. Would it be more desirable to use the environment settings or let it be explicitly set in the ActiveResource model?
-
Marshall Huss May 18th, 2009 @ 04:16 AM
Here's my patch to add proxy support. I made it work as close to the site attribute as possible. In reference to the paste-in-patch, I believe if the user wants to use the environmental http_proxy variable then they can explicitly set it.
class Foo < ActiveResource::Base
self.site = "http://site.local" self.proxy = "http://user:password@proxy.local:10000" endIf you have any suggestions/issues let me know and I can make the changes.
-
Marshall Huss May 18th, 2009 @ 05:36 PM
Found an issue with the patch and it will not work, will submit a new one asap.
-
John Wunder May 18th, 2009 @ 06:55 PM
Thanks Marshall, this will really help us out at work since we're behind a proxy, been missing it.
-
Marshall Huss May 19th, 2009 @ 12:03 AM
I added some more tests and fixed a bug.
class Foo < ActiveResource::Base self.site = "http://localhost" self.proxy = "http://user:password@proxy.local:8080" end
-
Geoff May 19th, 2009 @ 04:05 PM
+1 on this
I work in one of those lovely corporate settings where this would be really useful.
-
Rizwan Reza August 8th, 2009 @ 09:32 PM
not reproducible
-1 The patch doesn't apply... neither 2-3-stable nor master.
-
Marshall Huss August 8th, 2009 @ 10:12 PM
- Tag changed from active_resource, proxy to active_resource, bugmash, proxy
-
Jeremy Kemper August 8th, 2009 @ 11:42 PM
- State changed from new to committed
- Milestone changed from 2.x to 2.3.4
2-3-stable: 791c3880393c671c3b101ea9b12836070df7a64d
master: 4d1552810f631898c3d7f758454c92ca35a8cb26
-
Marshall Huss August 9th, 2009 @ 12:37 AM
- Tag changed from active_resource, bugmash, proxy to active_resource, proxy
-
Marshall Huss August 9th, 2009 @ 05:18 AM
(from [791c3880393c671c3b101ea9b12836070df7a64d]) HTTP proxy support
[#2133 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/791c3880393c671c3b101ea9b12836... -
Marshall Huss August 9th, 2009 @ 05:18 AM
(from [4d1552810f631898c3d7f758454c92ca35a8cb26]) HTTP proxy support
[#2133 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/4d1552810f631898c3d7f758454c92...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 2133 ActiveResource & HTTP proxy support [#2133 state:committed]
- 2133 ActiveResource & HTTP proxy support [#2133 state:committed]