Skip to content

Commit

Permalink
testing gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiii committed Mar 27, 2010
1 parent 41bb3a5 commit 31ab640
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
7 changes: 7 additions & 0 deletions spec/fixtures/gzip/gzip_response_fixture.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class GzipResponseFixture

def self.message
File.read(File.join(File.dirname(__FILE__), 'message.gz'))
end
end

Binary file added spec/fixtures/gzip/message.gz
Binary file not shown.
34 changes: 24 additions & 10 deletions spec/savon/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,35 @@
@response.http.should respond_to(:body)
end

it "should decode gzip request if Content-encoding header is gzip" do
@response = Savon::Response.new http_response_mock(200, body = "Encoded", "OK", 'content-encoding' => 'gzip')
describe "GZipped responses" do

should_decode_body body
it "should be decoded if Content-encoding header is gzip" do
@response = Savon::Response.new http_response_mock(200, body = "Encoded", "OK", 'content-encoding' => 'gzip')

@response.to_xml
end
should_decode_body body

@response.to_xml
end

# header extracted from http://dev.ctor.org/svn/soap4r/trunk/lib/soap/streamHandler.rb
it "should decode gzip request if body starts with gzip header" do
@response = Savon::Response.new http_response_mock(200, body = "\x1f\x8bEncoded", "OK")
# header logic extracted from http://dev.ctor.org/svn/soap4r/trunk/lib/soap/streamHandler.rb
it "should be decoded if body starts with gzip header" do
@response = Savon::Response.new http_response_mock(200, body = "\x1f\x8bEncoded", "OK")

should_decode_body body
should_decode_body body

@response.to_xml
end

@response.to_xml
it "should be decoded when header is set" do
@response = Savon::Response.new http_response_mock(200, GzipResponseFixture.message, "OK", 'content-encoding' => 'gzip')

@response.to_xml.should == "A short gzip encoded message\n"
end
it "should be decoded when header is not set" do
@response = Savon::Response.new http_response_mock(200, GzipResponseFixture.message, "OK")

@response.to_xml.should == "A short gzip encoded message\n"
end
end

def should_decode_body(body)
Expand Down

0 comments on commit 31ab640

Please sign in to comment.