Skip to content

Commit

Permalink
fix gzip for ruby 1.8
Browse files Browse the repository at this point in the history
Use Zlib::Inflate.new with the magical argument to create a gunzipper
instead of using a StringIO. This lets us avoid the need to set an
encoding on the StringIO on ruby 1.9
  • Loading branch information
danielsdeleo committed Dec 19, 2011
1 parent 08d26bd commit ef6166f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion chef/lib/chef/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# limitations under the License.
#

require 'zlib'
require 'net/https'
require 'uri'
require 'chef/json_compat'
Expand Down Expand Up @@ -264,7 +265,7 @@ def decompress_body(response)
case response[CONTENT_ENCODING]
when GZIP
Chef::Log.debug "decompressing gzip response"
Zlib::GzipReader.new(StringIO.new(response.body), encoding: "ASCII-8BIT").read
Zlib::Inflate.new(Zlib::MAX_WBITS + 16).inflate(response.body)
when DEFLATE
Chef::Log.debug "decompressing deflate response"
Zlib::Inflate.inflate(response.body)
Expand Down

0 comments on commit ef6166f

Please sign in to comment.