This project is archived and is in readonly mode.

#2133 ✓committed
Sébastien Dabet

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

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>

Referenced by

Pages