http 5.0.0.pre3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +65 -0
  3. data/.gitignore +6 -10
  4. data/.rspec +0 -4
  5. data/.rubocop.yml +7 -124
  6. data/.rubocop/layout.yml +8 -0
  7. data/.rubocop/style.yml +32 -0
  8. data/.rubocop_todo.yml +192 -0
  9. data/CHANGES.md +48 -1
  10. data/Gemfile +18 -11
  11. data/README.md +13 -17
  12. data/Rakefile +2 -10
  13. data/http.gemspec +2 -2
  14. data/lib/http/chainable.rb +15 -14
  15. data/lib/http/client.rb +18 -11
  16. data/lib/http/connection.rb +7 -3
  17. data/lib/http/content_type.rb +10 -5
  18. data/lib/http/feature.rb +1 -1
  19. data/lib/http/features/instrumentation.rb +1 -1
  20. data/lib/http/features/logging.rb +19 -21
  21. data/lib/http/headers.rb +3 -3
  22. data/lib/http/mime_type/adapter.rb +2 -0
  23. data/lib/http/options.rb +2 -2
  24. data/lib/http/redirector.rb +1 -1
  25. data/lib/http/request.rb +7 -4
  26. data/lib/http/response/body.rb +1 -2
  27. data/lib/http/response/inflater.rb +1 -1
  28. data/lib/http/response/parser.rb +72 -64
  29. data/lib/http/response/status.rb +2 -2
  30. data/lib/http/timeout/global.rb +16 -28
  31. data/lib/http/timeout/null.rb +2 -1
  32. data/lib/http/timeout/per_operation.rb +31 -55
  33. data/lib/http/version.rb +1 -1
  34. data/spec/lib/http/client_spec.rb +75 -41
  35. data/spec/lib/http/features/instrumentation_spec.rb +21 -15
  36. data/spec/lib/http/features/logging_spec.rb +2 -4
  37. data/spec/lib/http/headers_spec.rb +3 -3
  38. data/spec/lib/http/response/parser_spec.rb +2 -2
  39. data/spec/lib/http_spec.rb +20 -2
  40. data/spec/spec_helper.rb +21 -21
  41. data/spec/support/black_hole.rb +1 -1
  42. data/spec/support/dummy_server.rb +1 -1
  43. data/spec/support/dummy_server/servlet.rb +14 -2
  44. data/spec/support/fuubar.rb +21 -0
  45. data/spec/support/simplecov.rb +19 -0
  46. metadata +21 -16
  47. data/.coveralls.yml +0 -1
  48. data/.travis.yml +0 -38
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "simplecov"
4
- require "coveralls"
5
-
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
7
- [
8
- SimpleCov::Formatter::HTMLFormatter,
9
- Coveralls::SimpleCov::Formatter
10
- ]
11
- )
12
-
13
- SimpleCov.start do
14
- add_filter "/spec/"
15
- minimum_coverage 80
16
- end
3
+ require_relative "./support/simplecov"
4
+ require_relative "./support/fuubar" unless ENV["CI"]
17
5
 
18
6
  require "http"
19
7
  require "rspec/its"
@@ -40,6 +28,13 @@ RSpec.configure do |config|
40
28
  mocks.verify_partial_doubles = true
41
29
  end
42
30
 
31
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
32
+ # have no way to turn it off -- the option exists only for backwards
33
+ # compatibility in RSpec 3). It causes shared context metadata to be
34
+ # inherited by the metadata hash of host groups and examples, rather than
35
+ # triggering implicit auto-inclusion in groups with matching metadata.
36
+ config.shared_context_metadata_behavior = :apply_to_host_groups
37
+
43
38
  # These two settings work together to allow you to limit a spec run
44
39
  # to individual examples or groups you care about by tagging them with
45
40
  # `:focus` metadata. When nothing is tagged with `:focus`, all examples
@@ -48,17 +43,22 @@ RSpec.configure do |config|
48
43
  config.filter_run_excluding :flaky if defined?(JRUBY_VERSION) && ENV["CI"]
49
44
  config.run_all_when_everything_filtered = true
50
45
 
51
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
- # For more details, see:
53
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
- config.disable_monkey_patching!
57
-
58
46
  # This setting enables warnings. It's recommended, but in some cases may
59
47
  # be too noisy due to issues in dependencies.
60
48
  config.warnings = 0 == ENV["GUARD_RSPEC"].to_i
61
49
 
50
+ # Allows RSpec to persist some state between runs in order to support
51
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
52
+ # you configure your source control system to ignore this file.
53
+ config.example_status_persistence_file_path = "spec/examples.txt"
54
+
55
+ # Limits the available syntax to the non-monkey patched syntax that is
56
+ # recommended. For more details, see:
57
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
58
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
59
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
60
+ config.disable_monkey_patching!
61
+
62
62
  # Many RSpec users commonly either run the entire suite or an individual
63
63
  # file, and it's useful to allow more verbose output when running an
64
64
  # individual spec file.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module BlackHole
4
4
  class << self
5
- def method_missing(*) # rubocop:disable Style/MethodMissingSuper
5
+ def method_missing(*)
6
6
  self
7
7
  end
8
8
 
@@ -24,7 +24,7 @@ class DummyServer < WEBrick::HTTPServer
24
24
  :SSLStartImmediately => true
25
25
  ).freeze
26
26
 
27
- def initialize(options = {}) # rubocop:disable Style/OptionHash
27
+ def initialize(options = {})
28
28
  super(options[:ssl] ? SSL_CONFIG : CONFIG)
29
29
  mount("/", Servlet)
30
30
  end
@@ -156,7 +156,7 @@ class DummyServer < WEBrick::HTTPServer
156
156
  res.status = 200
157
157
 
158
158
  res.body = case req["Accept-Encoding"]
159
- when "gzip" then
159
+ when "gzip"
160
160
  res["Content-Encoding"] = "gzip"
161
161
  StringIO.open do |out|
162
162
  Zlib::GzipWriter.wrap(out) do |gz|
@@ -165,12 +165,24 @@ class DummyServer < WEBrick::HTTPServer
165
165
  out.tap(&:rewind).read
166
166
  end
167
167
  end
168
- when "deflate" then
168
+ when "deflate"
169
169
  res["Content-Encoding"] = "deflate"
170
170
  Zlib::Deflate.deflate("#{req.body}-deflated")
171
171
  else
172
172
  "#{req.body}-raw"
173
173
  end
174
174
  end
175
+
176
+ post "/no-content-204" do |req, res|
177
+ res.status = 204
178
+ res.body = ""
179
+
180
+ case req["Accept-Encoding"]
181
+ when "gzip"
182
+ res["Content-Encoding"] = "gzip"
183
+ when "deflate"
184
+ res["Content-Encoding"] = "deflate"
185
+ end
186
+ end
175
187
  end
176
188
  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
@@ -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
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: 5.0.0.pre3
4
+ version: 5.0.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: 2020-02-26 00:00:00.000000000 Z
14
+ date: 2021-05-13 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: http-parser
59
+ name: llhttp-ffi
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: 1.2.0
64
+ version: 0.0.1
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: 1.2.0
71
+ version: 0.0.1
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
- - ".coveralls.yml"
94
+ - ".github/workflows/ci.yml"
95
95
  - ".gitignore"
96
96
  - ".rspec"
97
97
  - ".rubocop.yml"
98
- - ".travis.yml"
98
+ - ".rubocop/layout.yml"
99
+ - ".rubocop/style.yml"
100
+ - ".rubocop_todo.yml"
99
101
  - ".yardopts"
100
102
  - CHANGES.md
101
103
  - CONTRIBUTING.md
@@ -175,10 +177,12 @@ files:
175
177
  - spec/support/dummy_server.rb
176
178
  - spec/support/dummy_server/servlet.rb
177
179
  - spec/support/fakeio.rb
180
+ - spec/support/fuubar.rb
178
181
  - spec/support/http_handling_shared.rb
179
182
  - spec/support/proxy_server.rb
180
183
  - spec/support/servers/config.rb
181
184
  - spec/support/servers/runner.rb
185
+ - spec/support/simplecov.rb
182
186
  - spec/support/ssl_helper.rb
183
187
  homepage: https://github.com/httprb/http
184
188
  licenses:
@@ -187,8 +191,8 @@ metadata:
187
191
  source_code_uri: https://github.com/httprb/http
188
192
  wiki_uri: https://github.com/httprb/http/wiki
189
193
  bug_tracker_uri: https://github.com/httprb/http/issues
190
- changelog_uri: https://github.com/httprb/http/blob/v5.0.0.pre3/CHANGES.md
191
- post_install_message:
194
+ changelog_uri: https://github.com/httprb/http/blob/v5.0.0/CHANGES.md
195
+ post_install_message:
192
196
  rdoc_options: []
193
197
  require_paths:
194
198
  - lib
@@ -196,16 +200,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
200
  requirements:
197
201
  - - ">="
198
202
  - !ruby/object:Gem::Version
199
- version: '2.3'
203
+ version: '2.5'
200
204
  required_rubygems_version: !ruby/object:Gem::Requirement
201
205
  requirements:
202
- - - ">"
206
+ - - ">="
203
207
  - !ruby/object:Gem::Version
204
- version: 1.3.1
208
+ version: '0'
205
209
  requirements: []
206
- rubyforge_project:
207
- rubygems_version: 2.7.6.2
208
- signing_key:
210
+ rubygems_version: 3.0.3
211
+ signing_key:
209
212
  specification_version: 4
210
213
  summary: HTTP should be easy
211
214
  test_files:
@@ -244,8 +247,10 @@ test_files:
244
247
  - spec/support/dummy_server.rb
245
248
  - spec/support/dummy_server/servlet.rb
246
249
  - spec/support/fakeio.rb
250
+ - spec/support/fuubar.rb
247
251
  - spec/support/http_handling_shared.rb
248
252
  - spec/support/proxy_server.rb
249
253
  - spec/support/servers/config.rb
250
254
  - spec/support/servers/runner.rb
255
+ - spec/support/simplecov.rb
251
256
  - spec/support/ssl_helper.rb
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service-name: travis-pro
data/.travis.yml DELETED
@@ -1,38 +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
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.4
22
- - 2.5
23
- - 2.6
24
- - 2.7
25
-
26
- matrix:
27
- fast_finish: true
28
- include:
29
- # Only run RuboCop and Yardstick metrics on the latest Ruby
30
- - rvm: 2.7
31
- env: SUITE="rubocop"
32
- - rvm: 2.7
33
- env: SUITE="yardstick"
34
-
35
- branches:
36
- only:
37
- - master
38
- - 4-x-stable