Skip to content

Commit

Permalink
Clean up proxy support
Browse files Browse the repository at this point in the history
Also add support for git http.proxy config.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
  • Loading branch information
stephencelis committed Aug 7, 2012
1 parent f899ea4 commit c077c95
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/ghi/client.rb
Expand Up @@ -54,6 +54,8 @@ def links
:patch => Net::HTTP::Patch,
:delete => Net::HTTP::Delete
}
HOST = 'api.github.com'
PORT = 443

attr_reader :username, :password
def initialize username = nil, password = nil
Expand Down Expand Up @@ -103,10 +105,12 @@ def request method, path, options
req.basic_auth username, password if username && password

proxy = ENV['https_proxy'] || ENV['http_proxy']
proxy ||= `git config http.proxy`.chomp
if proxy
http = Net::HTTP::Proxy(URI.parse(proxy).host, URI.parse(proxy).port).new 'api.github.com', 443
proxy = URI.parse proxy
http = Net::HTTP::Proxy(proxy.host, proxy.port).new HOST, PORT
else
http = Net::HTTP.new 'api.github.com', 443
http = Net::HTTP.new HOST, PORT
end

http.use_ssl = true
Expand Down

0 comments on commit c077c95

Please sign in to comment.