diff --git a/lib/savon/request.rb b/lib/savon/request.rb index bb4ea5fc..5e9ab8b5 100644 --- a/lib/savon/request.rb +++ b/lib/savon/request.rb @@ -9,6 +9,7 @@ def initialize(globals, http_request = nil) end def build + configure_request configure_timeouts configure_ssl @@ -17,6 +18,10 @@ def build private + def configure_request + @http_request.proxy = @globals[:proxy] if @globals.include? :proxy + end + def configure_timeouts @http_request.open_timeout = @globals[:open_timeout] if @globals.include? :open_timeout @http_request.read_timeout = @globals[:read_timeout] if @globals.include? :read_timeout diff --git a/spec/savon/request_spec.rb b/spec/savon/request_spec.rb index e07e8ae8..c6a7ced7 100644 --- a/spec/savon/request_spec.rb +++ b/spec/savon/request_spec.rb @@ -16,6 +16,20 @@ def new_wsdl_request expect(wsdl_request.build).to be_an(HTTPI::Request) end + describe "proxy" do + it "is set when specified" do + globals.proxy("http://proxy.example.com") + http_request.expects(:proxy=).with("http://proxy.example.com") + + new_wsdl_request.build + end + + it "is not set otherwise" do + http_request.expects(:proxy=).never + new_wsdl_request.build + end + end + describe "open timeout" do it "is set when specified" do globals.open_timeout(22)