Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump rest-client to 2.1.0 #83

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chargebee.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = %w[README.md LICENSE]

s.add_dependency('json_pure', '~> 2.1')
s.add_dependency('rest-client', '>=1.8', '<=2.0.2')
s.add_dependency('rest-client', '>=1.8', '<=2.1.0')
s.add_dependency('cgi', '>=0.1.0', '<1.0.0')
s.add_development_dependency('rspec', '~> 3.0.0')
s.add_development_dependency('mocha')
Expand Down
8 changes: 8 additions & 0 deletions lib/chargebee/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ def self.request(method, url, env, params=nil, headers={})
rescue Exception => e
raise IOError.new("IO Exception when trying to connect to chargebee with url #{opts[:url]} . Reason #{e}",e)
end

rheaders = response.headers

rbody = response.body
if headers.keys.any? { |k| k.downcase == 'accept-encoding' } &&
rheaders[:content_encoding] == 'gzip' && rbody && !rbody.empty?
rbody = Zlib::GzipReader.new(StringIO.new(rbody)).read
end
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually decode the gzipped response if Accept-Encoding header was manually set and response containts Content-Encoding: gzip.


rcode = response.code

begin
resp = JSON.parse(rbody)
rescue Exception => e
Expand Down