restforce 6.2.0 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f7a29ac5ff461f9db1f386570aceebfa30244ec519ccd26320e6255cdaddc57
4
- data.tar.gz: 556b7407db043fe2a3d5e9fe9183be767693cacacd31fe8ac492aca9fd195194
3
+ metadata.gz: 5b88661434383f16571c2b240a9c2482035058a34adadfe39a86b4fecb7382ca
4
+ data.tar.gz: bb4ac026f9b7fbd43f7b5237760e341d9d351c5433ca19009daa24794be251f0
5
5
  SHA512:
6
- metadata.gz: '0585185aed0e16fea289b78ccb16122306186901195daa5d2b323dedcbb4999e5760910e5d8ceb7966424b8e4d636d20c92f61bcc283f1fe75de3857ca35d68b'
7
- data.tar.gz: b17650d7d7984b0b412c2c678a49d61d8d69fc961454aad313c4a8c1ed25ea49f04d68b1d658bb4464b4514f81118f1e69392465a541f0431571d60096e9d9c0
6
+ metadata.gz: da66afd00a69c078e3883f76ae0039d2742911de7b0ca8cb6b14b15801695973a25deec7e71fede838d9193a60224510eee625b72b06c827d6f0467111757023
7
+ data.tar.gz: 86cad2e9fecc5610dae221bdec91a8a1868b9333d7aa552b5fb21af928352c73cad50ea64f63f26cd61ea50048784f5c3dad20b04d798c70aee2f0295c1721bd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 6.2.1 (Jan 18 2023)
2
+
3
+ * When a response claims to be gzipped but isn't, return the body as it is and don't explode (@timrogers)
4
+
1
5
  # 6.2.0 (Jan 18 2023)
2
6
 
3
7
  * Add support for `faraday` v2.7.x (@timrogers)
data/README.md CHANGED
@@ -27,7 +27,7 @@ Features include:
27
27
 
28
28
  Add this line to your application's Gemfile:
29
29
 
30
- gem 'restforce', '~> 6.2.0'
30
+ gem 'restforce', '~> 6.2.1'
31
31
 
32
32
  And then execute:
33
33
 
@@ -28,6 +28,10 @@ module Restforce
28
28
  # Internal: Decompresses a gzipped string.
29
29
  def decompress(body)
30
30
  Zlib::GzipReader.new(StringIO.new(body)).read
31
+ rescue Zlib::GzipFile::Error
32
+ # We thought the response was gzipped, but it wasn't. Return the original
33
+ # body back to the caller. See https://github.com/restforce/restforce/issues/761.
34
+ body
31
35
  end
32
36
  end
33
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Restforce
4
- VERSION = '6.2.0'
4
+ VERSION = '6.2.1'
5
5
  end
@@ -17,38 +17,73 @@ describe Restforce::Middleware::Gzip do
17
17
  describe '.call' do
18
18
  subject { lambda { middleware.call(env) } }
19
19
 
20
- before do
21
- app.should_receive(:on_complete) { middleware.on_complete(env) }
22
- app.should_receive(:call) do
23
- env[:body] = gzip fixture('sobject/query_success_response')
24
- env[:response_headers]['Content-Encoding'] = 'gzip'
25
- app
20
+ context 'when the response is gzipped' do
21
+ before do
22
+ app.should_receive(:on_complete) { middleware.on_complete(env) }
23
+ app.should_receive(:call) do
24
+ env[:body] = gzip fixture('sobject/query_success_response')
25
+ env[:response_headers]['Content-Encoding'] = 'gzip'
26
+ app
27
+ end
28
+ end
29
+
30
+ it 'decompresses the body' do
31
+ expect { subject.call }.to change {
32
+ env[:body]
33
+ }.to(fixture('sobject/query_success_response'))
34
+ end
35
+
36
+ context 'when :compress is false' do
37
+ it 'does not set request headers to ask the response to be compressed' do
38
+ expect { subject.call }.
39
+ not_to(change { env[:request_headers]['Accept-Encoding'] })
40
+ end
26
41
  end
27
- end
28
42
 
29
- it 'decompresses the body' do
30
- expect { subject.call }.to change {
31
- env[:body]
32
- }.to(fixture('sobject/query_success_response'))
43
+ context 'when :compress is true' do
44
+ before do
45
+ options[:compress] = true
46
+ end
47
+
48
+ it 'sets request headers to ask the response to be compressed' do
49
+ expect { subject.call }.to change {
50
+ env[:request_headers]['Accept-Encoding']
51
+ }.to('gzip')
52
+ end
53
+ end
33
54
  end
34
55
 
35
- context 'when :compress is false' do
36
- it {
37
- expect { subject.call }.
38
- not_to(change { env[:request_headers]['Accept-Encoding'] })
39
- }
56
+ context 'when the response claims to be gzipped, but is not' do
57
+ before do
58
+ app.should_receive(:on_complete) { middleware.on_complete(env) }
59
+ app.should_receive(:call) do
60
+ env[:body] = fixture('sobject/query_success_response')
61
+ env[:response_headers]['Content-Encoding'] = 'gzip'
62
+ app
63
+ end
64
+ end
65
+
66
+ it 'does not decompress the body' do
67
+ expect { subject.call }.to change {
68
+ env[:body]
69
+ }.to(fixture('sobject/query_success_response'))
70
+ end
40
71
  end
41
72
 
42
- context 'when :compress is true' do
73
+ context 'when the response does not even claim to be gzipped' do
43
74
  before do
44
- options[:compress] = true
75
+ app.should_receive(:on_complete) { middleware.on_complete(env) }
76
+ app.should_receive(:call) do
77
+ env[:body] = fixture('sobject/query_success_response')
78
+ app
79
+ end
45
80
  end
46
81
 
47
- it {
82
+ it 'does not decompress the body' do
48
83
  expect { subject.call }.to change {
49
- env[:request_headers]['Accept-Encoding']
50
- }.to('gzip')
51
- }
84
+ env[:body]
85
+ }.to(fixture('sobject/query_success_response'))
86
+ end
52
87
  end
53
88
  end
54
89
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0
4
+ version: 6.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Rogers