http 4.4.1 → 5.1.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 +65 -0
- data/.gitignore +6 -10
- data/.rspec +0 -4
- data/.rubocop/layout.yml +8 -0
- data/.rubocop/style.yml +32 -0
- data/.rubocop.yml +8 -110
- data/.rubocop_todo.yml +205 -0
- data/.yardopts +1 -1
- data/CHANGES.md +188 -3
- data/Gemfile +18 -10
- data/LICENSE.txt +1 -1
- data/README.md +47 -86
- data/Rakefile +2 -10
- data/SECURITY.md +5 -0
- data/http.gemspec +9 -8
- data/lib/http/chainable.rb +23 -17
- data/lib/http/client.rb +44 -34
- data/lib/http/connection.rb +11 -7
- data/lib/http/content_type.rb +12 -7
- data/lib/http/errors.rb +3 -0
- data/lib/http/feature.rb +3 -1
- data/lib/http/features/auto_deflate.rb +6 -6
- data/lib/http/features/auto_inflate.rb +6 -7
- data/lib/http/features/instrumentation.rb +1 -1
- data/lib/http/features/logging.rb +19 -21
- data/lib/http/headers.rb +50 -13
- data/lib/http/mime_type/adapter.rb +3 -1
- data/lib/http/mime_type/json.rb +1 -0
- data/lib/http/options.rb +5 -8
- data/lib/http/redirector.rb +51 -2
- data/lib/http/request/body.rb +1 -0
- data/lib/http/request/writer.rb +9 -4
- data/lib/http/request.rb +28 -11
- data/lib/http/response/body.rb +6 -4
- data/lib/http/response/inflater.rb +1 -1
- data/lib/http/response/parser.rb +74 -62
- data/lib/http/response/status.rb +4 -3
- data/lib/http/response.rb +44 -18
- data/lib/http/timeout/global.rb +20 -36
- data/lib/http/timeout/null.rb +2 -1
- data/lib/http/timeout/per_operation.rb +32 -55
- data/lib/http/uri.rb +5 -5
- data/lib/http/version.rb +1 -1
- data/spec/lib/http/client_spec.rb +153 -30
- data/spec/lib/http/connection_spec.rb +8 -5
- data/spec/lib/http/features/auto_inflate_spec.rb +3 -2
- data/spec/lib/http/features/instrumentation_spec.rb +27 -21
- data/spec/lib/http/features/logging_spec.rb +8 -10
- data/spec/lib/http/headers_spec.rb +53 -18
- data/spec/lib/http/options/headers_spec.rb +1 -1
- data/spec/lib/http/options/merge_spec.rb +16 -16
- data/spec/lib/http/redirector_spec.rb +107 -3
- data/spec/lib/http/request/body_spec.rb +3 -3
- data/spec/lib/http/request/writer_spec.rb +25 -2
- data/spec/lib/http/request_spec.rb +5 -5
- data/spec/lib/http/response/body_spec.rb +5 -5
- data/spec/lib/http/response/parser_spec.rb +33 -4
- data/spec/lib/http/response/status_spec.rb +3 -3
- data/spec/lib/http/response_spec.rb +80 -3
- data/spec/lib/http_spec.rb +30 -3
- data/spec/spec_helper.rb +21 -21
- data/spec/support/black_hole.rb +1 -1
- data/spec/support/dummy_server/servlet.rb +17 -6
- data/spec/support/dummy_server.rb +7 -7
- data/spec/support/fuubar.rb +21 -0
- data/spec/support/http_handling_shared.rb +5 -5
- data/spec/support/simplecov.rb +19 -0
- data/spec/support/ssl_helper.rb +4 -4
- metadata +23 -15
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -39
@@ -13,18 +13,18 @@ class DummyServer < WEBrick::HTTPServer
|
|
13
13
|
include ServerConfig
|
14
14
|
|
15
15
|
CONFIG = {
|
16
|
-
:BindAddress
|
17
|
-
:Port
|
18
|
-
:AccessLog
|
19
|
-
:Logger
|
16
|
+
:BindAddress => "127.0.0.1",
|
17
|
+
:Port => 0,
|
18
|
+
:AccessLog => BlackHole,
|
19
|
+
:Logger => BlackHole
|
20
20
|
}.freeze
|
21
21
|
|
22
22
|
SSL_CONFIG = CONFIG.merge(
|
23
|
-
:SSLEnable
|
24
|
-
:SSLStartImmediately
|
23
|
+
:SSLEnable => true,
|
24
|
+
:SSLStartImmediately => true
|
25
25
|
).freeze
|
26
26
|
|
27
|
-
def initialize(options = {})
|
27
|
+
def initialize(options = {})
|
28
28
|
super(options[:ssl] ? SSL_CONFIG : CONFIG)
|
29
29
|
mount("/", Servlet)
|
30
30
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fuubar"
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
# Use Fuubar instafail-alike formatter, unless a formatter has already been
|
7
|
+
# configured (e.g. via a command-line flag).
|
8
|
+
config.default_formatter = "Fuubar"
|
9
|
+
|
10
|
+
# Disable auto-refresh of the fuubar progress bar to avoid surprises during
|
11
|
+
# debugiing. And simply because there's next to absolutely no point in having
|
12
|
+
# this turned on.
|
13
|
+
#
|
14
|
+
# > By default fuubar will automatically refresh the bar (and therefore
|
15
|
+
# > the ETA) every second. Unfortunately this doesn't play well with things
|
16
|
+
# > like debuggers. When you're debugging, having a bar show up every second
|
17
|
+
# > is undesireable.
|
18
|
+
#
|
19
|
+
# See: https://github.com/thekompanee/fuubar#disabling-auto-refresh
|
20
|
+
config.fuubar_auto_refresh = false
|
21
|
+
end
|
@@ -14,11 +14,11 @@ RSpec.shared_context "HTTP handling" do
|
|
14
14
|
|
15
15
|
let(:options) do
|
16
16
|
{
|
17
|
-
:timeout_class
|
17
|
+
:timeout_class => HTTP::Timeout::PerOperation,
|
18
18
|
:timeout_options => {
|
19
19
|
:connect_timeout => conn_timeout,
|
20
|
-
:read_timeout
|
21
|
-
:write_timeout
|
20
|
+
:read_timeout => read_timeout,
|
21
|
+
:write_timeout => write_timeout
|
22
22
|
}
|
23
23
|
}
|
24
24
|
end
|
@@ -62,7 +62,7 @@ RSpec.shared_context "HTTP handling" do
|
|
62
62
|
context "with a global timeout" do
|
63
63
|
let(:options) do
|
64
64
|
{
|
65
|
-
:timeout_class
|
65
|
+
:timeout_class => HTTP::Timeout::Global,
|
66
66
|
:timeout_options => {
|
67
67
|
:global_timeout => global_timeout
|
68
68
|
}
|
@@ -77,7 +77,7 @@ RSpec.shared_context "HTTP handling" do
|
|
77
77
|
sleep 1.25
|
78
78
|
end
|
79
79
|
|
80
|
-
expect { response }.to raise_error(HTTP::
|
80
|
+
expect { response }.to raise_error(HTTP::ConnectTimeoutError, /execution/)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "errors if reading takes too long" do
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "simplecov"
|
4
|
+
|
5
|
+
if ENV["CI"]
|
6
|
+
require "simplecov-lcov"
|
7
|
+
|
8
|
+
SimpleCov::Formatter::LcovFormatter.config do |config|
|
9
|
+
config.report_with_single_file = true
|
10
|
+
config.lcov_file_name = "lcov.info"
|
11
|
+
end
|
12
|
+
|
13
|
+
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
|
14
|
+
end
|
15
|
+
|
16
|
+
SimpleCov.start do
|
17
|
+
add_filter "/spec/"
|
18
|
+
minimum_coverage 80
|
19
|
+
end
|
data/spec/support/ssl_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require "pathname"
|
|
5
5
|
require "certificate_authority"
|
6
6
|
|
7
7
|
module SSLHelper
|
8
|
-
CERTS_PATH = Pathname.new File.expand_path("
|
8
|
+
CERTS_PATH = Pathname.new File.expand_path("../../tmp/certs", __dir__)
|
9
9
|
|
10
10
|
class RootCertificate < ::CertificateAuthority::Certificate
|
11
11
|
EXTENSIONS = {"keyUsage" => {"usage" => %w[critical keyCertSign]}}.freeze
|
@@ -83,14 +83,14 @@ module SSLHelper
|
|
83
83
|
|
84
84
|
def client_params
|
85
85
|
{
|
86
|
-
:key
|
87
|
-
:cert
|
86
|
+
:key => client_cert.key,
|
87
|
+
:cert => client_cert.cert,
|
88
88
|
:ca_file => ca.file
|
89
89
|
}
|
90
90
|
end
|
91
91
|
|
92
92
|
%w[server client].each do |side|
|
93
|
-
class_eval <<-RUBY, __FILE__, __LINE__
|
93
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
94
94
|
def #{side}_cert
|
95
95
|
@#{side}_cert ||= ChildCertificate.new ca
|
96
96
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
8
8
|
- Erik Michaels-Ober
|
9
9
|
- Alexey V. Zapparov
|
10
10
|
- Zachary Anker
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2022-06-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: addressable
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '2.
|
22
|
+
version: '2.8'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2.
|
29
|
+
version: '2.8'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: http-cookie
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,19 +56,19 @@ dependencies:
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '2.2'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
59
|
+
name: llhttp-ffi
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
64
|
+
version: 0.4.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:
|
71
|
+
version: 0.4.0
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: bundler
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,11 +91,13 @@ executables: []
|
|
91
91
|
extensions: []
|
92
92
|
extra_rdoc_files: []
|
93
93
|
files:
|
94
|
-
- ".
|
94
|
+
- ".github/workflows/ci.yml"
|
95
95
|
- ".gitignore"
|
96
96
|
- ".rspec"
|
97
97
|
- ".rubocop.yml"
|
98
|
-
- ".
|
98
|
+
- ".rubocop/layout.yml"
|
99
|
+
- ".rubocop/style.yml"
|
100
|
+
- ".rubocop_todo.yml"
|
99
101
|
- ".yardopts"
|
100
102
|
- CHANGES.md
|
101
103
|
- CONTRIBUTING.md
|
@@ -104,6 +106,7 @@ files:
|
|
104
106
|
- LICENSE.txt
|
105
107
|
- README.md
|
106
108
|
- Rakefile
|
109
|
+
- SECURITY.md
|
107
110
|
- http.gemspec
|
108
111
|
- lib/http.rb
|
109
112
|
- lib/http/chainable.rb
|
@@ -175,10 +178,12 @@ files:
|
|
175
178
|
- spec/support/dummy_server.rb
|
176
179
|
- spec/support/dummy_server/servlet.rb
|
177
180
|
- spec/support/fakeio.rb
|
181
|
+
- spec/support/fuubar.rb
|
178
182
|
- spec/support/http_handling_shared.rb
|
179
183
|
- spec/support/proxy_server.rb
|
180
184
|
- spec/support/servers/config.rb
|
181
185
|
- spec/support/servers/runner.rb
|
186
|
+
- spec/support/simplecov.rb
|
182
187
|
- spec/support/ssl_helper.rb
|
183
188
|
homepage: https://github.com/httprb/http
|
184
189
|
licenses:
|
@@ -187,8 +192,9 @@ metadata:
|
|
187
192
|
source_code_uri: https://github.com/httprb/http
|
188
193
|
wiki_uri: https://github.com/httprb/http/wiki
|
189
194
|
bug_tracker_uri: https://github.com/httprb/http/issues
|
190
|
-
changelog_uri: https://github.com/httprb/http/blob/
|
191
|
-
|
195
|
+
changelog_uri: https://github.com/httprb/http/blob/v5.1.0/CHANGES.md
|
196
|
+
rubygems_mfa_required: 'true'
|
197
|
+
post_install_message:
|
192
198
|
rdoc_options: []
|
193
199
|
require_paths:
|
194
200
|
- lib
|
@@ -196,15 +202,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
202
|
requirements:
|
197
203
|
- - ">="
|
198
204
|
- !ruby/object:Gem::Version
|
199
|
-
version: '2.
|
205
|
+
version: '2.6'
|
200
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
207
|
requirements:
|
202
208
|
- - ">="
|
203
209
|
- !ruby/object:Gem::Version
|
204
210
|
version: '0'
|
205
211
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
207
|
-
signing_key:
|
212
|
+
rubygems_version: 3.1.6
|
213
|
+
signing_key:
|
208
214
|
specification_version: 4
|
209
215
|
summary: HTTP should be easy
|
210
216
|
test_files:
|
@@ -243,8 +249,10 @@ test_files:
|
|
243
249
|
- spec/support/dummy_server.rb
|
244
250
|
- spec/support/dummy_server/servlet.rb
|
245
251
|
- spec/support/fakeio.rb
|
252
|
+
- spec/support/fuubar.rb
|
246
253
|
- spec/support/http_handling_shared.rb
|
247
254
|
- spec/support/proxy_server.rb
|
248
255
|
- spec/support/servers/config.rb
|
249
256
|
- spec/support/servers/runner.rb
|
257
|
+
- spec/support/simplecov.rb
|
250
258
|
- spec/support/ssl_helper.rb
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service-name: travis-pro
|
data/.travis.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
|
4
|
-
cache: bundler
|
5
|
-
|
6
|
-
before_install:
|
7
|
-
- gem update --system
|
8
|
-
- gem --version
|
9
|
-
- gem install bundler --no-document
|
10
|
-
- bundle --version
|
11
|
-
|
12
|
-
install: bundle install --without development doc
|
13
|
-
|
14
|
-
script: bundle exec rake
|
15
|
-
|
16
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
17
|
-
|
18
|
-
rvm:
|
19
|
-
# Include JRuby first because it takes the longest
|
20
|
-
- jruby-9.2.5.0
|
21
|
-
- 2.3
|
22
|
-
- 2.4
|
23
|
-
- 2.5
|
24
|
-
- 2.6
|
25
|
-
- 2.7
|
26
|
-
|
27
|
-
matrix:
|
28
|
-
fast_finish: true
|
29
|
-
include:
|
30
|
-
# Only run RuboCop and Yardstick metrics on the latest Ruby
|
31
|
-
- rvm: 2.7
|
32
|
-
env: SUITE="rubocop"
|
33
|
-
- rvm: 2.7
|
34
|
-
env: SUITE="yardstick"
|
35
|
-
|
36
|
-
branches:
|
37
|
-
only:
|
38
|
-
- master
|
39
|
-
- 4-x-stable
|