hack for HTTP servers that use raw DEFLATE compression. Closes #49

This commit is contained in:
Julien Kirch 2011-06-05 00:35:46 +02:00
parent 3e7949d08f
commit 979c502b20
2 changed files with 8 additions and 1 deletions

View File

@ -10,6 +10,7 @@
- make gemspec Rubygems 1.8 compatible (patch provided by David Backeus)
- added RestClient.reset_before_execution_procs (patch provided by Cloudify)
- added PATCH method (patch provided by Jeff Remer)
- hack for HTTP servers that use raw DEFLATE compression, see http://www.ruby-forum.com/topic/136825 (path provided by James Reeves)
# 1.6.1

View File

@ -236,7 +236,13 @@ module RestClient
elsif content_encoding == 'gzip'
Zlib::GzipReader.new(StringIO.new(body)).read
elsif content_encoding == 'deflate'
Zlib::Inflate.new.inflate body
begin
Zlib::Inflate.new.inflate body
rescue Zlib::DataError
# No luck with Zlib decompression. Let's try with raw deflate,
# like some broken web servers do.
Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate body
end
else
body
end