http 2.2.2 → 3.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +46 -13
- data/.travis.yml +17 -12
- data/CHANGES.md +25 -1
- data/Gemfile +11 -4
- data/Guardfile +2 -0
- data/README.md +4 -5
- data/Rakefile +14 -13
- data/http.gemspec +3 -1
- data/lib/http.rb +1 -0
- data/lib/http/chainable.rb +15 -14
- data/lib/http/client.rb +27 -24
- data/lib/http/connection.rb +6 -4
- data/lib/http/content_type.rb +1 -0
- data/lib/http/errors.rb +3 -2
- data/lib/http/feature.rb +2 -1
- data/lib/http/features/auto_deflate.rb +77 -20
- data/lib/http/features/auto_inflate.rb +2 -1
- data/lib/http/headers.rb +3 -2
- data/lib/http/headers/known.rb +23 -22
- data/lib/http/headers/mixin.rb +1 -0
- data/lib/http/mime_type.rb +1 -0
- data/lib/http/mime_type/adapter.rb +2 -1
- data/lib/http/mime_type/json.rb +2 -1
- data/lib/http/options.rb +15 -12
- data/lib/http/redirector.rb +4 -3
- data/lib/http/request.rb +25 -10
- data/lib/http/request/body.rb +67 -0
- data/lib/http/request/writer.rb +32 -37
- data/lib/http/response.rb +17 -2
- data/lib/http/response/body.rb +16 -12
- data/lib/http/response/parser.rb +1 -0
- data/lib/http/response/status.rb +1 -0
- data/lib/http/response/status/reasons.rb +1 -0
- data/lib/http/timeout/global.rb +1 -0
- data/lib/http/timeout/null.rb +2 -1
- data/lib/http/timeout/per_operation.rb +19 -6
- data/lib/http/uri.rb +8 -2
- data/lib/http/version.rb +1 -1
- data/spec/lib/http/client_spec.rb +104 -4
- data/spec/lib/http/content_type_spec.rb +1 -0
- data/spec/lib/http/features/auto_deflate_spec.rb +32 -64
- data/spec/lib/http/features/auto_inflate_spec.rb +1 -0
- data/spec/lib/http/headers/mixin_spec.rb +1 -0
- data/spec/lib/http/headers_spec.rb +36 -35
- data/spec/lib/http/options/body_spec.rb +1 -0
- data/spec/lib/http/options/features_spec.rb +1 -0
- data/spec/lib/http/options/form_spec.rb +1 -0
- data/spec/lib/http/options/headers_spec.rb +2 -1
- data/spec/lib/http/options/json_spec.rb +1 -0
- data/spec/lib/http/options/new_spec.rb +2 -1
- data/spec/lib/http/options/proxy_spec.rb +1 -0
- data/spec/lib/http/options_spec.rb +1 -0
- data/spec/lib/http/redirector_spec.rb +1 -0
- data/spec/lib/http/request/body_spec.rb +138 -0
- data/spec/lib/http/request/writer_spec.rb +44 -74
- data/spec/lib/http/request_spec.rb +14 -0
- data/spec/lib/http/response/body_spec.rb +20 -4
- data/spec/lib/http/response/status_spec.rb +27 -26
- data/spec/lib/http/response_spec.rb +10 -0
- data/spec/lib/http/uri_spec.rb +11 -0
- data/spec/lib/http_spec.rb +18 -6
- data/spec/regression_specs.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/black_hole.rb +9 -2
- data/spec/support/capture_warning.rb +1 -0
- data/spec/support/dummy_server.rb +2 -1
- data/spec/support/dummy_server/servlet.rb +1 -1
- data/spec/support/fakeio.rb +21 -0
- data/spec/support/http_handling_shared.rb +1 -0
- data/spec/support/proxy_server.rb +1 -0
- data/spec/support/servers/config.rb +1 -0
- data/spec/support/servers/runner.rb +1 -0
- data/spec/support/ssl_helper.rb +3 -2
- metadata +20 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d74f7b02faf0fd77fd72d958ebcff214296aeca
|
4
|
+
data.tar.gz: 97f8a4bead5243682c117e8e54cf9f11edcef626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d1136aa3733a3c8873d084b09282268e60c1f6b0fe46393b31423eab90cd4c72ff321cede0d18f720ad6d8d1e712997f617f27a352815d3785058a7323b86d0
|
7
|
+
data.tar.gz: 6a678e67514d00cdf8d707f269d54a7f6c9f6a4dc0985603d2a117fe78691e5c73d7e5ae8a260b27816c01e1b1df960160310b31d64ae8474fe0bce52bce82d1
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
AllCops:
|
2
2
|
DisplayCopNames: true
|
3
3
|
|
4
|
+
## Layout ######################################################################
|
5
|
+
|
6
|
+
Layout/DotPosition:
|
7
|
+
EnforcedStyle: trailing
|
8
|
+
|
9
|
+
Layout/SpaceAroundOperators:
|
10
|
+
AllowForAlignment: true
|
11
|
+
|
12
|
+
Layout/SpaceInsideHashLiteralBraces:
|
13
|
+
EnforcedStyle: no_space
|
14
|
+
|
15
|
+
## Metrics #####################################################################
|
16
|
+
|
17
|
+
Metrics/AbcSize:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Exclude:
|
22
|
+
- spec/**/*
|
23
|
+
|
4
24
|
Metrics/BlockNesting:
|
5
25
|
Max: 2
|
6
26
|
|
@@ -8,19 +28,22 @@ Metrics/ClassLength:
|
|
8
28
|
CountComments: false
|
9
29
|
Max: 125
|
10
30
|
|
11
|
-
|
31
|
+
# TODO: Lower to 6
|
32
|
+
Metrics/CyclomaticComplexity:
|
12
33
|
Max: 8
|
13
34
|
|
14
|
-
Metrics/
|
15
|
-
Max: 8
|
35
|
+
Metrics/PerceivedComplexity:
|
36
|
+
Max: 8
|
16
37
|
|
38
|
+
# TODO: Lower to 80
|
17
39
|
Metrics/LineLength:
|
18
40
|
AllowURI: true
|
19
|
-
Max: 143
|
41
|
+
Max: 143
|
20
42
|
|
43
|
+
# TODO: Lower to 15
|
21
44
|
Metrics/MethodLength:
|
22
45
|
CountComments: false
|
23
|
-
Max: 25
|
46
|
+
Max: 25
|
24
47
|
|
25
48
|
Metrics/ModuleLength:
|
26
49
|
CountComments: false
|
@@ -30,9 +53,14 @@ Metrics/ParameterLists:
|
|
30
53
|
Max: 5
|
31
54
|
CountKeywordArgs: true
|
32
55
|
|
33
|
-
|
56
|
+
## Performance #################################################################
|
57
|
+
|
58
|
+
# XXX: requires ruby 2.4+
|
59
|
+
Performance/RegexpMatch:
|
34
60
|
Enabled: false
|
35
61
|
|
62
|
+
## Style #######################################################################
|
63
|
+
|
36
64
|
Style/CollectionMethods:
|
37
65
|
PreferredMethods:
|
38
66
|
collect: 'map'
|
@@ -43,9 +71,6 @@ Style/CollectionMethods:
|
|
43
71
|
Style/Documentation:
|
44
72
|
Enabled: false
|
45
73
|
|
46
|
-
Style/DotPosition:
|
47
|
-
EnforcedStyle: trailing
|
48
|
-
|
49
74
|
Style/DoubleNegation:
|
50
75
|
Enabled: false
|
51
76
|
|
@@ -58,20 +83,28 @@ Style/Encoding:
|
|
58
83
|
Style/EmptyCaseCondition:
|
59
84
|
Enabled: false
|
60
85
|
|
86
|
+
# XXX: Lots of times it suggests making code terrible to read.
|
87
|
+
Style/GuardClause:
|
88
|
+
Enabled: false
|
89
|
+
|
61
90
|
Style/HashSyntax:
|
62
91
|
EnforcedStyle: hash_rockets
|
63
92
|
|
64
93
|
Style/Lambda:
|
65
94
|
Enabled: false
|
66
95
|
|
67
|
-
Style/
|
68
|
-
|
96
|
+
Style/OptionHash:
|
97
|
+
Enabled: true
|
69
98
|
|
70
|
-
|
71
|
-
|
99
|
+
# XXX: requires ruby 2.3+
|
100
|
+
Style/SafeNavigation:
|
101
|
+
Enabled: false
|
72
102
|
|
73
103
|
Style/StringLiterals:
|
74
104
|
EnforcedStyle: double_quotes
|
75
105
|
|
76
106
|
Style/TrivialAccessors:
|
77
107
|
Enabled: false
|
108
|
+
|
109
|
+
Style/YodaCondition:
|
110
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,30 +1,35 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
|
4
|
+
cache: bundler
|
5
|
+
|
4
6
|
before_install:
|
5
|
-
- gem update --system
|
7
|
+
- gem update --system
|
6
8
|
- gem --version
|
7
|
-
- gem install bundler --
|
9
|
+
- gem install bundler --no-rdoc --no-ri
|
8
10
|
- bundle --version
|
9
11
|
|
10
|
-
install: bundle
|
12
|
+
install: bundle install --without development doc
|
11
13
|
|
12
|
-
script: bundle
|
14
|
+
script: bundle exec rake
|
13
15
|
|
14
|
-
env:
|
15
|
-
global:
|
16
|
-
- JRUBY_OPTS="$JRUBY_OPTS --debug"
|
16
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
17
17
|
|
18
18
|
rvm:
|
19
|
-
|
20
|
-
-
|
21
|
-
- 2.1
|
19
|
+
# Include JRuby first because it takes the longest
|
20
|
+
- jruby-9.1.13.0
|
22
21
|
- 2.2
|
23
|
-
- 2.3.
|
24
|
-
- 2.4.
|
22
|
+
- 2.3.4
|
23
|
+
- 2.4.1
|
25
24
|
|
26
25
|
matrix:
|
27
26
|
fast_finish: true
|
27
|
+
include:
|
28
|
+
# Only run RuboCop and Yardstick metrics on the latest Ruby
|
29
|
+
- rvm: 2.4.1
|
30
|
+
env: SUITE="rubocop"
|
31
|
+
- rvm: 2.4.1
|
32
|
+
env: SUITE="yardstick"
|
28
33
|
|
29
34
|
branches:
|
30
35
|
only:
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## 3.0.0.pre
|
2
|
+
|
3
|
+
* Drop support of Ruby `2.0` and Ruby `2.1`.
|
4
|
+
([@ixti])
|
5
|
+
|
6
|
+
* [#410](https://github.com/httprb/http/pull/410)
|
7
|
+
Infer `Host` header upon redirects.
|
8
|
+
([@janko-m])
|
9
|
+
|
10
|
+
* [#409](https://github.com/httprb/http/pull/409)
|
11
|
+
Enables request body streaming on any IO object.
|
12
|
+
([@janko-m])
|
13
|
+
|
14
|
+
* [#413](https://github.com/httprb/http/issues/413),
|
15
|
+
[#414](https://github.com/httprb/http/pull/414)
|
16
|
+
Fix encoding of body chunks.
|
17
|
+
([@janko-m])
|
18
|
+
|
19
|
+
* [#368](https://github.com/httprb/http/pull/368),
|
20
|
+
[#357](https://github.com/httprb/http/issues/357)
|
21
|
+
Fix timeout issue.
|
22
|
+
([@HoneyryderChuck])
|
23
|
+
|
24
|
+
|
1
25
|
## 2.2.2 (2017-04-27)
|
2
26
|
|
3
27
|
* [#404](https://github.com/httprb/http/issues/404),
|
@@ -593,4 +617,4 @@ end
|
|
593
617
|
[@britishtea]: https://github.com/britishtea
|
594
618
|
[@janko-m]: https://github.com/janko-m
|
595
619
|
[@Bonias]: https://github.com/Bonias
|
596
|
-
[@
|
620
|
+
[@HoneyryderChuck]: https://github.com/HoneyryderChuck
|
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
ruby RUBY_VERSION
|
3
5
|
|
@@ -15,15 +17,20 @@ group :development do
|
|
15
17
|
end
|
16
18
|
|
17
19
|
group :test do
|
20
|
+
gem "activemodel", :require => false # Used by certificate_authority
|
21
|
+
gem "certificate_authority", :require => false
|
22
|
+
|
18
23
|
gem "backports"
|
24
|
+
|
19
25
|
gem "coveralls", :require => false
|
20
26
|
gem "simplecov", ">= 0.9"
|
21
|
-
|
22
|
-
gem "rspec",
|
27
|
+
|
28
|
+
gem "rspec", "~> 3.0"
|
23
29
|
gem "rspec-its"
|
30
|
+
|
31
|
+
gem "rubocop", "= 0.49.1"
|
32
|
+
|
24
33
|
gem "yardstick"
|
25
|
-
gem "certificate_authority", :require => false
|
26
|
-
gem "activemodel", :require => false # Used by certificate_authority
|
27
34
|
end
|
28
35
|
|
29
36
|
group :doc do
|
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/httprb/http/badge.svg?branch=master)](https://coveralls.io/r/httprb/http)
|
7
7
|
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/httprb/http/blob/master/LICENSE.txt)
|
8
8
|
|
9
|
-
_NOTE: This is the
|
9
|
+
_NOTE: This is the 3.x **development** branch. For the 2.x **stable** branch, please see:_
|
10
10
|
|
11
|
-
https://github.com/httprb/http/
|
11
|
+
https://github.com/httprb/http/tree/2-x-stable
|
12
12
|
|
13
13
|
## About
|
14
14
|
|
@@ -160,10 +160,9 @@ and call `#readpartial` on it repeatedly until it returns `nil`:
|
|
160
160
|
This library aims to support and is [tested against][travis] the following Ruby
|
161
161
|
versions:
|
162
162
|
|
163
|
-
* Ruby 2.0.0
|
164
|
-
* Ruby 2.1.x
|
165
163
|
* Ruby 2.2.x
|
166
164
|
* Ruby 2.3.x
|
165
|
+
* Ruby 2.4.x
|
167
166
|
* JRuby 9.1.x.x
|
168
167
|
|
169
168
|
If something doesn't work on one of these versions, it's a bug.
|
@@ -194,5 +193,5 @@ dropped.
|
|
194
193
|
|
195
194
|
## Copyright
|
196
195
|
|
197
|
-
Copyright (c) 2011-
|
196
|
+
Copyright (c) 2011-2017 Tony Arcieri, Alexey V. Zapparov, Erik Michaels-Ober, Zachary Anker.
|
198
197
|
See LICENSE.txt for further details.
|
data/Rakefile
CHANGED
@@ -1,19 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "bundler/gem_tasks"
|
3
4
|
|
4
5
|
require "rspec/core/rake_task"
|
5
6
|
RSpec::Core::RakeTask.new
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
begin
|
10
|
-
require "rubocop/rake_task"
|
11
|
-
RuboCop::RakeTask.new
|
12
|
-
rescue LoadError
|
13
|
-
task :rubocop do
|
14
|
-
$stderr.puts "RuboCop is disabled"
|
15
|
-
end
|
16
|
-
end
|
8
|
+
require "rubocop/rake_task"
|
9
|
+
RuboCop::RakeTask.new
|
17
10
|
|
18
11
|
require "yardstick/rake/measurement"
|
19
12
|
Yardstick::Rake::Measurement.new do |measurement|
|
@@ -36,7 +29,7 @@ task :generate_status_codes do
|
|
36
29
|
code = e.xpath("xmlns:value").text.to_s
|
37
30
|
desc = e.xpath("xmlns:description").text.to_s
|
38
31
|
|
39
|
-
next a if
|
32
|
+
next a if %w[Unassigned (Unused)].include?(desc)
|
40
33
|
|
41
34
|
a << "#{code} => #{desc.inspect}"
|
42
35
|
end
|
@@ -68,4 +61,12 @@ task :generate_status_codes do
|
|
68
61
|
end
|
69
62
|
end
|
70
63
|
|
71
|
-
|
64
|
+
if ENV["CI"].nil?
|
65
|
+
task :default => %i[spec rubocop verify_measurements]
|
66
|
+
else
|
67
|
+
case ENV["SUITE"]
|
68
|
+
when "rubocop" then task :default => :rubocop
|
69
|
+
when "yardstick" then task :default => :verify_measurements
|
70
|
+
else task :default => :spec
|
71
|
+
end
|
72
|
+
end
|
data/http.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path("../lib", __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require "http/version"
|
@@ -26,7 +28,7 @@ Gem::Specification.new do |gem|
|
|
26
28
|
gem.required_ruby_version = ">= 2.0"
|
27
29
|
|
28
30
|
gem.add_runtime_dependency "http_parser.rb", "~> 0.6.0"
|
29
|
-
gem.add_runtime_dependency "http-form_data", "
|
31
|
+
gem.add_runtime_dependency "http-form_data", ">= 2.0.0-pre2", "< 3"
|
30
32
|
gem.add_runtime_dependency "http-cookie", "~> 1.0"
|
31
33
|
gem.add_runtime_dependency "addressable", "~> 2.3"
|
32
34
|
|
data/lib/http.rb
CHANGED
data/lib/http/chainable.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "base64"
|
3
4
|
|
4
5
|
require "http/headers"
|
@@ -8,70 +9,70 @@ module HTTP
|
|
8
9
|
# Request a get sans response body
|
9
10
|
# @param uri
|
10
11
|
# @option options [Hash]
|
11
|
-
def head(uri, options = {})
|
12
|
+
def head(uri, options = {}) # rubocop:disable Style/OptionHash
|
12
13
|
request :head, uri, options
|
13
14
|
end
|
14
15
|
|
15
16
|
# Get a resource
|
16
17
|
# @param uri
|
17
18
|
# @option options [Hash]
|
18
|
-
def get(uri, options = {})
|
19
|
+
def get(uri, options = {}) # rubocop:disable Style/OptionHash
|
19
20
|
request :get, uri, options
|
20
21
|
end
|
21
22
|
|
22
23
|
# Post to a resource
|
23
24
|
# @param uri
|
24
25
|
# @option options [Hash]
|
25
|
-
def post(uri, options = {})
|
26
|
+
def post(uri, options = {}) # rubocop:disable Style/OptionHash
|
26
27
|
request :post, uri, options
|
27
28
|
end
|
28
29
|
|
29
30
|
# Put to a resource
|
30
31
|
# @param uri
|
31
32
|
# @option options [Hash]
|
32
|
-
def put(uri, options = {})
|
33
|
+
def put(uri, options = {}) # rubocop:disable Style/OptionHash
|
33
34
|
request :put, uri, options
|
34
35
|
end
|
35
36
|
|
36
37
|
# Delete a resource
|
37
38
|
# @param uri
|
38
39
|
# @option options [Hash]
|
39
|
-
def delete(uri, options = {})
|
40
|
+
def delete(uri, options = {}) # rubocop:disable Style/OptionHash
|
40
41
|
request :delete, uri, options
|
41
42
|
end
|
42
43
|
|
43
44
|
# Echo the request back to the client
|
44
45
|
# @param uri
|
45
46
|
# @option options [Hash]
|
46
|
-
def trace(uri, options = {})
|
47
|
+
def trace(uri, options = {}) # rubocop:disable Style/OptionHash
|
47
48
|
request :trace, uri, options
|
48
49
|
end
|
49
50
|
|
50
51
|
# Return the methods supported on the given URI
|
51
52
|
# @param uri
|
52
53
|
# @option options [Hash]
|
53
|
-
def options(uri, options = {})
|
54
|
+
def options(uri, options = {}) # rubocop:disable Style/OptionHash
|
54
55
|
request :options, uri, options
|
55
56
|
end
|
56
57
|
|
57
58
|
# Convert to a transparent TCP/IP tunnel
|
58
59
|
# @param uri
|
59
60
|
# @option options [Hash]
|
60
|
-
def connect(uri, options = {})
|
61
|
+
def connect(uri, options = {}) # rubocop:disable Style/OptionHash
|
61
62
|
request :connect, uri, options
|
62
63
|
end
|
63
64
|
|
64
65
|
# Apply partial modifications to a resource
|
65
66
|
# @param uri
|
66
67
|
# @option options [Hash]
|
67
|
-
def patch(uri, options = {})
|
68
|
+
def patch(uri, options = {}) # rubocop:disable Style/OptionHash
|
68
69
|
request :patch, uri, options
|
69
70
|
end
|
70
71
|
|
71
72
|
# Make an HTTP request with the given verb
|
72
73
|
# @param uri
|
73
74
|
# @option options [Hash]
|
74
|
-
def request(verb, uri, options = {})
|
75
|
+
def request(verb, uri, options = {}) # rubocop:disable Style/OptionHash
|
75
76
|
branch(options).request verb, uri
|
76
77
|
end
|
77
78
|
|
@@ -85,7 +86,7 @@ module HTTP
|
|
85
86
|
# @option options [Float] :read Read timeout
|
86
87
|
# @option options [Float] :write Write timeout
|
87
88
|
# @option options [Float] :connect Connect timeout
|
88
|
-
def timeout(klass, options = {})
|
89
|
+
def timeout(klass, options = {}) # rubocop:disable Style/OptionHash
|
89
90
|
if klass.is_a? Hash
|
90
91
|
options = klass
|
91
92
|
klass = :per_operation
|
@@ -98,7 +99,7 @@ module HTTP
|
|
98
99
|
else raise ArgumentError, "Unsupported Timeout class: #{klass}"
|
99
100
|
end
|
100
101
|
|
101
|
-
[
|
102
|
+
%i[read write connect].each do |k|
|
102
103
|
next unless options.key? k
|
103
104
|
options["#{k}_timeout".to_sym] = options.delete k
|
104
105
|
end
|
@@ -170,8 +171,8 @@ module HTTP
|
|
170
171
|
# @param opts
|
171
172
|
# @return [HTTP::Client]
|
172
173
|
# @see Redirector#initialize
|
173
|
-
def follow(
|
174
|
-
branch default_options.with_follow
|
174
|
+
def follow(options = {}) # rubocop:disable Style/OptionHash
|
175
|
+
branch default_options.with_follow options
|
175
176
|
end
|
176
177
|
|
177
178
|
# Make a request with the given headers
|