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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/restforce/middleware/gzip.rb +4 -0
- data/lib/restforce/version.rb +1 -1
- data/spec/unit/middleware/gzip_spec.rb +57 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b88661434383f16571c2b240a9c2482035058a34adadfe39a86b4fecb7382ca
|
4
|
+
data.tar.gz: bb4ac026f9b7fbd43f7b5237760e341d9d351c5433ca19009daa24794be251f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da66afd00a69c078e3883f76ae0039d2742911de7b0ca8cb6b14b15801695973a25deec7e71fede838d9193a60224510eee625b72b06c827d6f0467111757023
|
7
|
+
data.tar.gz: 86cad2e9fecc5610dae221bdec91a8a1868b9333d7aa552b5fb21af928352c73cad50ea64f63f26cd61ea50048784f5c3dad20b04d798c70aee2f0295c1721bd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -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
|
data/lib/restforce/version.rb
CHANGED
@@ -17,38 +17,73 @@ describe Restforce::Middleware::Gzip do
|
|
17
17
|
describe '.call' do
|
18
18
|
subject { lambda { middleware.call(env) } }
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
73
|
+
context 'when the response does not even claim to be gzipped' do
|
43
74
|
before do
|
44
|
-
|
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[:
|
50
|
-
}.to('
|
51
|
-
|
84
|
+
env[:body]
|
85
|
+
}.to(fixture('sobject/query_success_response'))
|
86
|
+
end
|
52
87
|
end
|
53
88
|
end
|
54
89
|
|