Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Expose connection params so proxy may be set
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanensari committed Jul 14, 2015
1 parent c1c0c7c commit e4b9cd6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/jeff.rb
Expand Up @@ -105,11 +105,11 @@ def self.included(base)

# A reusable HTTP connection.
def connection
@connection ||= Excon.new(aws_endpoint,
headers: { "User-Agent" => self.class.user_agent },
expects: 200,
omit_default_port: true
)
@connection ||= Excon.new(aws_endpoint, connection_params)
end

def connection_params
@connection_params ||= default_connection_params
end

attr_accessor :aws_endpoint
Expand Down Expand Up @@ -145,6 +145,14 @@ def #{method}(options = {})

private

def default_connection_params
{
headers: { "User-Agent" => self.class.user_agent },
expects: 200,
omit_default_port: true
}
end

def add_md5_digest(options)
return unless options.key?(:body)
md5 = Content.new(options[:body]).md5
Expand Down
9 changes: 9 additions & 0 deletions test/test_jeff.rb
Expand Up @@ -126,4 +126,13 @@ def test_gets_from_an_actual_endpoint
res = @client.post(query: { "Action" => "GetServiceStatus" })
assert_equal 200, res.status
end

def test_has_no_proxy_by_default
refute @client.connection.proxy
end

def test_sets_proxy
@client.connection_params.store(:proxy, "http://my.proxy:4321")
assert @client.connection.proxy
end
end

0 comments on commit e4b9cd6

Please sign in to comment.