Skip to content

Commit

Permalink
Properly handle $no_proxy/localhost in a user's environment.
Browse files Browse the repository at this point in the history
When a user has $http(s)_proxy defined, vmc will often fail to target a local
VCAP environment. The cause of this was that vmc was looking directly to the
http_proxy or https_proxy environment variables without checking that the host
was not in $no_proxy, nor checking whether the target resolved to localhost.
Both of these checks are handled via the open-uri module's find_proxy() method.
  • Loading branch information
David Trowbridge authored and Patrick Bozeman committed May 17, 2011
1 parent d53278c commit 4bc4f95
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/vmc/client.rb
Expand Up @@ -11,6 +11,7 @@

require 'rubygems'
require 'json/pure'
require 'open-uri'

require File.expand_path('../const', __FILE__)

Expand Down Expand Up @@ -374,11 +375,7 @@ def request(method, path, content_type = nil, payload = nil, headers = {})
end

def perform_http_request(req)
if URI::HTTPS === URI.parse(req[:url])
RestClient.proxy = ENV['https_proxy'] || ENV['http_proxy']
else
RestClient.proxy = ENV['http_proxy']
end
RestClient.proxy = URI.parse(req[:url]).find_proxy()

# Setup tracing if needed
unless trace.nil?
Expand Down

0 comments on commit 4bc4f95

Please sign in to comment.