From 41eaf98f8ddf47de3930a9b302218470b67ddb89 Mon Sep 17 00:00:00 2001 From: Jarek Lipski Date: Sun, 8 Sep 2024 14:16:10 +0200 Subject: [PATCH 1/3] bump rest-client to 2.1.0 --- chargebee.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chargebee.gemspec b/chargebee.gemspec index b653fb7..4eb3232 100644 --- a/chargebee.gemspec +++ b/chargebee.gemspec @@ -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') From e66f2d61cbce7d793d37fd00f8833bc25ba2743d Mon Sep 17 00:00:00 2001 From: Jarek Lipski Date: Sun, 8 Sep 2024 20:03:40 +0200 Subject: [PATCH 2/3] decode manually --- lib/chargebee/rest.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/chargebee/rest.rb b/lib/chargebee/rest.rb index a35956a..7b51ef5 100644 --- a/lib/chargebee/rest.rb +++ b/lib/chargebee/rest.rb @@ -55,7 +55,12 @@ def self.request(method, url, env, params=nil, headers={}) 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 + rcode = response.code begin resp = JSON.parse(rbody) From 2aca08fdafeeb3c6128fb332a9dfd1a349a221f8 Mon Sep 17 00:00:00 2001 From: Jarek Lipski Date: Sun, 8 Sep 2024 20:08:08 +0200 Subject: [PATCH 3/3] formatting --- lib/chargebee/rest.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/chargebee/rest.rb b/lib/chargebee/rest.rb index 7b51ef5..e5db40a 100644 --- a/lib/chargebee/rest.rb +++ b/lib/chargebee/rest.rb @@ -54,14 +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 + 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 rcode = response.code + begin resp = JSON.parse(rbody) rescue Exception => e