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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d09142fafcb9b5715621ad330639c7c03ea5b280d6a7d1024029bb1125d1db1e
4
- data.tar.gz: 48d33d13b9009d302de0b7cefa097e2891032ac8b961a803441776908b707531
3
+ metadata.gz: cc5c5ebaa25630442cf182d6cc9925d112dccbfeb4030f07951cfaad72f35bde
4
+ data.tar.gz: bdb8d0148f8fd0cdb3634ab743db153a998bfa8f8be28295bb8d95bae5833d68
5
5
  SHA512:
6
- metadata.gz: 9e446e54d2066969541b1ef5593aed989d1ff0b0d7228bf56ab61483dab1e52374bca34792c616930b689d1c684ab09694e49b07dce0b6e2bdc2d82de3504ebc
7
- data.tar.gz: bc2877d15a9e06c3b105aa542da78f0497eee9bc81f26fd07867cef3f4be3d1b005060ff4e4d95133442cbd6b5edefb6adc39a4c04cb54fdcb8b91852de3036b
6
+ metadata.gz: d74104f964a90c0d0689df9f5af8082fcd5d4902dfa46bf9bdc22ed1a2a86d48211c29fd42b20c037afee958f89ef1f5e7d442285083f169852ccf31bd522818
7
+ data.tar.gz: 6bac3882bc504513b6a05eb7facf5823b4f46ea55a737933b75305a336b23a97a21914f77378f8a67d7ab262a3b16ec46c592f224036491254f1bb0363e3d294
@@ -0,0 +1,65 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
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.5, ruby-2.6, ruby-2.7, ruby-3.0 ]
20
+ os: [ ubuntu-latest ]
21
+
22
+ steps:
23
+ - uses: actions/checkout@v2
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
+ coveralls:
42
+ needs: test
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - name: Finalize Coveralls test coverage report
46
+ uses: coverallsapp/github-action@master
47
+ with:
48
+ github-token: ${{ secrets.GITHUB_TOKEN }}
49
+ parallel-finished: true
50
+
51
+ lint:
52
+ runs-on: ubuntu-latest
53
+
54
+ steps:
55
+ - uses: actions/checkout@v2
56
+
57
+ - uses: ruby/setup-ruby@v1
58
+ with:
59
+ ruby-version: 2.5
60
+ bundler-cache: true
61
+
62
+ - name: bundle exec rubocop
63
+ run: bundle exec rubocop --format progress --color
64
+
65
+ - 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
data/.rubocop.yml CHANGED
@@ -1,127 +1,10 @@
1
- require: rubocop-performance
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+ - .rubocop/layout.yml
4
+ - .rubocop/style.yml
2
5
 
3
6
  AllCops:
4
- TargetRubyVersion: 2.3
7
+ DefaultFormatter: fuubar
5
8
  DisplayCopNames: true
6
-
7
- ## Layout ######################################################################
8
-
9
- Layout/AlignHash:
10
- EnforcedColonStyle: table
11
- EnforcedHashRocketStyle: table
12
-
13
- Layout/DotPosition:
14
- EnforcedStyle: trailing
15
-
16
- Layout/SpaceAroundOperators:
17
- AllowForAlignment: true
18
-
19
- Layout/SpaceInsideHashLiteralBraces:
20
- EnforcedStyle: no_space
21
-
22
- ## Metrics #####################################################################
23
-
24
- Metrics/AbcSize:
25
- Enabled: false
26
-
27
- Metrics/BlockLength:
28
- Exclude:
29
- - "spec/**/*"
30
- - "**/*.gemspec"
31
-
32
- Metrics/BlockNesting:
33
- Max: 2
34
-
35
- Metrics/ClassLength:
36
- CountComments: false
37
- Max: 125
38
-
39
- # TODO: Lower to 6
40
- Metrics/CyclomaticComplexity:
41
- Max: 8
42
-
43
- Metrics/PerceivedComplexity:
44
- Max: 8
45
-
46
- # TODO: Lower to 80
47
- Metrics/LineLength:
48
- AllowURI: true
49
- Max: 143
50
-
51
- # TODO: Lower to 15
52
- Metrics/MethodLength:
53
- CountComments: false
54
- Max: 25
55
-
56
- Metrics/ModuleLength:
57
- CountComments: false
58
- Max: 120
59
-
60
- Metrics/ParameterLists:
61
- Max: 5
62
- CountKeywordArgs: true
63
-
64
- ## Performance #################################################################
65
-
66
- # XXX: requires ruby 2.4+
67
- Performance/RegexpMatch:
68
- Enabled: false
69
-
70
- Performance/UnfreezeString:
71
- Enabled: false
72
-
73
- ## Style #######################################################################
74
-
75
- Style/CollectionMethods:
76
- PreferredMethods:
77
- collect: 'map'
78
- reduce: 'inject'
79
- find: 'detect'
80
- find_all: 'select'
81
-
82
- Style/Documentation:
83
- Enabled: false
84
-
85
- Style/DoubleNegation:
86
- Enabled: false
87
-
88
- Style/EachWithObject:
89
- Enabled: false
90
-
91
- Style/Encoding:
92
- Enabled: false
93
-
94
- Style/EmptyCaseCondition:
95
- Enabled: false
96
-
97
- # XXX: Lots of times it suggests making code terrible to read.
98
- Style/GuardClause:
99
- Enabled: false
100
-
101
- Style/HashSyntax:
102
- EnforcedStyle: hash_rockets
103
-
104
- Style/Lambda:
105
- Enabled: false
106
-
107
- Style/OptionHash:
108
- Enabled: true
109
-
110
- # XXX: requires ruby 2.3+
111
- Style/SafeNavigation:
112
- Enabled: false
113
-
114
- Style/StringLiterals:
115
- EnforcedStyle: double_quotes
116
-
117
- Style/TrivialAccessors:
118
- Enabled: false
119
-
120
- Style/YodaCondition:
121
- Enabled: false
122
-
123
- Style/FormatStringToken:
124
- EnforcedStyle: unannotated
125
-
126
- Style/RescueStandardError:
127
- EnforcedStyle: implicit
9
+ NewCops: enable
10
+ TargetRubyVersion: 2.5
@@ -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_todo.yml ADDED
@@ -0,0 +1,192 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 42`
3
+ # on 2021-04-10 09:49:03 UTC using RuboCop version 1.12.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: 53
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: EnforcedStyle.
12
+ # SupportedStyles: leading, trailing
13
+ Layout/DotPosition:
14
+ Exclude:
15
+ - 'lib/http/options.rb'
16
+ - 'spec/lib/http/client_spec.rb'
17
+ - 'spec/lib/http/features/auto_deflate_spec.rb'
18
+ - 'spec/lib/http/headers_spec.rb'
19
+ - 'spec/lib/http/options/features_spec.rb'
20
+ - 'spec/lib/http/redirector_spec.rb'
21
+ - 'spec/lib/http/response/body_spec.rb'
22
+ - 'spec/lib/http_spec.rb'
23
+ - 'spec/support/http_handling_shared.rb'
24
+
25
+ # Offense count: 174
26
+ # Cop supports --auto-correct.
27
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
28
+ # SupportedStyles: space, no_space, compact
29
+ # SupportedStylesForEmptyBraces: space, no_space
30
+ Layout/SpaceInsideHashLiteralBraces:
31
+ Exclude:
32
+ - 'lib/http/chainable.rb'
33
+ - 'spec/lib/http/client_spec.rb'
34
+ - 'spec/lib/http/features/auto_inflate_spec.rb'
35
+ - 'spec/lib/http/features/instrumentation_spec.rb'
36
+ - 'spec/lib/http/features/logging_spec.rb'
37
+ - 'spec/lib/http/headers_spec.rb'
38
+ - 'spec/lib/http/options/features_spec.rb'
39
+ - 'spec/lib/http/options/merge_spec.rb'
40
+ - 'spec/lib/http/options/new_spec.rb'
41
+ - 'spec/lib/http/redirector_spec.rb'
42
+ - 'spec/lib/http/request_spec.rb'
43
+ - 'spec/lib/http/response_spec.rb'
44
+ - 'spec/lib/http_spec.rb'
45
+ - 'spec/support/dummy_server/servlet.rb'
46
+ - 'spec/support/http_handling_shared.rb'
47
+ - 'spec/support/ssl_helper.rb'
48
+
49
+ # Offense count: 4
50
+ Lint/MissingSuper:
51
+ Exclude:
52
+ - 'lib/http/features/auto_deflate.rb'
53
+ - 'lib/http/features/instrumentation.rb'
54
+ - 'lib/http/features/logging.rb'
55
+ - 'lib/http/features/normalize_uri.rb'
56
+
57
+ # Offense count: 8
58
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes, Max.
59
+ Metrics/AbcSize:
60
+ Exclude:
61
+ - 'lib/http/chainable.rb'
62
+ - 'lib/http/client.rb'
63
+ - 'lib/http/connection.rb'
64
+ - 'lib/http/features/auto_deflate.rb'
65
+ - 'lib/http/redirector.rb'
66
+ - 'lib/http/request.rb'
67
+ - 'lib/http/response.rb'
68
+
69
+ # Offense count: 66
70
+ # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
71
+ # IgnoredMethods: refine
72
+ Metrics/BlockLength:
73
+ Exclude:
74
+ - '**/*.gemspec'
75
+ - 'spec/lib/http/client_spec.rb'
76
+ - 'spec/lib/http/connection_spec.rb'
77
+ - 'spec/lib/http/content_type_spec.rb'
78
+ - 'spec/lib/http/features/auto_deflate_spec.rb'
79
+ - 'spec/lib/http/features/auto_inflate_spec.rb'
80
+ - 'spec/lib/http/features/instrumentation_spec.rb'
81
+ - 'spec/lib/http/features/logging_spec.rb'
82
+ - 'spec/lib/http/headers/mixin_spec.rb'
83
+ - 'spec/lib/http/headers_spec.rb'
84
+ - 'spec/lib/http/options/merge_spec.rb'
85
+ - 'spec/lib/http/redirector_spec.rb'
86
+ - 'spec/lib/http/request/body_spec.rb'
87
+ - 'spec/lib/http/request/writer_spec.rb'
88
+ - 'spec/lib/http/request_spec.rb'
89
+ - 'spec/lib/http/response/body_spec.rb'
90
+ - 'spec/lib/http/response/parser_spec.rb'
91
+ - 'spec/lib/http/response/status_spec.rb'
92
+ - 'spec/lib/http/response_spec.rb'
93
+ - 'spec/lib/http_spec.rb'
94
+ - 'spec/support/http_handling_shared.rb'
95
+
96
+ # Offense count: 4
97
+ # Configuration parameters: CountComments, Max, CountAsOne.
98
+ Metrics/ClassLength:
99
+ Exclude:
100
+ - 'lib/http/client.rb'
101
+ - 'lib/http/connection.rb'
102
+ - 'lib/http/headers.rb'
103
+ - 'lib/http/request.rb'
104
+
105
+ # Offense count: 2
106
+ # Configuration parameters: IgnoredMethods, Max.
107
+ Metrics/CyclomaticComplexity:
108
+ Exclude:
109
+ - 'lib/http/chainable.rb'
110
+ - 'lib/http/client.rb'
111
+
112
+ # Offense count: 19
113
+ # Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, IgnoredMethods.
114
+ Metrics/MethodLength:
115
+ Exclude:
116
+ - 'lib/http/chainable.rb'
117
+ - 'lib/http/client.rb'
118
+ - 'lib/http/connection.rb'
119
+ - 'lib/http/features/auto_deflate.rb'
120
+ - 'lib/http/features/auto_inflate.rb'
121
+ - 'lib/http/headers.rb'
122
+ - 'lib/http/options.rb'
123
+ - 'lib/http/redirector.rb'
124
+ - 'lib/http/request.rb'
125
+ - 'lib/http/response.rb'
126
+ - 'lib/http/response/body.rb'
127
+ - 'lib/http/timeout/global.rb'
128
+
129
+ # Offense count: 1
130
+ # Configuration parameters: CountComments, Max, CountAsOne.
131
+ Metrics/ModuleLength:
132
+ Exclude:
133
+ - 'lib/http/chainable.rb'
134
+
135
+ # Offense count: 2
136
+ # Cop supports --auto-correct.
137
+ # Configuration parameters: EnforcedStyle.
138
+ # SupportedStyles: separated, grouped
139
+ Style/AccessorGrouping:
140
+ Exclude:
141
+ - 'lib/http/request.rb'
142
+
143
+ # Offense count: 4
144
+ # Cop supports --auto-correct.
145
+ Style/EmptyCaseCondition:
146
+ Exclude:
147
+ - 'lib/http/client.rb'
148
+ - 'lib/http/headers.rb'
149
+ - 'lib/http/options.rb'
150
+ - 'lib/http/response/status.rb'
151
+
152
+ # Offense count: 5
153
+ # Cop supports --auto-correct.
154
+ Style/Encoding:
155
+ Exclude:
156
+ - 'spec/lib/http/client_spec.rb'
157
+ - 'spec/lib/http/request/writer_spec.rb'
158
+ - 'spec/lib/http/request_spec.rb'
159
+ - 'spec/lib/http_spec.rb'
160
+ - 'spec/support/dummy_server/servlet.rb'
161
+
162
+ # Offense count: 17
163
+ # Configuration parameters: SuspiciousParamNames.
164
+ # SuspiciousParamNames: options, opts, args, params, parameters
165
+ Style/OptionHash:
166
+ Exclude:
167
+ - 'lib/http/chainable.rb'
168
+ - 'lib/http/client.rb'
169
+ - 'lib/http/feature.rb'
170
+ - 'lib/http/options.rb'
171
+ - 'lib/http/redirector.rb'
172
+ - 'lib/http/timeout/null.rb'
173
+ - 'spec/support/dummy_server.rb'
174
+
175
+ # Offense count: 4
176
+ # Configuration parameters: AllowedMethods.
177
+ # AllowedMethods: respond_to_missing?
178
+ Style/OptionalBooleanParameter:
179
+ Exclude:
180
+ - 'lib/http/timeout/global.rb'
181
+ - 'lib/http/timeout/null.rb'
182
+ - 'lib/http/timeout/per_operation.rb'
183
+ - 'lib/http/uri.rb'
184
+
185
+ # Offense count: 3
186
+ # Cop supports --auto-correct.
187
+ # Configuration parameters: AutoCorrect, Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
188
+ # URISchemes: http, https
189
+ Layout/LineLength:
190
+ Exclude:
191
+ - 'lib/http/chainable.rb'
192
+ - 'spec/lib/http/options/proxy_spec.rb'