http 5.2.0 → 6.0.2

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.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +110 -13
  4. data/http.gemspec +38 -35
  5. data/lib/http/base64.rb +22 -0
  6. data/lib/http/chainable/helpers.rb +62 -0
  7. data/lib/http/chainable/verbs.rb +136 -0
  8. data/lib/http/chainable.rb +249 -129
  9. data/lib/http/client.rb +158 -127
  10. data/lib/http/connection/internals.rb +141 -0
  11. data/lib/http/connection.rb +128 -97
  12. data/lib/http/content_type.rb +61 -6
  13. data/lib/http/errors.rb +41 -1
  14. data/lib/http/feature.rb +67 -6
  15. data/lib/http/features/auto_deflate.rb +124 -17
  16. data/lib/http/features/auto_inflate.rb +38 -15
  17. data/lib/http/features/caching/entry.rb +178 -0
  18. data/lib/http/features/caching/in_memory_store.rb +63 -0
  19. data/lib/http/features/caching.rb +216 -0
  20. data/lib/http/features/digest_auth.rb +234 -0
  21. data/lib/http/features/instrumentation.rb +97 -17
  22. data/lib/http/features/logging.rb +183 -5
  23. data/lib/http/features/normalize_uri.rb +17 -0
  24. data/lib/http/features/raise_error.rb +37 -0
  25. data/lib/http/form_data/composite_io.rb +106 -0
  26. data/lib/http/form_data/file.rb +95 -0
  27. data/lib/http/form_data/multipart/param.rb +62 -0
  28. data/lib/http/form_data/multipart.rb +106 -0
  29. data/lib/http/form_data/part.rb +52 -0
  30. data/lib/http/form_data/readable.rb +58 -0
  31. data/lib/http/form_data/urlencoded.rb +175 -0
  32. data/lib/http/form_data/version.rb +8 -0
  33. data/lib/http/form_data.rb +102 -0
  34. data/lib/http/headers/known.rb +3 -0
  35. data/lib/http/headers/normalizer.rb +50 -0
  36. data/lib/http/headers.rb +185 -92
  37. data/lib/http/mime_type/adapter.rb +24 -9
  38. data/lib/http/mime_type/json.rb +19 -4
  39. data/lib/http/mime_type.rb +21 -3
  40. data/lib/http/options/definitions.rb +189 -0
  41. data/lib/http/options.rb +172 -125
  42. data/lib/http/redirector.rb +80 -75
  43. data/lib/http/request/body.rb +87 -6
  44. data/lib/http/request/builder.rb +184 -0
  45. data/lib/http/request/proxy.rb +83 -0
  46. data/lib/http/request/writer.rb +78 -17
  47. data/lib/http/request.rb +216 -99
  48. data/lib/http/response/body.rb +103 -18
  49. data/lib/http/response/inflater.rb +35 -7
  50. data/lib/http/response/parser.rb +98 -4
  51. data/lib/http/response/status/reasons.rb +2 -4
  52. data/lib/http/response/status.rb +141 -31
  53. data/lib/http/response.rb +219 -61
  54. data/lib/http/retriable/delay_calculator.rb +91 -0
  55. data/lib/http/retriable/errors.rb +35 -0
  56. data/lib/http/retriable/performer.rb +197 -0
  57. data/lib/http/session.rb +280 -0
  58. data/lib/http/timeout/global.rb +147 -34
  59. data/lib/http/timeout/null.rb +155 -9
  60. data/lib/http/timeout/per_operation.rb +139 -18
  61. data/lib/http/uri/normalizer.rb +82 -0
  62. data/lib/http/uri/parsing.rb +182 -0
  63. data/lib/http/uri.rb +289 -124
  64. data/lib/http/version.rb +2 -1
  65. data/lib/http.rb +11 -1
  66. data/sig/http.rbs +1619 -0
  67. metadata +42 -175
  68. data/.github/workflows/ci.yml +0 -67
  69. data/.gitignore +0 -15
  70. data/.rspec +0 -1
  71. data/.rubocop/layout.yml +0 -8
  72. data/.rubocop/metrics.yml +0 -4
  73. data/.rubocop/style.yml +0 -32
  74. data/.rubocop.yml +0 -11
  75. data/.rubocop_todo.yml +0 -206
  76. data/.yardopts +0 -2
  77. data/CHANGELOG.md +0 -41
  78. data/CHANGES_OLD.md +0 -1002
  79. data/CONTRIBUTING.md +0 -26
  80. data/Gemfile +0 -50
  81. data/Guardfile +0 -18
  82. data/Rakefile +0 -64
  83. data/SECURITY.md +0 -17
  84. data/lib/http/headers/mixin.rb +0 -34
  85. data/logo.png +0 -0
  86. data/spec/lib/http/client_spec.rb +0 -556
  87. data/spec/lib/http/connection_spec.rb +0 -88
  88. data/spec/lib/http/content_type_spec.rb +0 -47
  89. data/spec/lib/http/features/auto_deflate_spec.rb +0 -77
  90. data/spec/lib/http/features/auto_inflate_spec.rb +0 -86
  91. data/spec/lib/http/features/instrumentation_spec.rb +0 -81
  92. data/spec/lib/http/features/logging_spec.rb +0 -65
  93. data/spec/lib/http/headers/mixin_spec.rb +0 -36
  94. data/spec/lib/http/headers_spec.rb +0 -527
  95. data/spec/lib/http/options/body_spec.rb +0 -15
  96. data/spec/lib/http/options/features_spec.rb +0 -33
  97. data/spec/lib/http/options/form_spec.rb +0 -15
  98. data/spec/lib/http/options/headers_spec.rb +0 -24
  99. data/spec/lib/http/options/json_spec.rb +0 -15
  100. data/spec/lib/http/options/merge_spec.rb +0 -68
  101. data/spec/lib/http/options/new_spec.rb +0 -30
  102. data/spec/lib/http/options/proxy_spec.rb +0 -20
  103. data/spec/lib/http/options_spec.rb +0 -13
  104. data/spec/lib/http/redirector_spec.rb +0 -529
  105. data/spec/lib/http/request/body_spec.rb +0 -211
  106. data/spec/lib/http/request/writer_spec.rb +0 -121
  107. data/spec/lib/http/request_spec.rb +0 -234
  108. data/spec/lib/http/response/body_spec.rb +0 -85
  109. data/spec/lib/http/response/parser_spec.rb +0 -74
  110. data/spec/lib/http/response/status_spec.rb +0 -253
  111. data/spec/lib/http/response_spec.rb +0 -262
  112. data/spec/lib/http/uri/normalizer_spec.rb +0 -95
  113. data/spec/lib/http/uri_spec.rb +0 -71
  114. data/spec/lib/http_spec.rb +0 -506
  115. data/spec/regression_specs.rb +0 -24
  116. data/spec/spec_helper.rb +0 -88
  117. data/spec/support/black_hole.rb +0 -13
  118. data/spec/support/capture_warning.rb +0 -10
  119. data/spec/support/dummy_server/servlet.rb +0 -190
  120. data/spec/support/dummy_server.rb +0 -43
  121. data/spec/support/fakeio.rb +0 -21
  122. data/spec/support/fuubar.rb +0 -21
  123. data/spec/support/http_handling_shared.rb +0 -190
  124. data/spec/support/proxy_server.rb +0 -39
  125. data/spec/support/servers/config.rb +0 -11
  126. data/spec/support/servers/runner.rb +0 -19
  127. data/spec/support/simplecov.rb +0 -19
  128. data/spec/support/ssl_helper.rb +0 -104
data/CONTRIBUTING.md DELETED
@@ -1,26 +0,0 @@
1
- # Help and Discussion
2
-
3
- If you need help or just want to talk about the http.rb,
4
- visit the http.rb Google Group:
5
-
6
- https://groups.google.com/forum/#!forum/httprb
7
-
8
- You can join by email by sending a message to:
9
-
10
- [httprb+subscribe@googlegroups.com](mailto:httprb+subscribe@googlegroups.com)
11
-
12
-
13
- # Reporting bugs
14
-
15
- The best way to report a bug is by providing a reproduction script. A half
16
- working script with comments for the parts you were unable to automate is still
17
- appreciated.
18
-
19
- In any case, specify following info in description of your issue:
20
-
21
- - What you're trying to accomplish
22
- - What you expected to happen
23
- - What actually happened
24
- - The exception backtrace(s), if any
25
- - Version of gem or commit ref you are using
26
- - Version of ruby you are using
data/Gemfile DELETED
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
- ruby RUBY_VERSION
5
-
6
- gem "rake"
7
-
8
- # Ruby 3.0 does not ship it anymore.
9
- # TODO: We should probably refactor specs to avoid need for it.
10
- gem "webrick"
11
-
12
- group :development do
13
- gem "guard-rspec", :require => false
14
- gem "nokogiri", :require => false
15
- gem "pry", :require => false
16
-
17
- # RSpec formatter
18
- gem "fuubar", :require => false
19
-
20
- platform :mri do
21
- gem "pry-byebug"
22
- end
23
- end
24
-
25
- group :test do
26
- gem "certificate_authority", "~> 1.0", :require => false
27
-
28
- gem "backports"
29
-
30
- gem "rubocop", "~> 1.30.0"
31
- gem "rubocop-performance"
32
- gem "rubocop-rake"
33
- gem "rubocop-rspec"
34
-
35
- gem "simplecov", :require => false
36
- gem "simplecov-lcov", :require => false
37
-
38
- gem "rspec", "~> 3.10"
39
- gem "rspec-its"
40
-
41
- gem "yardstick"
42
- end
43
-
44
- group :doc do
45
- gem "kramdown"
46
- gem "yard"
47
- end
48
-
49
- # Specify your gem's dependencies in http.gemspec
50
- gemspec
data/Guardfile DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # More info at https://github.com/guard/guard#readme
4
-
5
- guard :rspec, :cmd => "GUARD_RSPEC=1 bundle exec rspec --no-profile" do
6
- require "guard/rspec/dsl"
7
- dsl = Guard::RSpec::Dsl.new(self)
8
-
9
- # RSpec files
10
- rspec = dsl.rspec
11
- watch(rspec.spec_helper) { rspec.spec_dir }
12
- watch(rspec.spec_support) { rspec.spec_dir }
13
- watch(rspec.spec_files)
14
-
15
- # Ruby files
16
- ruby = dsl.ruby
17
- dsl.watch_spec_files_for(ruby.lib_files)
18
- end
data/Rakefile DELETED
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
-
5
- require "rspec/core/rake_task"
6
- RSpec::Core::RakeTask.new
7
-
8
- require "rubocop/rake_task"
9
- RuboCop::RakeTask.new
10
-
11
- require "yardstick/rake/measurement"
12
- Yardstick::Rake::Measurement.new do |measurement|
13
- measurement.output = "measurement/report.txt"
14
- end
15
-
16
- require "yardstick/rake/verify"
17
- Yardstick::Rake::Verify.new do |verify|
18
- verify.require_exact_threshold = false
19
- verify.threshold = 55
20
- end
21
-
22
- task :generate_status_codes do
23
- require "http"
24
- require "nokogiri"
25
-
26
- url = "http://www.iana.org/assignments/http-status-codes/http-status-codes.xml"
27
- xml = Nokogiri::XML HTTP.get url
28
- arr = xml.xpath("//xmlns:record").reduce([]) do |a, e|
29
- code = e.xpath("xmlns:value").text.to_s
30
- desc = e.xpath("xmlns:description").text.to_s
31
-
32
- next a if %w[Unassigned (Unused)].include?(desc)
33
-
34
- a << "#{code} => #{desc.inspect}"
35
- end
36
-
37
- File.open("./lib/http/response/status/reasons.rb", "w") do |io|
38
- io.puts <<~TPL
39
- # AUTO-GENERATED FILE, DO NOT CHANGE IT MANUALLY
40
-
41
- require "delegate"
42
-
43
- module HTTP
44
- class Response
45
- class Status < ::Delegator
46
- # Code to Reason map
47
- #
48
- # @example Usage
49
- #
50
- # REASONS[400] # => "Bad Request"
51
- # REASONS[414] # => "Request-URI Too Long"
52
- #
53
- # @return [Hash<Fixnum => String>]
54
- REASONS = {
55
- #{arr.join ",\n "}
56
- }.each { |_, v| v.freeze }.freeze
57
- end
58
- end
59
- end
60
- TPL
61
- end
62
- end
63
-
64
- task :default => %i[spec rubocop verify_measurements]
data/SECURITY.md DELETED
@@ -1,17 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- Security updates are applied only to the most recent release.
6
-
7
- ## Reporting a Vulnerability
8
-
9
- If you have discovered a security vulnerability in this project, please report
10
- it privately. **Do not disclose it as a public issue.** This gives us time to
11
- work with you to fix the issue before public exposure, reducing the chance that
12
- the exploit will be used before a patch is released.
13
-
14
- Please disclose it at [security advisory](https://github.com/httprb/http/security/advisories/new).
15
-
16
- This project is maintained by a team of volunteers on a reasonable-effort basis.
17
- As such, please give us at least 90 days to work on a fix before public exposure.
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "forwardable"
4
-
5
- module HTTP
6
- class Headers
7
- # Provides shared behavior for {HTTP::Request} and {HTTP::Response}.
8
- # Expects `@headers` to be an instance of {HTTP::Headers}.
9
- #
10
- # @example Usage
11
- #
12
- # class MyHttpRequest
13
- # include HTTP::Headers::Mixin
14
- #
15
- # def initialize
16
- # @headers = HTTP::Headers.new
17
- # end
18
- # end
19
- module Mixin
20
- extend Forwardable
21
-
22
- # @return [HTTP::Headers]
23
- attr_reader :headers
24
-
25
- # @!method []
26
- # (see HTTP::Headers#[])
27
- def_delegator :headers, :[]
28
-
29
- # @!method []=
30
- # (see HTTP::Headers#[]=)
31
- def_delegator :headers, :[]=
32
- end
33
- end
34
- end
data/logo.png DELETED
Binary file