faraday-gzip 3.0.0-java → 3.0.2-java
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/lib/faraday/gzip/version.rb +1 -1
- metadata +3 -9
- data/spec/faraday/gzip/middleware_spec.rb +0 -179
- data/spec/faraday/gzip/version_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a3411acdc3965fb039bde10d5630f157fb424fa927a6246101d9e7b78d8fe66
|
4
|
+
data.tar.gz: 8cb56773469ef2043a28d0ad7f0602f8df51aa6e92f245e5c73e5cfea656a967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c9e2ed168eb9697a3451aba55980dfc8c200b8134ade4d410c0f208a8238e36f7e643e5aa61ff15201b186d458232cda5748a287e32c904fcd73be83a9b5591
|
7
|
+
data.tar.gz: a9db00cb41836a55b4d244b8137949d3a0b1b2f2c67b07233f7d923ff58e01e8d3d0757e402b0531752bb362dc0ac5b09f2bc7da686ef8fb1ebed904a76433ba
|
data/CHANGELOG.md
CHANGED
data/lib/faraday/gzip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-gzip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Ilya Krukowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,16 +158,13 @@ files:
|
|
158
158
|
- lib/faraday/gzip.rb
|
159
159
|
- lib/faraday/gzip/middleware.rb
|
160
160
|
- lib/faraday/gzip/version.rb
|
161
|
-
- spec/faraday/gzip/middleware_spec.rb
|
162
|
-
- spec/faraday/gzip/version_spec.rb
|
163
|
-
- spec/spec_helper.rb
|
164
161
|
homepage: https://github.com/bodrovis/faraday-gzip
|
165
162
|
licenses:
|
166
163
|
- MIT
|
167
164
|
metadata:
|
168
165
|
bug_tracker_uri: https://github.com/bodrovis/faraday-gzip/issues
|
169
166
|
changelog_uri: https://github.com/bodrovis/faraday-gzip/blob/master/CHANGELOG.md
|
170
|
-
documentation_uri: http://www.rubydoc.info/gems/faraday-gzip/3.0.
|
167
|
+
documentation_uri: http://www.rubydoc.info/gems/faraday-gzip/3.0.2
|
171
168
|
homepage_uri: https://github.com/bodrovis/faraday-gzip
|
172
169
|
source_code_uri: https://github.com/bodrovis/faraday-gzip
|
173
170
|
rubygems_mfa_required: 'true'
|
@@ -180,9 +177,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
177
|
- - ">="
|
181
178
|
- !ruby/object:Gem::Version
|
182
179
|
version: '3.0'
|
183
|
-
- - "<"
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
version: '4'
|
186
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
181
|
requirements:
|
188
182
|
- - ">="
|
@@ -1,179 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe Faraday::Gzip::Middleware do
|
4
|
-
require 'brotli' if Faraday::Gzip::Middleware::BROTLI_SUPPORTED
|
5
|
-
|
6
|
-
subject(:middleware) do
|
7
|
-
described_class.new(->(env) { Faraday::Response.new(env) })
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:headers) { {} }
|
11
|
-
|
12
|
-
def process(body, content_type = nil, options = {})
|
13
|
-
env = {
|
14
|
-
body: body, request: options,
|
15
|
-
request_headers: Faraday::Utils::Headers.new,
|
16
|
-
response_headers: Faraday::Utils::Headers.new(headers)
|
17
|
-
}
|
18
|
-
env[:response_headers]['content-type'] = content_type if content_type
|
19
|
-
yield(env) if block_given?
|
20
|
-
middleware.call(env)
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'when request' do
|
24
|
-
it 'sets the Accept-Encoding request header' do
|
25
|
-
env = process('').env
|
26
|
-
encodings = Faraday::Gzip::Middleware::BROTLI_SUPPORTED ? 'gzip,deflate,br' : 'gzip,deflate'
|
27
|
-
expect(env[:request_headers][:accept_encoding]).to eq(encodings)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'doesnt overwrite existing Accept-Encoding request header' do
|
31
|
-
env = process('') do |e|
|
32
|
-
e[:request_headers][:accept_encoding] = 'zopfli'
|
33
|
-
end.env
|
34
|
-
expect(env[:request_headers][:accept_encoding]).to eq('zopfli')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when response' do
|
39
|
-
let(:uncompressed_body) do
|
40
|
-
'<html><head><title>Rspec</title></head><body>Hello, spec!</body></html>'
|
41
|
-
end
|
42
|
-
let(:empty_body) { '' }
|
43
|
-
let(:gzipped_body) do
|
44
|
-
io = StringIO.new
|
45
|
-
gz = Zlib::GzipWriter.new(io)
|
46
|
-
gz.write(uncompressed_body)
|
47
|
-
gz.close
|
48
|
-
res = io.string
|
49
|
-
res.force_encoding('BINARY')
|
50
|
-
res
|
51
|
-
end
|
52
|
-
let(:deflated_body) do
|
53
|
-
Zlib::Deflate.deflate(uncompressed_body)
|
54
|
-
end
|
55
|
-
let(:raw_deflated_body) do
|
56
|
-
z = Zlib::Deflate.new(Zlib::DEFAULT_COMPRESSION, -Zlib::MAX_WBITS)
|
57
|
-
compressed_body = z.deflate(uncompressed_body, Zlib::FINISH)
|
58
|
-
z.close
|
59
|
-
compressed_body
|
60
|
-
end
|
61
|
-
|
62
|
-
if Faraday::Gzip::Middleware::BROTLI_SUPPORTED
|
63
|
-
let(:brotlied_body) do
|
64
|
-
Brotli.deflate(uncompressed_body)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
shared_examples 'compressed response' do
|
69
|
-
it 'uncompresses the body' do
|
70
|
-
expect(process(body).body).to eq(uncompressed_body)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'sets the Content-Length' do
|
74
|
-
expect(process(body).headers['Content-Length']).to eq(uncompressed_body.length)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'removes the Content-Encoding' do
|
78
|
-
expect(process(body).headers['Content-Encoding']).to be_nil
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when gzipped response' do
|
83
|
-
let(:body) { gzipped_body }
|
84
|
-
let(:headers) { { 'Content-Encoding' => 'gzip', 'Content-Length' => body.length } }
|
85
|
-
|
86
|
-
it_behaves_like 'compressed response'
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'when deflated response' do
|
90
|
-
let(:body) { deflated_body }
|
91
|
-
let(:headers) { { 'Content-Encoding' => 'deflate', 'Content-Length' => body.length } }
|
92
|
-
|
93
|
-
it_behaves_like 'compressed response'
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'when raw deflated response' do
|
97
|
-
let(:body) { raw_deflated_body }
|
98
|
-
let(:headers) { { 'Content-Encoding' => 'deflate', 'Content-Length' => body.length } }
|
99
|
-
|
100
|
-
it_behaves_like 'compressed response'
|
101
|
-
end
|
102
|
-
|
103
|
-
if Faraday::Gzip::Middleware::BROTLI_SUPPORTED
|
104
|
-
context 'when brotlied response' do
|
105
|
-
let(:body) { brotlied_body }
|
106
|
-
let(:headers) { { 'Content-Encoding' => 'br', 'Content-Length' => body.length } }
|
107
|
-
|
108
|
-
it_behaves_like 'compressed response'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'when empty response' do
|
113
|
-
let(:body) { empty_body }
|
114
|
-
let(:headers) { { 'Content-Encoding' => 'gzip', 'Content-Length' => body.length } }
|
115
|
-
|
116
|
-
it 'sets the Content-Length' do
|
117
|
-
expect(process(body).headers['Content-Length']).to eq(empty_body.length)
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'removes the Content-Encoding' do
|
121
|
-
expect(process(body).headers['Content-Encoding']).to be_nil
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'when nil response' do
|
126
|
-
let(:body) { nil }
|
127
|
-
let(:headers) { { 'Content-Encoding' => 'gzip', 'Content-Length' => 0 } }
|
128
|
-
|
129
|
-
it 'sets the Content-Length' do
|
130
|
-
expect(process(body).headers['Content-Length']).to eq(0)
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'removes the Content-Encoding' do
|
134
|
-
expect(process(body).headers['Content-Encoding']).to be_nil
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'when identity response' do
|
139
|
-
let(:body) { uncompressed_body }
|
140
|
-
|
141
|
-
it 'does not modify the body' do
|
142
|
-
expect(process(body).body).to eq(uncompressed_body)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
context 'when unsupported encoding response' do
|
147
|
-
let(:body) { 'unsupported' }
|
148
|
-
let(:headers) { { 'Content-Encoding' => 'unsupported' } }
|
149
|
-
|
150
|
-
it 'does not modify the body' do
|
151
|
-
expect(process(body).body).to eq(body)
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'preserves the Content-Encoding header' do
|
155
|
-
expect(process(body).headers['Content-Encoding']).to eq('unsupported')
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
context 'when no Content-Encoding header' do
|
160
|
-
let(:body) { uncompressed_body }
|
161
|
-
let(:headers) { {} }
|
162
|
-
|
163
|
-
it 'does not modify the body' do
|
164
|
-
expect(process(body).body).to eq(uncompressed_body)
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'does not add a Content-Encoding header' do
|
168
|
-
expect(process(body).headers['Content-Encoding']).to be_nil
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
context 'when Content-Length is a string' do
|
173
|
-
let(:body) { gzipped_body }
|
174
|
-
let(:headers) { { 'Content-Encoding' => 'gzip', 'Content-Length' => body.length.to_s } }
|
175
|
-
|
176
|
-
it_behaves_like 'compressed response'
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
require 'simplecov'
|
5
|
-
|
6
|
-
SimpleCov.start do
|
7
|
-
add_filter 'spec/'
|
8
|
-
add_filter '.github/'
|
9
|
-
end
|
10
|
-
|
11
|
-
require_relative '../lib/faraday/gzip'
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
# Enable flags like --only-failures and --next-failure
|
15
|
-
config.example_status_persistence_file_path = '.rspec_status'
|
16
|
-
|
17
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
18
|
-
config.disable_monkey_patching!
|
19
|
-
|
20
|
-
config.expect_with :rspec do |c|
|
21
|
-
c.syntax = :expect
|
22
|
-
end
|
23
|
-
|
24
|
-
config.order = :random
|
25
|
-
end
|