Skip to content

Commit

Permalink
Add support for HTTP Basic Authentication on the HTTP proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred committed Mar 12, 2012
1 parent 3cf2c07 commit e32d0bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/rest/request.rb
Expand Up @@ -82,7 +82,7 @@ def proxy_settings
end

def proxy
@proxy ||= Net::HTTP.Proxy(proxy_settings.host, proxy_settings.port)
@proxy ||= Net::HTTP.Proxy(proxy_settings.host, proxy_settings.port, proxy_settings.user, proxy_settings.password)
end

def http_request
Expand Down
10 changes: 6 additions & 4 deletions test/rest_request_test.rb
Expand Up @@ -178,16 +178,18 @@
request.http_proxy.should. == 'http://localhost'
ENV.delete('HTTP_PROXY')

ENV['http_proxy'] = 'http://192.168.0.1'
request.http_proxy.should. == 'http://192.168.0.1'
ENV['http_proxy'] = 'http://rob:secret@192.168.0.1:21'
request.http_proxy.should. == 'http://rob:secret@192.168.0.1:21'
ENV.delete('http_proxy')
end

it "parses the http proxy settings" do
request = REST::Request.new(:get, URI.parse(''))
request.stubs(:http_proxy).returns('http://192.168.0.1:80')
request.stubs(:http_proxy).returns('http://rob:secret@192.168.0.1:21')
request.proxy_settings.host.should == '192.168.0.1'
request.proxy_settings.port.should == 80
request.proxy_settings.port.should == 21
request.proxy_settings.user.should == 'rob'
request.proxy_settings.password.should == 'secret'
end

it "should use a proxy when the http_proxy" do
Expand Down

0 comments on commit e32d0bd

Please sign in to comment.