http 4.4.1 → 5.1.1

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +85 -0
  3. data/.gitignore +6 -10
  4. data/.rspec +0 -4
  5. data/.rubocop/layout.yml +8 -0
  6. data/.rubocop/style.yml +32 -0
  7. data/.rubocop.yml +8 -110
  8. data/.rubocop_todo.yml +206 -0
  9. data/.yardopts +1 -1
  10. data/CHANGES.md +200 -3
  11. data/Gemfile +18 -10
  12. data/LICENSE.txt +1 -1
  13. data/README.md +48 -86
  14. data/Rakefile +2 -10
  15. data/SECURITY.md +5 -0
  16. data/http.gemspec +9 -8
  17. data/lib/http/chainable.rb +23 -17
  18. data/lib/http/client.rb +44 -34
  19. data/lib/http/connection.rb +11 -7
  20. data/lib/http/content_type.rb +12 -7
  21. data/lib/http/errors.rb +3 -0
  22. data/lib/http/feature.rb +3 -1
  23. data/lib/http/features/auto_deflate.rb +6 -6
  24. data/lib/http/features/auto_inflate.rb +6 -7
  25. data/lib/http/features/instrumentation.rb +1 -1
  26. data/lib/http/features/logging.rb +19 -21
  27. data/lib/http/headers.rb +50 -13
  28. data/lib/http/mime_type/adapter.rb +3 -1
  29. data/lib/http/mime_type/json.rb +1 -0
  30. data/lib/http/options.rb +5 -8
  31. data/lib/http/redirector.rb +55 -4
  32. data/lib/http/request/body.rb +1 -0
  33. data/lib/http/request/writer.rb +9 -4
  34. data/lib/http/request.rb +28 -11
  35. data/lib/http/response/body.rb +6 -4
  36. data/lib/http/response/inflater.rb +1 -1
  37. data/lib/http/response/parser.rb +74 -62
  38. data/lib/http/response/status.rb +4 -3
  39. data/lib/http/response.rb +44 -18
  40. data/lib/http/timeout/global.rb +20 -36
  41. data/lib/http/timeout/null.rb +2 -1
  42. data/lib/http/timeout/per_operation.rb +32 -55
  43. data/lib/http/uri.rb +51 -6
  44. data/lib/http/version.rb +1 -1
  45. data/spec/lib/http/client_spec.rb +155 -30
  46. data/spec/lib/http/connection_spec.rb +8 -5
  47. data/spec/lib/http/features/auto_inflate_spec.rb +3 -2
  48. data/spec/lib/http/features/instrumentation_spec.rb +27 -21
  49. data/spec/lib/http/features/logging_spec.rb +8 -10
  50. data/spec/lib/http/headers_spec.rb +53 -18
  51. data/spec/lib/http/options/headers_spec.rb +1 -1
  52. data/spec/lib/http/options/merge_spec.rb +16 -16
  53. data/spec/lib/http/redirector_spec.rb +133 -3
  54. data/spec/lib/http/request/body_spec.rb +3 -3
  55. data/spec/lib/http/request/writer_spec.rb +25 -2
  56. data/spec/lib/http/request_spec.rb +5 -5
  57. data/spec/lib/http/response/body_spec.rb +5 -5
  58. data/spec/lib/http/response/parser_spec.rb +33 -4
  59. data/spec/lib/http/response/status_spec.rb +3 -3
  60. data/spec/lib/http/response_spec.rb +80 -3
  61. data/spec/lib/http/uri_spec.rb +39 -0
  62. data/spec/lib/http_spec.rb +30 -3
  63. data/spec/spec_helper.rb +21 -21
  64. data/spec/support/black_hole.rb +1 -1
  65. data/spec/support/dummy_server/servlet.rb +19 -6
  66. data/spec/support/dummy_server.rb +7 -7
  67. data/spec/support/fuubar.rb +21 -0
  68. data/spec/support/http_handling_shared.rb +5 -5
  69. data/spec/support/simplecov.rb +19 -0
  70. data/spec/support/ssl_helper.rb +4 -4
  71. metadata +22 -14
  72. data/.coveralls.yml +0 -1
  73. data/.travis.yml +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cce9a8685f3b60f994e77174f79c2306f607d62016bf64b74fcebc4f86377ec0
4
- data.tar.gz: 353702b62a1b9d3b2ea86ac5ac3ad88e9efa734c77e180128fa06c6c301895d3
3
+ metadata.gz: ef55bbff996952784d0917931b8eaa6f12a1adfc9cc480daf098cbc8cd8f6107
4
+ data.tar.gz: 222f8e8723969f89994fe2a0692c41786e450c200c45b84f5c8418f736254a64
5
5
  SHA512:
6
- metadata.gz: 84ddc4cf98e603d175a9ecb8db03abd32187888070abd96a437c4121750ac2b86b6cada5d00d527b398ff4a403c2b6448d45bed61c45dbd3be8658f4ad38b121
7
- data.tar.gz: 750edced9ae715483d750f0b18777f84a4ee24848ec761c67d2c5b89d00ebbc99fbc1e02932d3d30a33eaea43e1d081ba97bcacaf2231f6693e50d218ee24e87
6
+ metadata.gz: 49b0c9e508fb02fca9d9e8a26d707202c5ac67bbdf73fce15b616b321545a3a32be96eb9e23f4d389687ad1720372eaba4412e18d800c5d29fab5bb0f4bc0d93
7
+ data.tar.gz: 1b2e22b2b33abe8059e78535556a15c53959b321fb225cd84153d5a8ea608ba4d03ead9cf018720f63b1e7c27c477f8c3f1b151cae60f2d50b6811e7dd9f5bcc
@@ -0,0 +1,85 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ env:
10
+ BUNDLE_WITHOUT: "development"
11
+ JRUBY_OPTS: "--dev --debug"
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ${{ matrix.os }}
16
+
17
+ strategy:
18
+ matrix:
19
+ ruby: [ ruby-2.6, ruby-2.7, ruby-3.0, ruby-3.1 ]
20
+ os: [ ubuntu-latest ]
21
+
22
+ steps:
23
+ - uses: actions/checkout@v3
24
+
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby }}
28
+ bundler-cache: true
29
+
30
+ - name: bundle exec rspec
31
+ run: bundle exec rspec --format progress --force-colour
32
+
33
+ - name: Prepare Coveralls test coverage report
34
+ uses: coverallsapp/github-action@v1.1.2
35
+ with:
36
+ github-token: ${{ secrets.GITHUB_TOKEN }}
37
+ flag-name: "${{ matrix.ruby }} @${{ matrix.os }}"
38
+ path-to-lcov: ./coverage/lcov/lcov.info
39
+ parallel: true
40
+
41
+ test-flaky:
42
+ runs-on: ${{ matrix.os }}
43
+
44
+ strategy:
45
+ matrix:
46
+ ruby: [ jruby-9.3 ]
47
+ os: [ ubuntu-latest ]
48
+
49
+ steps:
50
+ - uses: actions/checkout@v3
51
+
52
+ - uses: ruby/setup-ruby@v1
53
+ with:
54
+ ruby-version: ${{ matrix.ruby }}
55
+ bundler-cache: true
56
+
57
+ - name: bundle exec rspec
58
+ continue-on-error: true
59
+ run: bundle exec rspec --format progress --force-colour
60
+
61
+ coveralls:
62
+ needs: test
63
+ runs-on: ubuntu-latest
64
+ steps:
65
+ - name: Finalize Coveralls test coverage report
66
+ uses: coverallsapp/github-action@master
67
+ with:
68
+ github-token: ${{ secrets.GITHUB_TOKEN }}
69
+ parallel-finished: true
70
+
71
+ lint:
72
+ runs-on: ubuntu-latest
73
+
74
+ steps:
75
+ - uses: actions/checkout@v3
76
+
77
+ - uses: ruby/setup-ruby@v1
78
+ with:
79
+ ruby-version: 2.6
80
+ bundler-cache: true
81
+
82
+ - name: bundle exec rubocop
83
+ run: bundle exec rubocop --format progress --color
84
+
85
+ - run: bundle exec rake verify_measurements
data/.gitignore CHANGED
@@ -1,19 +1,15 @@
1
1
  *.gem
2
- .bundle
3
2
  .config
4
3
  .rvmrc
5
- .ruby-version
6
4
  .yardoc
7
- Gemfile.lock
8
5
  InstalledFiles
9
6
  _yardoc
10
- coverage
7
+
8
+ .bundle
9
+ .ruby-version
11
10
  doc
12
- lib/bundler/man
13
- measurement
11
+ coverage
14
12
  pkg
15
- rdoc
16
- spec/reports
17
- test/tmp
18
- test/version_tmp
13
+ spec/examples.txt
19
14
  tmp
15
+ Gemfile.lock
data/.rspec CHANGED
@@ -1,5 +1 @@
1
- --backtrace
2
- --color
3
- --format=documentation
4
- --order random
5
1
  --require spec_helper
@@ -0,0 +1,8 @@
1
+ Layout/DotPosition:
2
+ Enabled: true
3
+ EnforcedStyle: leading
4
+
5
+ Layout/HashAlignment:
6
+ Enabled: true
7
+ EnforcedColonStyle: table
8
+ EnforcedHashRocketStyle: table
@@ -0,0 +1,32 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Style/DocumentDynamicEvalDefinition:
5
+ Enabled: true
6
+ Exclude:
7
+ - 'spec/**/*.rb'
8
+
9
+ Style/FormatStringToken:
10
+ Enabled: true
11
+ EnforcedStyle: unannotated
12
+
13
+ Style/HashSyntax:
14
+ Enabled: true
15
+ EnforcedStyle: hash_rockets
16
+
17
+ Style/OptionHash:
18
+ Enabled: true
19
+
20
+ Style/RescueStandardError:
21
+ Enabled: true
22
+ EnforcedStyle: implicit
23
+
24
+ Style/StringLiterals:
25
+ Enabled: true
26
+ EnforcedStyle: double_quotes
27
+
28
+ Style/WordArray:
29
+ Enabled: true
30
+
31
+ Style/YodaCondition:
32
+ Enabled: false
data/.rubocop.yml CHANGED
@@ -1,112 +1,10 @@
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+ - .rubocop/layout.yml
4
+ - .rubocop/style.yml
5
+
1
6
  AllCops:
2
- TargetRubyVersion: 2.3
7
+ DefaultFormatter: fuubar
3
8
  DisplayCopNames: true
4
-
5
- ## Layout ######################################################################
6
-
7
- Layout/DotPosition:
8
- EnforcedStyle: trailing
9
-
10
- Layout/SpaceAroundOperators:
11
- AllowForAlignment: true
12
-
13
- Layout/SpaceInsideHashLiteralBraces:
14
- EnforcedStyle: no_space
15
-
16
- ## Metrics #####################################################################
17
-
18
- Metrics/AbcSize:
19
- Enabled: false
20
-
21
- Metrics/BlockLength:
22
- Exclude:
23
- - "spec/**/*"
24
- - "**/*.gemspec"
25
-
26
- Metrics/BlockNesting:
27
- Max: 2
28
-
29
- Metrics/ClassLength:
30
- CountComments: false
31
- Max: 125
32
-
33
- # TODO: Lower to 6
34
- Metrics/CyclomaticComplexity:
35
- Max: 8
36
-
37
- Metrics/PerceivedComplexity:
38
- Max: 8
39
-
40
- # TODO: Lower to 80
41
- Metrics/LineLength:
42
- AllowURI: true
43
- Max: 143
44
-
45
- # TODO: Lower to 15
46
- Metrics/MethodLength:
47
- CountComments: false
48
- Max: 25
49
-
50
- Metrics/ModuleLength:
51
- CountComments: false
52
- Max: 120
53
-
54
- Metrics/ParameterLists:
55
- Max: 5
56
- CountKeywordArgs: true
57
-
58
- ## Performance #################################################################
59
-
60
- # XXX: requires ruby 2.4+
61
- Performance/RegexpMatch:
62
- Enabled: false
63
-
64
- ## Style #######################################################################
65
-
66
- Style/CollectionMethods:
67
- PreferredMethods:
68
- collect: 'map'
69
- reduce: 'inject'
70
- find: 'detect'
71
- find_all: 'select'
72
-
73
- Style/Documentation:
74
- Enabled: false
75
-
76
- Style/DoubleNegation:
77
- Enabled: false
78
-
79
- Style/EachWithObject:
80
- Enabled: false
81
-
82
- Style/Encoding:
83
- Enabled: false
84
-
85
- Style/EmptyCaseCondition:
86
- Enabled: false
87
-
88
- # XXX: Lots of times it suggests making code terrible to read.
89
- Style/GuardClause:
90
- Enabled: false
91
-
92
- Style/HashSyntax:
93
- EnforcedStyle: hash_rockets
94
-
95
- Style/Lambda:
96
- Enabled: false
97
-
98
- Style/OptionHash:
99
- Enabled: true
100
-
101
- # XXX: requires ruby 2.3+
102
- Style/SafeNavigation:
103
- Enabled: false
104
-
105
- Style/StringLiterals:
106
- EnforcedStyle: double_quotes
107
-
108
- Style/TrivialAccessors:
109
- Enabled: false
110
-
111
- Style/YodaCondition:
112
- Enabled: false
9
+ NewCops: enable
10
+ TargetRubyVersion: 2.6
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,206 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 100`
3
+ # on 2022-06-16 14:35:44 UTC using RuboCop version 1.30.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: Include.
12
+ # Include: **/*.gemspec
13
+ Gemspec/DeprecatedAttributeAssignment:
14
+ Exclude:
15
+ - 'http.gemspec'
16
+
17
+ # Offense count: 53
18
+ # This cop supports safe autocorrection (--autocorrect).
19
+ # Configuration parameters: EnforcedStyle.
20
+ # SupportedStyles: leading, trailing
21
+ Layout/DotPosition:
22
+ Exclude:
23
+ - 'lib/http/options.rb'
24
+ - 'spec/lib/http/client_spec.rb'
25
+ - 'spec/lib/http/features/auto_deflate_spec.rb'
26
+ - 'spec/lib/http/headers_spec.rb'
27
+ - 'spec/lib/http/options/features_spec.rb'
28
+ - 'spec/lib/http/redirector_spec.rb'
29
+ - 'spec/lib/http/response/body_spec.rb'
30
+ - 'spec/lib/http_spec.rb'
31
+ - 'spec/support/http_handling_shared.rb'
32
+
33
+ # Offense count: 176
34
+ # This cop supports safe autocorrection (--autocorrect).
35
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
36
+ # SupportedStyles: space, no_space, compact
37
+ # SupportedStylesForEmptyBraces: space, no_space
38
+ Layout/SpaceInsideHashLiteralBraces:
39
+ Exclude:
40
+ - 'lib/http/chainable.rb'
41
+ - 'spec/lib/http/client_spec.rb'
42
+ - 'spec/lib/http/features/auto_inflate_spec.rb'
43
+ - 'spec/lib/http/features/instrumentation_spec.rb'
44
+ - 'spec/lib/http/features/logging_spec.rb'
45
+ - 'spec/lib/http/headers_spec.rb'
46
+ - 'spec/lib/http/options/features_spec.rb'
47
+ - 'spec/lib/http/options/merge_spec.rb'
48
+ - 'spec/lib/http/options/new_spec.rb'
49
+ - 'spec/lib/http/redirector_spec.rb'
50
+ - 'spec/lib/http/request_spec.rb'
51
+ - 'spec/lib/http/response_spec.rb'
52
+ - 'spec/lib/http_spec.rb'
53
+ - 'spec/support/dummy_server/servlet.rb'
54
+ - 'spec/support/http_handling_shared.rb'
55
+ - 'spec/support/ssl_helper.rb'
56
+
57
+ # Offense count: 4
58
+ Lint/MissingSuper:
59
+ Exclude:
60
+ - 'lib/http/features/auto_deflate.rb'
61
+ - 'lib/http/features/instrumentation.rb'
62
+ - 'lib/http/features/logging.rb'
63
+ - 'lib/http/features/normalize_uri.rb'
64
+
65
+ # Offense count: 8
66
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes, Max.
67
+ Metrics/AbcSize:
68
+ Exclude:
69
+ - 'lib/http/chainable.rb'
70
+ - 'lib/http/client.rb'
71
+ - 'lib/http/connection.rb'
72
+ - 'lib/http/features/auto_deflate.rb'
73
+ - 'lib/http/redirector.rb'
74
+ - 'lib/http/request.rb'
75
+ - 'lib/http/response.rb'
76
+
77
+ # Offense count: 70
78
+ # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
79
+ # IgnoredMethods: refine
80
+ Metrics/BlockLength:
81
+ Exclude:
82
+ - '**/*.gemspec'
83
+ - 'spec/lib/http/client_spec.rb'
84
+ - 'spec/lib/http/connection_spec.rb'
85
+ - 'spec/lib/http/content_type_spec.rb'
86
+ - 'spec/lib/http/features/auto_deflate_spec.rb'
87
+ - 'spec/lib/http/features/auto_inflate_spec.rb'
88
+ - 'spec/lib/http/features/instrumentation_spec.rb'
89
+ - 'spec/lib/http/features/logging_spec.rb'
90
+ - 'spec/lib/http/headers/mixin_spec.rb'
91
+ - 'spec/lib/http/headers_spec.rb'
92
+ - 'spec/lib/http/options/merge_spec.rb'
93
+ - 'spec/lib/http/redirector_spec.rb'
94
+ - 'spec/lib/http/request/body_spec.rb'
95
+ - 'spec/lib/http/request/writer_spec.rb'
96
+ - 'spec/lib/http/request_spec.rb'
97
+ - 'spec/lib/http/response/body_spec.rb'
98
+ - 'spec/lib/http/response/parser_spec.rb'
99
+ - 'spec/lib/http/response/status_spec.rb'
100
+ - 'spec/lib/http/response_spec.rb'
101
+ - 'spec/lib/http/uri_spec.rb'
102
+ - 'spec/lib/http_spec.rb'
103
+ - 'spec/support/http_handling_shared.rb'
104
+
105
+ # Offense count: 4
106
+ # Configuration parameters: CountComments, Max, CountAsOne.
107
+ Metrics/ClassLength:
108
+ Exclude:
109
+ - 'lib/http/client.rb'
110
+ - 'lib/http/connection.rb'
111
+ - 'lib/http/headers.rb'
112
+ - 'lib/http/request.rb'
113
+
114
+ # Offense count: 2
115
+ # Configuration parameters: IgnoredMethods, Max.
116
+ Metrics/CyclomaticComplexity:
117
+ Exclude:
118
+ - 'lib/http/chainable.rb'
119
+ - 'lib/http/client.rb'
120
+
121
+ # Offense count: 18
122
+ # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
123
+ Metrics/MethodLength:
124
+ Exclude:
125
+ - 'lib/http/chainable.rb'
126
+ - 'lib/http/client.rb'
127
+ - 'lib/http/connection.rb'
128
+ - 'lib/http/features/auto_deflate.rb'
129
+ - 'lib/http/features/auto_inflate.rb'
130
+ - 'lib/http/headers.rb'
131
+ - 'lib/http/options.rb'
132
+ - 'lib/http/redirector.rb'
133
+ - 'lib/http/request.rb'
134
+ - 'lib/http/response.rb'
135
+ - 'lib/http/response/body.rb'
136
+ - 'lib/http/timeout/global.rb'
137
+
138
+ # Offense count: 1
139
+ # Configuration parameters: CountComments, Max, CountAsOne.
140
+ Metrics/ModuleLength:
141
+ Exclude:
142
+ - 'lib/http/chainable.rb'
143
+
144
+ # Offense count: 1
145
+ Security/CompoundHash:
146
+ Exclude:
147
+ - 'lib/http/uri.rb'
148
+
149
+ # Offense count: 2
150
+ # This cop supports safe autocorrection (--autocorrect).
151
+ # Configuration parameters: EnforcedStyle.
152
+ # SupportedStyles: separated, grouped
153
+ Style/AccessorGrouping:
154
+ Exclude:
155
+ - 'lib/http/request.rb'
156
+
157
+ # Offense count: 4
158
+ # This cop supports safe autocorrection (--autocorrect).
159
+ Style/EmptyCaseCondition:
160
+ Exclude:
161
+ - 'lib/http/client.rb'
162
+ - 'lib/http/headers.rb'
163
+ - 'lib/http/options.rb'
164
+ - 'lib/http/response/status.rb'
165
+
166
+ # Offense count: 5
167
+ # This cop supports safe autocorrection (--autocorrect).
168
+ Style/Encoding:
169
+ Exclude:
170
+ - 'spec/lib/http/client_spec.rb'
171
+ - 'spec/lib/http/request/writer_spec.rb'
172
+ - 'spec/lib/http/request_spec.rb'
173
+ - 'spec/lib/http_spec.rb'
174
+ - 'spec/support/dummy_server/servlet.rb'
175
+
176
+ # Offense count: 17
177
+ # Configuration parameters: SuspiciousParamNames, Allowlist.
178
+ # SuspiciousParamNames: options, opts, args, params, parameters
179
+ Style/OptionHash:
180
+ Exclude:
181
+ - 'lib/http/chainable.rb'
182
+ - 'lib/http/client.rb'
183
+ - 'lib/http/feature.rb'
184
+ - 'lib/http/options.rb'
185
+ - 'lib/http/redirector.rb'
186
+ - 'lib/http/timeout/null.rb'
187
+ - 'spec/support/dummy_server.rb'
188
+
189
+ # Offense count: 4
190
+ # Configuration parameters: AllowedMethods.
191
+ # AllowedMethods: respond_to_missing?
192
+ Style/OptionalBooleanParameter:
193
+ Exclude:
194
+ - 'lib/http/timeout/global.rb'
195
+ - 'lib/http/timeout/null.rb'
196
+ - 'lib/http/timeout/per_operation.rb'
197
+ - 'lib/http/uri.rb'
198
+
199
+ # Offense count: 3
200
+ # This cop supports safe autocorrection (--autocorrect).
201
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
202
+ # URISchemes: http, https
203
+ Layout/LineLength:
204
+ Exclude:
205
+ - 'lib/http/chainable.rb'
206
+ - 'spec/lib/http/options/proxy_spec.rb'
data/.yardopts CHANGED
@@ -1,2 +1,2 @@
1
- --markup-provider=redcarpet
1
+ --markup-provider=kramdown
2
2
  --markup=markdown