http 5.1.1 → 5.3.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/.github/workflows/ci.yml +6 -24
- data/.rubocop/metrics.yml +4 -0
- data/.rubocop/rspec.yml +9 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +45 -32
- data/CHANGELOG.md +57 -0
- data/{CHANGES.md → CHANGES_OLD.md} +1 -1
- data/Gemfile +1 -0
- data/README.md +4 -2
- data/SECURITY.md +13 -1
- data/http.gemspec +8 -2
- data/lib/http/base64.rb +12 -0
- data/lib/http/chainable.rb +27 -3
- data/lib/http/client.rb +1 -1
- data/lib/http/connection.rb +12 -3
- data/lib/http/errors.rb +16 -0
- data/lib/http/feature.rb +2 -1
- data/lib/http/features/instrumentation.rb +6 -1
- data/lib/http/features/raise_error.rb +22 -0
- data/lib/http/headers/normalizer.rb +69 -0
- data/lib/http/headers.rb +26 -40
- data/lib/http/request/writer.rb +2 -1
- data/lib/http/request.rb +15 -5
- data/lib/http/retriable/client.rb +37 -0
- data/lib/http/retriable/delay_calculator.rb +64 -0
- data/lib/http/retriable/errors.rb +14 -0
- data/lib/http/retriable/performer.rb +153 -0
- data/lib/http/timeout/null.rb +8 -5
- data/lib/http/uri.rb +18 -2
- data/lib/http/version.rb +1 -1
- data/lib/http.rb +1 -0
- data/spec/lib/http/client_spec.rb +1 -0
- data/spec/lib/http/connection_spec.rb +23 -1
- data/spec/lib/http/features/instrumentation_spec.rb +19 -0
- data/spec/lib/http/features/raise_error_spec.rb +62 -0
- data/spec/lib/http/headers/normalizer_spec.rb +52 -0
- data/spec/lib/http/options/headers_spec.rb +5 -1
- data/spec/lib/http/redirector_spec.rb +6 -5
- data/spec/lib/http/retriable/delay_calculator_spec.rb +69 -0
- data/spec/lib/http/retriable/performer_spec.rb +302 -0
- data/spec/lib/http/uri/normalizer_spec.rb +95 -0
- data/spec/lib/http_spec.rb +49 -3
- data/spec/spec_helper.rb +1 -0
- data/spec/support/dummy_server/servlet.rb +19 -6
- data/spec/support/dummy_server.rb +2 -1
- metadata +28 -8
@@ -9,15 +9,20 @@ class DummyServer < WEBrick::HTTPServer
|
|
9
9
|
@sockets ||= []
|
10
10
|
end
|
11
11
|
|
12
|
-
def not_found(
|
12
|
+
def not_found(req, res)
|
13
13
|
res.status = 404
|
14
|
-
res.body = "
|
14
|
+
res.body = "#{req.unparsed_uri} not found"
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.handlers
|
18
18
|
@handlers ||= {}
|
19
19
|
end
|
20
20
|
|
21
|
+
def initialize(server, memo)
|
22
|
+
super(server)
|
23
|
+
@memo = memo
|
24
|
+
end
|
25
|
+
|
21
26
|
%w[get post head].each do |method|
|
22
27
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
23
28
|
def self.#{method}(path, &block)
|
@@ -27,7 +32,7 @@ class DummyServer < WEBrick::HTTPServer
|
|
27
32
|
def do_#{method.upcase}(req, res)
|
28
33
|
handler = self.class.handlers["#{method}:\#{req.path}"]
|
29
34
|
return instance_exec(req, res, &handler) if handler
|
30
|
-
not_found
|
35
|
+
not_found(req, res)
|
31
36
|
end
|
32
37
|
RUBY
|
33
38
|
end
|
@@ -68,7 +73,7 @@ class DummyServer < WEBrick::HTTPServer
|
|
68
73
|
end
|
69
74
|
|
70
75
|
get "/params" do |req, res|
|
71
|
-
next not_found unless "foo=bar" == req.query_string
|
76
|
+
next not_found(req, res) unless "foo=bar" == req.query_string
|
72
77
|
|
73
78
|
res.status = 200
|
74
79
|
res.body = "Params!"
|
@@ -77,7 +82,7 @@ class DummyServer < WEBrick::HTTPServer
|
|
77
82
|
get "/multiple-params" do |req, res|
|
78
83
|
params = CGI.parse req.query_string
|
79
84
|
|
80
|
-
next not_found unless {"foo" => ["bar"], "baz" => ["quux"]} == params
|
85
|
+
next not_found(req, res) unless {"foo" => ["bar"], "baz" => ["quux"]} == params
|
81
86
|
|
82
87
|
res.status = 200
|
83
88
|
res.body = "More Params!"
|
@@ -149,7 +154,7 @@ class DummyServer < WEBrick::HTTPServer
|
|
149
154
|
res.body = req.body
|
150
155
|
end
|
151
156
|
|
152
|
-
get "/
|
157
|
+
get "/héllö-wörld".b do |_req, res|
|
153
158
|
res.status = 200
|
154
159
|
res.body = "hello world"
|
155
160
|
end
|
@@ -186,5 +191,13 @@ class DummyServer < WEBrick::HTTPServer
|
|
186
191
|
res["Content-Encoding"] = "deflate"
|
187
192
|
end
|
188
193
|
end
|
194
|
+
|
195
|
+
get "/retry-2" do |_req, res|
|
196
|
+
@memo[:attempts] ||= 0
|
197
|
+
@memo[:attempts] += 1
|
198
|
+
|
199
|
+
res.body = "retried #{@memo[:attempts]}x"
|
200
|
+
res.status = @memo[:attempts] == 2 ? 200 : 500
|
201
|
+
end
|
189
202
|
end
|
190
203
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2025-06-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: addressable
|
@@ -56,19 +56,19 @@ dependencies:
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '2.2'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name: llhttp
|
59
|
+
name: llhttp
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.
|
64
|
+
version: 0.5.0
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.
|
71
|
+
version: 0.5.0
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: bundler
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,10 +96,13 @@ files:
|
|
96
96
|
- ".rspec"
|
97
97
|
- ".rubocop.yml"
|
98
98
|
- ".rubocop/layout.yml"
|
99
|
+
- ".rubocop/metrics.yml"
|
100
|
+
- ".rubocop/rspec.yml"
|
99
101
|
- ".rubocop/style.yml"
|
100
102
|
- ".rubocop_todo.yml"
|
101
103
|
- ".yardopts"
|
102
|
-
-
|
104
|
+
- CHANGELOG.md
|
105
|
+
- CHANGES_OLD.md
|
103
106
|
- CONTRIBUTING.md
|
104
107
|
- Gemfile
|
105
108
|
- Guardfile
|
@@ -109,6 +112,7 @@ files:
|
|
109
112
|
- SECURITY.md
|
110
113
|
- http.gemspec
|
111
114
|
- lib/http.rb
|
115
|
+
- lib/http/base64.rb
|
112
116
|
- lib/http/chainable.rb
|
113
117
|
- lib/http/client.rb
|
114
118
|
- lib/http/connection.rb
|
@@ -120,9 +124,11 @@ files:
|
|
120
124
|
- lib/http/features/instrumentation.rb
|
121
125
|
- lib/http/features/logging.rb
|
122
126
|
- lib/http/features/normalize_uri.rb
|
127
|
+
- lib/http/features/raise_error.rb
|
123
128
|
- lib/http/headers.rb
|
124
129
|
- lib/http/headers/known.rb
|
125
130
|
- lib/http/headers/mixin.rb
|
131
|
+
- lib/http/headers/normalizer.rb
|
126
132
|
- lib/http/mime_type.rb
|
127
133
|
- lib/http/mime_type/adapter.rb
|
128
134
|
- lib/http/mime_type/json.rb
|
@@ -137,6 +143,10 @@ files:
|
|
137
143
|
- lib/http/response/parser.rb
|
138
144
|
- lib/http/response/status.rb
|
139
145
|
- lib/http/response/status/reasons.rb
|
146
|
+
- lib/http/retriable/client.rb
|
147
|
+
- lib/http/retriable/delay_calculator.rb
|
148
|
+
- lib/http/retriable/errors.rb
|
149
|
+
- lib/http/retriable/performer.rb
|
140
150
|
- lib/http/timeout/global.rb
|
141
151
|
- lib/http/timeout/null.rb
|
142
152
|
- lib/http/timeout/per_operation.rb
|
@@ -150,7 +160,9 @@ files:
|
|
150
160
|
- spec/lib/http/features/auto_inflate_spec.rb
|
151
161
|
- spec/lib/http/features/instrumentation_spec.rb
|
152
162
|
- spec/lib/http/features/logging_spec.rb
|
163
|
+
- spec/lib/http/features/raise_error_spec.rb
|
153
164
|
- spec/lib/http/headers/mixin_spec.rb
|
165
|
+
- spec/lib/http/headers/normalizer_spec.rb
|
154
166
|
- spec/lib/http/headers_spec.rb
|
155
167
|
- spec/lib/http/options/body_spec.rb
|
156
168
|
- spec/lib/http/options/features_spec.rb
|
@@ -169,6 +181,9 @@ files:
|
|
169
181
|
- spec/lib/http/response/parser_spec.rb
|
170
182
|
- spec/lib/http/response/status_spec.rb
|
171
183
|
- spec/lib/http/response_spec.rb
|
184
|
+
- spec/lib/http/retriable/delay_calculator_spec.rb
|
185
|
+
- spec/lib/http/retriable/performer_spec.rb
|
186
|
+
- spec/lib/http/uri/normalizer_spec.rb
|
172
187
|
- spec/lib/http/uri_spec.rb
|
173
188
|
- spec/lib/http_spec.rb
|
174
189
|
- spec/regression_specs.rb
|
@@ -192,7 +207,7 @@ metadata:
|
|
192
207
|
source_code_uri: https://github.com/httprb/http
|
193
208
|
wiki_uri: https://github.com/httprb/http/wiki
|
194
209
|
bug_tracker_uri: https://github.com/httprb/http/issues
|
195
|
-
changelog_uri: https://github.com/httprb/http/blob/v5.
|
210
|
+
changelog_uri: https://github.com/httprb/http/blob/v5.3.0/CHANGELOG.md
|
196
211
|
rubygems_mfa_required: 'true'
|
197
212
|
post_install_message:
|
198
213
|
rdoc_options: []
|
@@ -209,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
224
|
- !ruby/object:Gem::Version
|
210
225
|
version: '0'
|
211
226
|
requirements: []
|
212
|
-
rubygems_version: 3.
|
227
|
+
rubygems_version: 3.4.19
|
213
228
|
signing_key:
|
214
229
|
specification_version: 4
|
215
230
|
summary: HTTP should be easy
|
@@ -221,7 +236,9 @@ test_files:
|
|
221
236
|
- spec/lib/http/features/auto_inflate_spec.rb
|
222
237
|
- spec/lib/http/features/instrumentation_spec.rb
|
223
238
|
- spec/lib/http/features/logging_spec.rb
|
239
|
+
- spec/lib/http/features/raise_error_spec.rb
|
224
240
|
- spec/lib/http/headers/mixin_spec.rb
|
241
|
+
- spec/lib/http/headers/normalizer_spec.rb
|
225
242
|
- spec/lib/http/headers_spec.rb
|
226
243
|
- spec/lib/http/options/body_spec.rb
|
227
244
|
- spec/lib/http/options/features_spec.rb
|
@@ -240,6 +257,9 @@ test_files:
|
|
240
257
|
- spec/lib/http/response/parser_spec.rb
|
241
258
|
- spec/lib/http/response/status_spec.rb
|
242
259
|
- spec/lib/http/response_spec.rb
|
260
|
+
- spec/lib/http/retriable/delay_calculator_spec.rb
|
261
|
+
- spec/lib/http/retriable/performer_spec.rb
|
262
|
+
- spec/lib/http/uri/normalizer_spec.rb
|
243
263
|
- spec/lib/http/uri_spec.rb
|
244
264
|
- spec/lib/http_spec.rb
|
245
265
|
- spec/regression_specs.rb
|