Skip to content

Commit

Permalink
Add headers configuration to WSDLRequest#build (#753)
Browse files Browse the repository at this point in the history
e.g. some proxy servers may require

```ruby
{ "Proxy-Authorization" => "Basic base64EncodedAuthHash" }
```

as part of the headers.

In particular we ran into issues with using the Proximo Heroku Add-On.

This fixes #750 and may be considered as a late addition to #378.
  • Loading branch information
janraasch authored and pcai committed Aug 22, 2017
1 parent 2bb95b4 commit 2bd15ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/savon/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ class WSDLRequest < HTTPRequest
def build
configure_proxy
configure_timeouts
configure_headers
configure_ssl
configure_auth
configure_redirect_handling

@http_request
end

private

def configure_headers
@http_request.headers = @globals[:headers] if @globals.include? :headers
end
end

class SOAPRequest < HTTPRequest
Expand Down
14 changes: 14 additions & 0 deletions spec/savon/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ def new_wsdl_request
expect(wsdl_request.build).to be_an(HTTPI::Request)
end

describe "headers" do
it "are set when specified" do
globals.headers("Proxy-Authorization" => "Basic auth")
configured_http_request = new_wsdl_request.build

expect(configured_http_request.headers["Proxy-Authorization"]).to eq("Basic auth")
end

it "are not set otherwise" do
configured_http_request = new_wsdl_request.build
expect(configured_http_request.headers).to_not include("Proxy-Authorization")
end
end

describe "proxy" do
it "is set when specified" do
globals.proxy("http://proxy.example.com")
Expand Down

0 comments on commit 2bd15ef

Please sign in to comment.