baza.rb 0.14.4 → 0.15.0
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/Gemfile +5 -4
- data/Gemfile.lock +49 -64
- data/README.md +1 -1
- data/Rakefile +2 -5
- data/baza.rb.gemspec +10 -13
- data/lib/baza-rb/compress.rb +55 -0
- data/lib/baza-rb/fake.rb +76 -58
- data/lib/baza-rb/version.rb +1 -1
- data/lib/baza-rb.rb +318 -319
- data/pact.json +50 -1
- metadata +12 -53
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4723ea9fe01e74c827c3e8e2f5531d22016e4b80a616bcd9da6f0c5c2ead1b97
|
|
4
|
+
data.tar.gz: e0f61fcac606b88c09ff1e38223d2d2e96a85eafca1563e2965327948662cddd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 409d6505f045704847bbb85e4bfa1320f3971f16fab512d30bde7dfbbeef27f448d58d6b84f6fdce0211aa58c407b766e3b0a2535a0051e90b8df52dd54270f1
|
|
7
|
+
data.tar.gz: 304605659a8bcc8a03e65d53971fb46cdd407c2a542d8fa4d3c31ca9b8bd46faad39c8d0ff300ce189ee72a29b6ecce633243483fc5880d47aa20a1eaefad271
|
data/Gemfile
CHANGED
|
@@ -8,7 +8,7 @@ gemspec
|
|
|
8
8
|
|
|
9
9
|
gem 'activesupport', '~>8.0', require: false
|
|
10
10
|
gem 'base64', '~>0.3', require: false
|
|
11
|
-
gem 'diff-lcs', '1.6.2', require: false
|
|
11
|
+
gem 'diff-lcs', '1.6.2', require: false
|
|
12
12
|
gem 'factbase', '~>0.16', require: false
|
|
13
13
|
gem 'minitest', '~>6.0', require: false
|
|
14
14
|
gem 'minitest-reporters', '~>1.7', require: false
|
|
@@ -17,15 +17,16 @@ gem 'online', '~>0.1', require: false
|
|
|
17
17
|
gem 'os', '~>1.1', require: false
|
|
18
18
|
gem 'pact', '~>1.65', require: false
|
|
19
19
|
gem 'pact-ffi', '0.4.28.0', require: false
|
|
20
|
-
gem 'psych', '5.3.1', require: false
|
|
20
|
+
gem 'psych', '5.3.1', require: false
|
|
21
21
|
gem 'puma', '~>7.0', require: false
|
|
22
22
|
gem 'qbash', '~>0.4', require: false
|
|
23
23
|
gem 'rack', '~>3.1', require: false
|
|
24
24
|
gem 'rackup', '~>2.2', require: false
|
|
25
25
|
gem 'rake', '~>13.2', require: false
|
|
26
26
|
gem 'random-port', '~>0.7', require: false
|
|
27
|
-
gem 'rdoc', '7.1.0', require: false
|
|
27
|
+
gem 'rdoc', '7.1.0', require: false
|
|
28
28
|
gem 'rubocop', '~>1.73', require: false
|
|
29
|
+
gem 'rubocop-elegant', '~>0.5', require: false
|
|
29
30
|
gem 'rubocop-minitest', '~>0.38', require: false
|
|
30
31
|
gem 'rubocop-performance', '~>1.23', require: false
|
|
31
32
|
gem 'rubocop-rake', '~>0.7', require: false
|
|
@@ -35,4 +36,4 @@ gem 'sinatra', '~>4.1', require: false
|
|
|
35
36
|
gem 'wait_for', '~>0.1', require: false
|
|
36
37
|
gem 'webmock', '~>3.24', require: false
|
|
37
38
|
gem 'webrick', '~>1.9', require: false
|
|
38
|
-
gem 'yard', '0.9.
|
|
39
|
+
gem 'yard', '0.9.44', require: false
|
data/Gemfile.lock
CHANGED
|
@@ -2,13 +2,10 @@ PATH
|
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
4
|
baza.rb (0.0.0)
|
|
5
|
-
|
|
5
|
+
base64 (~> 0.3)
|
|
6
6
|
elapsed (~> 0.2)
|
|
7
|
-
faraday (~> 2.13)
|
|
8
|
-
faraday-http-cache (~> 2.5)
|
|
9
|
-
faraday-multipart (~> 1.1)
|
|
10
|
-
faraday-retry (~> 2.3)
|
|
11
7
|
iri (~> 0.11)
|
|
8
|
+
logger (~> 1.6)
|
|
12
9
|
loog (~> 0.6)
|
|
13
10
|
retries (~> 0.0)
|
|
14
11
|
tago (~> 0.2)
|
|
@@ -30,16 +27,16 @@ GEM
|
|
|
30
27
|
securerandom (>= 0.3)
|
|
31
28
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
32
29
|
uri (>= 0.13.1)
|
|
33
|
-
addressable (2.
|
|
30
|
+
addressable (2.9.0)
|
|
34
31
|
public_suffix (>= 2.0.2, < 8.0)
|
|
35
|
-
ansi (1.
|
|
32
|
+
ansi (1.6.0)
|
|
36
33
|
ast (2.4.3)
|
|
37
34
|
awesome_print (1.9.2)
|
|
38
35
|
backtrace (0.4.1)
|
|
39
36
|
base64 (0.3.0)
|
|
40
|
-
bigdecimal (4.
|
|
37
|
+
bigdecimal (4.1.2)
|
|
41
38
|
builder (3.3.0)
|
|
42
|
-
concurrent-ruby (1.3.
|
|
39
|
+
concurrent-ruby (1.3.7)
|
|
43
40
|
connection_pool (3.0.2)
|
|
44
41
|
crack (1.0.1)
|
|
45
42
|
bigdecimal
|
|
@@ -53,12 +50,13 @@ GEM
|
|
|
53
50
|
loog (~> 0.6)
|
|
54
51
|
tago (~> 0.1)
|
|
55
52
|
ellipsized (0.3.0)
|
|
56
|
-
erb (6.0.
|
|
57
|
-
ethon (0.
|
|
53
|
+
erb (6.0.4)
|
|
54
|
+
ethon (0.18.0)
|
|
58
55
|
ffi (>= 1.15.0)
|
|
56
|
+
logger
|
|
59
57
|
expgen (0.1.1)
|
|
60
58
|
parslet
|
|
61
|
-
factbase (0.19.
|
|
59
|
+
factbase (0.19.16)
|
|
62
60
|
backtrace (~> 0.4)
|
|
63
61
|
decoor (~> 0.1)
|
|
64
62
|
ellipsized (~> 0.3)
|
|
@@ -69,31 +67,19 @@ GEM
|
|
|
69
67
|
others (~> 0.1)
|
|
70
68
|
tago (~> 0.1)
|
|
71
69
|
yaml (~> 0.3)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
faraday-http-cache (2.6.1)
|
|
77
|
-
faraday (>= 0.8)
|
|
78
|
-
faraday-multipart (1.2.0)
|
|
79
|
-
multipart-post (~> 2.0)
|
|
80
|
-
faraday-net_http (3.4.2)
|
|
81
|
-
net-http (~> 0.5)
|
|
82
|
-
faraday-retry (2.4.0)
|
|
83
|
-
faraday (~> 2.0)
|
|
84
|
-
ffi (1.17.3-arm64-darwin)
|
|
85
|
-
ffi (1.17.3-x86_64-darwin)
|
|
86
|
-
ffi (1.17.3-x86_64-linux-gnu)
|
|
87
|
-
ffi (1.17.3-x86_64-linux-musl)
|
|
70
|
+
ffi (1.17.4-arm64-darwin)
|
|
71
|
+
ffi (1.17.4-x86_64-darwin)
|
|
72
|
+
ffi (1.17.4-x86_64-linux-gnu)
|
|
73
|
+
ffi (1.17.4-x86_64-linux-musl)
|
|
88
74
|
find_a_port (1.0.1)
|
|
89
75
|
hashdiff (1.2.1)
|
|
90
|
-
i18n (1.
|
|
76
|
+
i18n (1.15.2)
|
|
91
77
|
concurrent-ruby (~> 1.0)
|
|
92
78
|
iri (0.11.8)
|
|
93
|
-
json (2.
|
|
79
|
+
json (2.21.1)
|
|
94
80
|
jsonpath (1.1.5)
|
|
95
81
|
multi_json
|
|
96
|
-
language_server-protocol (3.17.0.
|
|
82
|
+
language_server-protocol (3.17.0.6)
|
|
97
83
|
lint_roller (1.1.0)
|
|
98
84
|
logger (1.7.0)
|
|
99
85
|
loog (0.8.0)
|
|
@@ -102,30 +88,26 @@ GEM
|
|
|
102
88
|
minitest (6.0.6)
|
|
103
89
|
drb (~> 2.0)
|
|
104
90
|
prism (~> 1.5)
|
|
105
|
-
minitest-reporters (1.
|
|
91
|
+
minitest-reporters (1.8.0)
|
|
106
92
|
ansi
|
|
107
93
|
builder
|
|
108
|
-
minitest (>= 5.0)
|
|
94
|
+
minitest (>= 5.0, < 7)
|
|
109
95
|
ruby-progressbar
|
|
110
|
-
multi_json (1.
|
|
111
|
-
|
|
112
|
-
mustermann (3.0.4)
|
|
113
|
-
ruby2_keywords (~> 0.0.1)
|
|
114
|
-
net-http (0.9.1)
|
|
115
|
-
uri (>= 0.11.1)
|
|
96
|
+
multi_json (1.21.1)
|
|
97
|
+
mustermann (3.1.1)
|
|
116
98
|
nio4r (2.7.5)
|
|
117
|
-
nokogiri (1.19.
|
|
99
|
+
nokogiri (1.19.4-arm64-darwin)
|
|
118
100
|
racc (~> 1.4)
|
|
119
|
-
nokogiri (1.19.
|
|
101
|
+
nokogiri (1.19.4-x86_64-darwin)
|
|
120
102
|
racc (~> 1.4)
|
|
121
|
-
nokogiri (1.19.
|
|
103
|
+
nokogiri (1.19.4-x86_64-linux-gnu)
|
|
122
104
|
racc (~> 1.4)
|
|
123
|
-
nokogiri (1.19.
|
|
105
|
+
nokogiri (1.19.4-x86_64-linux-musl)
|
|
124
106
|
racc (~> 1.4)
|
|
125
107
|
online (0.3.0)
|
|
126
108
|
openssl (>= 3)
|
|
127
109
|
timeout (~> 0.4)
|
|
128
|
-
openssl (4.0.
|
|
110
|
+
openssl (4.0.2)
|
|
129
111
|
os (1.1.4)
|
|
130
112
|
others (0.1.1)
|
|
131
113
|
pact (1.67.5)
|
|
@@ -164,7 +146,7 @@ GEM
|
|
|
164
146
|
jsonpath (~> 1.0)
|
|
165
147
|
rainbow (~> 3.1.1)
|
|
166
148
|
string_pattern (~> 2.0)
|
|
167
|
-
parallel (1.
|
|
149
|
+
parallel (2.1.0)
|
|
168
150
|
parser (3.3.11.1)
|
|
169
151
|
ast (~> 2.4.1)
|
|
170
152
|
racc
|
|
@@ -173,10 +155,10 @@ GEM
|
|
|
173
155
|
psych (5.3.1)
|
|
174
156
|
date
|
|
175
157
|
stringio
|
|
176
|
-
public_suffix (7.0.
|
|
177
|
-
puma (7.2.
|
|
158
|
+
public_suffix (7.0.5)
|
|
159
|
+
puma (7.2.1)
|
|
178
160
|
nio4r (~> 2.0)
|
|
179
|
-
qbash (0.8.
|
|
161
|
+
qbash (0.8.4)
|
|
180
162
|
backtrace (> 0)
|
|
181
163
|
elapsed (> 0)
|
|
182
164
|
loog (> 0)
|
|
@@ -187,9 +169,9 @@ GEM
|
|
|
187
169
|
base64 (>= 0.1.0)
|
|
188
170
|
logger (>= 1.6.0)
|
|
189
171
|
rack (>= 3.0.0, < 4)
|
|
190
|
-
rack-proxy (0.
|
|
172
|
+
rack-proxy (0.8.3)
|
|
191
173
|
rack
|
|
192
|
-
rack-session (2.1.
|
|
174
|
+
rack-session (2.1.2)
|
|
193
175
|
base64 (>= 0.1.0)
|
|
194
176
|
rack (>= 3.0.0)
|
|
195
177
|
rack-test (2.2.0)
|
|
@@ -220,7 +202,7 @@ GEM
|
|
|
220
202
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
221
203
|
rspec-support (~> 3.13.0)
|
|
222
204
|
rspec-support (3.13.7)
|
|
223
|
-
rubocop (1.
|
|
205
|
+
rubocop (1.88.2)
|
|
224
206
|
json (~> 2.3)
|
|
225
207
|
language_server-protocol (~> 3.17.0.2)
|
|
226
208
|
lint_roller (~> 1.1.0)
|
|
@@ -231,10 +213,13 @@ GEM
|
|
|
231
213
|
rubocop-ast (>= 1.49.0, < 2.0)
|
|
232
214
|
ruby-progressbar (~> 1.7)
|
|
233
215
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
234
|
-
rubocop-ast (1.
|
|
216
|
+
rubocop-ast (1.50.0)
|
|
235
217
|
parser (>= 3.3.7.2)
|
|
236
218
|
prism (~> 1.7)
|
|
237
|
-
rubocop-
|
|
219
|
+
rubocop-elegant (0.7.1)
|
|
220
|
+
lint_roller (~> 1.1)
|
|
221
|
+
rubocop (~> 1.75)
|
|
222
|
+
rubocop-minitest (0.39.1)
|
|
238
223
|
lint_roller (~> 1.1)
|
|
239
224
|
rubocop (>= 1.75.0, < 2.0)
|
|
240
225
|
rubocop-ast (>= 1.38.0, < 2.0)
|
|
@@ -246,13 +231,12 @@ GEM
|
|
|
246
231
|
lint_roller (~> 1.1)
|
|
247
232
|
rubocop (>= 1.72.1)
|
|
248
233
|
ruby-progressbar (1.13.0)
|
|
249
|
-
ruby2_keywords (0.0.5)
|
|
250
234
|
securerandom (0.4.1)
|
|
251
235
|
simplecov (0.22.0)
|
|
252
236
|
docile (~> 1.1)
|
|
253
237
|
simplecov-html (~> 0.11)
|
|
254
238
|
simplecov_json_formatter (~> 0.1)
|
|
255
|
-
simplecov-cobertura (3.
|
|
239
|
+
simplecov-cobertura (3.2.0)
|
|
256
240
|
rexml
|
|
257
241
|
simplecov (~> 0.19)
|
|
258
242
|
simplecov-html (0.13.2)
|
|
@@ -264,16 +248,16 @@ GEM
|
|
|
264
248
|
rack-protection (= 4.2.1)
|
|
265
249
|
rack-session (>= 2.0.0, < 3)
|
|
266
250
|
tilt (~> 2.0)
|
|
267
|
-
string_pattern (2.
|
|
251
|
+
string_pattern (2.4.0)
|
|
268
252
|
regexp_parser (~> 2.5, >= 2.5.0)
|
|
269
253
|
stringio (3.2.0)
|
|
270
254
|
tago (0.7.0)
|
|
271
255
|
thor (1.5.0)
|
|
272
|
-
tilt (2.
|
|
273
|
-
timeout (0.6.
|
|
256
|
+
tilt (2.8.0)
|
|
257
|
+
timeout (0.6.1)
|
|
274
258
|
tsort (0.2.0)
|
|
275
|
-
typhoeus (1.
|
|
276
|
-
ethon (>= 0.
|
|
259
|
+
typhoeus (1.6.0)
|
|
260
|
+
ethon (>= 0.18.0)
|
|
277
261
|
tzinfo (2.0.6)
|
|
278
262
|
concurrent-ruby (~> 1.0)
|
|
279
263
|
unicode-display_width (3.2.0)
|
|
@@ -281,14 +265,14 @@ GEM
|
|
|
281
265
|
unicode-emoji (4.2.0)
|
|
282
266
|
uri (1.1.1)
|
|
283
267
|
wait_for (0.1.1)
|
|
284
|
-
webmock (3.26.
|
|
268
|
+
webmock (3.26.2)
|
|
285
269
|
addressable (>= 2.8.0)
|
|
286
270
|
crack (>= 0.3.2)
|
|
287
271
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
288
272
|
webrick (1.9.2)
|
|
289
273
|
yaml (0.4.0)
|
|
290
|
-
yard (0.9.
|
|
291
|
-
zeitwerk (2.
|
|
274
|
+
yard (0.9.44)
|
|
275
|
+
zeitwerk (2.8.2)
|
|
292
276
|
|
|
293
277
|
PLATFORMS
|
|
294
278
|
arm64-darwin
|
|
@@ -318,6 +302,7 @@ DEPENDENCIES
|
|
|
318
302
|
random-port (~> 0.7)
|
|
319
303
|
rdoc (= 7.1.0)
|
|
320
304
|
rubocop (~> 1.73)
|
|
305
|
+
rubocop-elegant (~> 0.5)
|
|
321
306
|
rubocop-minitest (~> 0.38)
|
|
322
307
|
rubocop-performance (~> 1.23)
|
|
323
308
|
rubocop-rake (~> 0.7)
|
|
@@ -327,7 +312,7 @@ DEPENDENCIES
|
|
|
327
312
|
wait_for (~> 0.1)
|
|
328
313
|
webmock (~> 3.24)
|
|
329
314
|
webrick (~> 1.9)
|
|
330
|
-
yard (= 0.9.
|
|
315
|
+
yard (= 0.9.44)
|
|
331
316
|
|
|
332
317
|
BUNDLED WITH
|
|
333
318
|
2.6.8
|
data/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Read
|
|
|
19
19
|
[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
|
20
20
|
Make sure your build is green before you contribute
|
|
21
21
|
your pull request. You will need to have
|
|
22
|
-
[Ruby](https://www.ruby-lang.org/en/) 3.
|
|
22
|
+
[Ruby](https://www.ruby-lang.org/en/) 3.3+ and
|
|
23
23
|
[Bundler](https://bundler.io/) installed. Then:
|
|
24
24
|
|
|
25
25
|
```bash
|
data/Rakefile
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
require 'os'
|
|
7
7
|
require 'qbash'
|
|
8
|
-
require 'rubygems'
|
|
9
8
|
require 'rake'
|
|
10
9
|
require 'rake/clean'
|
|
10
|
+
require 'rubygems'
|
|
11
11
|
require 'shellwords'
|
|
12
12
|
|
|
13
13
|
def name
|
|
@@ -34,10 +34,7 @@ desc 'Run them via Ruby, one by one'
|
|
|
34
34
|
task :picks do
|
|
35
35
|
next if OS.windows?
|
|
36
36
|
Dir['lib/**/*.rb'].each do |f|
|
|
37
|
-
qbash(
|
|
38
|
-
"bundle exec ruby #{Shellwords.escape(f)} -- --offline",
|
|
39
|
-
stdout: $stdout, env: { 'RACK_ENV' => 'picks' }
|
|
40
|
-
)
|
|
37
|
+
qbash("bundle exec ruby #{Shellwords.escape(f)} -- --offline", stdout: $stdout, env: { 'RACK_ENV' => 'picks' })
|
|
41
38
|
end
|
|
42
39
|
end
|
|
43
40
|
|
data/baza.rb.gemspec
CHANGED
|
@@ -7,8 +7,8 @@ require 'English'
|
|
|
7
7
|
require_relative 'lib/baza-rb/version'
|
|
8
8
|
|
|
9
9
|
Gem::Specification.new do |s|
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?
|
|
11
|
-
s.required_ruby_version = '>=3.
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
|
|
11
|
+
s.required_ruby_version = '>=3.3'
|
|
12
12
|
s.name = 'baza.rb'
|
|
13
13
|
s.version = BazaRb::VERSION
|
|
14
14
|
s.license = 'MIT'
|
|
@@ -23,16 +23,13 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
|
|
24
24
|
s.rdoc_options = ['--charset=UTF-8']
|
|
25
25
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
|
26
|
-
s.add_dependency
|
|
27
|
-
s.add_dependency
|
|
28
|
-
s.add_dependency
|
|
29
|
-
s.add_dependency
|
|
30
|
-
s.add_dependency
|
|
31
|
-
s.add_dependency
|
|
32
|
-
s.add_dependency
|
|
33
|
-
s.add_dependency
|
|
34
|
-
s.add_dependency 'retries', '~>0.0'
|
|
35
|
-
s.add_dependency 'tago', '~>0.2'
|
|
36
|
-
s.add_dependency 'typhoeus', '~>1.4'
|
|
26
|
+
s.add_dependency('base64', '~>0.3')
|
|
27
|
+
s.add_dependency('elapsed', '~>0.2')
|
|
28
|
+
s.add_dependency('iri', '~>0.11')
|
|
29
|
+
s.add_dependency('logger', '~>1.6')
|
|
30
|
+
s.add_dependency('loog', '~>0.6')
|
|
31
|
+
s.add_dependency('retries', '~>0.0')
|
|
32
|
+
s.add_dependency('tago', '~>0.2')
|
|
33
|
+
s.add_dependency('typhoeus', '~>1.4')
|
|
37
34
|
s.metadata['rubygems_mfa_required'] = 'true'
|
|
38
35
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 Zerocracy
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
6
|
+
require 'stringio'
|
|
7
|
+
require 'zlib'
|
|
8
|
+
|
|
9
|
+
# Compression helpers for BazaRb.
|
|
10
|
+
#
|
|
11
|
+
# Provides gzip compression and decompression for request bodies
|
|
12
|
+
# and response data.
|
|
13
|
+
#
|
|
14
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
15
|
+
# Copyright:: Copyright (c) 2024-2026 Yegor Bugayenko
|
|
16
|
+
# License:: MIT
|
|
17
|
+
class BazaRb
|
|
18
|
+
# Compression helpers.
|
|
19
|
+
module Compress
|
|
20
|
+
LIMIT_UNCOMPRESSED = 10_485_760
|
|
21
|
+
|
|
22
|
+
# Decompress gzipped data.
|
|
23
|
+
#
|
|
24
|
+
# @param [String] data The gzipped data to decompress
|
|
25
|
+
# @return [String] The decompressed data
|
|
26
|
+
# @raise [BadCompression] If the data is not valid gzip
|
|
27
|
+
def unzip(data)
|
|
28
|
+
unzipped = StringIO.new
|
|
29
|
+
Zlib::GzipReader.new(StringIO.new(data)).each(4096) do |chunk|
|
|
30
|
+
unzipped.write(chunk)
|
|
31
|
+
next unless unzipped.length > LIMIT_UNCOMPRESSED
|
|
32
|
+
raise(BadCompression, "Uncompressed size #{unzipped.length} exceeds limit #{LIMIT_UNCOMPRESSED}")
|
|
33
|
+
end
|
|
34
|
+
unzipped.string
|
|
35
|
+
rescue Zlib::GzipFile::Error => e
|
|
36
|
+
raise(BadCompression, "Failed to unzip #{data.bytesize} bytes: #{e.message}")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Compress request parameters with gzip.
|
|
40
|
+
#
|
|
41
|
+
# @param [Hash] params The request parameters with :body and :headers keys
|
|
42
|
+
# @return [Hash] The modified parameters with compressed body and updated headers
|
|
43
|
+
def zipped(params)
|
|
44
|
+
io = StringIO.new
|
|
45
|
+
gz = Zlib::GzipWriter.new(io)
|
|
46
|
+
gz.write(params.fetch(:body))
|
|
47
|
+
gz.close
|
|
48
|
+
body = io.string
|
|
49
|
+
params.merge(
|
|
50
|
+
body:,
|
|
51
|
+
headers: params.fetch(:headers).merge({ 'Content-Encoding' => 'gzip', 'Content-Length' => body.bytesize })
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|