Skip to content

Commit

Permalink
fix for issue savonrb#237
Browse files Browse the repository at this point in the history
always set both Content-Type and Content-Length headers.
  • Loading branch information
rubiii committed Nov 5, 2011
1 parent 6b6fe26 commit b394c79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 2 additions & 3 deletions lib/savon/soap/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ def response
def configure(http)
http.url = soap.endpoint
http.body = soap.to_xml
http.headers["Content-Type"] ||= ContentType[soap.version]
http.headers["Content-Length"] ||= soap.to_xml.length.to_s

http.headers["Content-Type"] = ContentType[soap.version]
http.headers["Content-Length"] = soap.to_xml.length.to_s
http
end

Expand Down
16 changes: 10 additions & 6 deletions spec/savon/soap/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@
soap_request.http.headers["Content-Type"].should == Savon::SOAP::Request::ContentType[2]
end

it "does not set the Content-Type header if it's already specified" do
headers = { "Content-Type" => "text/plain" }
soap_request = Savon::SOAP::Request.new HTTPI::Request.new(:headers => headers), soap
soap_request.http.headers["Content-Type"].should == headers["Content-Type"]
end

it "sets the Content-Length header" do
soap_request.http.headers["Content-Length"].should == soap.to_xml.length.to_s
end

it "sets the Content-Length header for every request" do
http = HTTPI::Request.new
soap_request = Savon::SOAP::Request.new(http, soap)
http.headers.should include("Content-Length" => "272")

soap = Savon::SOAP::XML.new Endpoint.soap, [nil, :create_user, {}], :id => 123
soap_request = Savon::SOAP::Request.new(http, soap)
http.headers.should include("Content-Length" => "280")
end
end

describe "#response" do
Expand Down

0 comments on commit b394c79

Please sign in to comment.