http 4.0.0 → 4.0.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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGES.md +19 -0
- data/README.md +4 -4
- data/http.gemspec +1 -1
- data/lib/http/chainable.rb +6 -10
- data/lib/http/version.rb +1 -1
- data/spec/lib/http/features/logging_spec.rb +35 -42
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b4b0a992f25d4d013ad17cc731ef43b9a77bce5326989ddfcce64e0dac136fc
|
4
|
+
data.tar.gz: 7db71f7b6038af882c3951c894d38eff1e54642fbd1025644cb2756e6ea3abe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1566faa35cdf35dcef2c54cd88c7a9f3768c0e6ed1627e1fbc8af49d0a3b1aab84675bc065a28213f85d43d672779c6778f5dd661b51360116e8bedbc9dc48de
|
7
|
+
data.tar.gz: 61b6da199935be564e142a2a791374a652bda85ee142384a7d21fa62fbbf6b86167239332f10e67af39a0b719222f216eca3f7390ac72b7f624b95139eb8b852
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
|
+
## 4.0.1 (2019-01-14)
|
2
|
+
|
3
|
+
* [#515](https://github.com/httprb/http/pull/515)
|
4
|
+
Fix `#build_request` and `#request` to respect default options.
|
5
|
+
([@RickCSong])
|
6
|
+
|
7
|
+
|
1
8
|
## 4.0.0 (2018-10-15)
|
2
9
|
|
10
|
+
* [#482](https://github.com/httprb/http/pull/482)
|
11
|
+
[#499](https://github.com/httprb/http/pull/499)
|
12
|
+
Introduce new features injection API with 2 new feaures: instrumentation
|
13
|
+
(compatible with ActiveSupport::Notification) and logging.
|
14
|
+
([@paul])
|
15
|
+
|
16
|
+
* [#473](https://github.com/httprb/http/pull/473)
|
17
|
+
Handle early responses.
|
18
|
+
([@janko-m])
|
19
|
+
|
3
20
|
* [#468](https://github.com/httprb/http/pull/468)
|
4
21
|
Rewind `HTTP::Request::Body#source` once `#each` is complete.
|
5
22
|
([@ixti])
|
@@ -709,3 +726,5 @@ end
|
|
709
726
|
[@scarfacedeb]: https://github.com/scarfacedeb
|
710
727
|
[@mikegee]: https://github.com/mikegee
|
711
728
|
[@tycoon]: https://github.com/tycooon
|
729
|
+
[@paul]: https://github.com/paul
|
730
|
+
[@RickCSong]: https://github.com/RickCSong
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# 
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/http)
|
4
|
-
[](https://travis-ci.org/httprb/http)
|
5
|
+
[](https://codeclimate.com/github/httprb/http)
|
6
|
+
[](https://coveralls.io/r/httprb/http)
|
7
7
|
[](https://github.com/httprb/http/blob/master/LICENSE.txt)
|
8
8
|
|
9
9
|
[Documentation]
|
10
10
|
|
11
|
-
_NOTE: This is the 4.x **
|
11
|
+
_NOTE: This is the 4.x **stable** branch. For the 3.x **stable** branch, please see:_
|
12
12
|
|
13
13
|
https://github.com/httprb/http/tree/3-x-stable
|
14
14
|
|
data/http.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.require_paths = ["lib"]
|
26
26
|
gem.version = HTTP::VERSION
|
27
27
|
|
28
|
-
gem.required_ruby_version = ">= 2.
|
28
|
+
gem.required_ruby_version = ">= 2.3"
|
29
29
|
|
30
30
|
gem.add_runtime_dependency "http_parser.rb", "~> 0.6.0"
|
31
31
|
gem.add_runtime_dependency "http-form_data", "~> 2.0"
|
data/lib/http/chainable.rb
CHANGED
@@ -70,19 +70,15 @@ module HTTP
|
|
70
70
|
end
|
71
71
|
|
72
72
|
# Make an HTTP request with the given verb
|
73
|
-
# @param
|
74
|
-
|
75
|
-
|
76
|
-
def request(verb, uri, options = {}) # rubocop:disable Style/OptionHash
|
77
|
-
branch(options).request verb, uri
|
73
|
+
# @param (see Client#request)
|
74
|
+
def request(*args)
|
75
|
+
branch(default_options).request(*args)
|
78
76
|
end
|
79
77
|
|
80
78
|
# Prepare an HTTP request with the given verb
|
81
|
-
# @param
|
82
|
-
|
83
|
-
|
84
|
-
def build_request(verb, uri, options = {}) # rubocop:disable Style/OptionHash
|
85
|
-
branch(options).build_request verb, uri
|
79
|
+
# @param (see Client#build_request)
|
80
|
+
def build_request(*args)
|
81
|
+
branch(default_options).build_request(*args)
|
86
82
|
end
|
87
83
|
|
88
84
|
# @overload timeout(options = {})
|
data/lib/http/version.rb
CHANGED
@@ -1,34 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "logger"
|
4
|
+
|
3
5
|
RSpec.describe HTTP::Features::Logging do
|
4
|
-
subject(:feature)
|
5
|
-
|
6
|
+
subject(:feature) do
|
7
|
+
logger = Logger.new(logdev)
|
8
|
+
logger.formatter = ->(severity, _, _, message) do
|
9
|
+
format("** %s **\n%s\n", severity, message)
|
10
|
+
end
|
11
|
+
|
12
|
+
described_class.new(:logger => logger)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:logdev) { StringIO.new }
|
6
16
|
|
7
17
|
describe "logging the request" do
|
8
18
|
let(:request) do
|
9
19
|
HTTP::Request.new(
|
10
|
-
:verb
|
11
|
-
:uri
|
12
|
-
:headers
|
13
|
-
:body
|
20
|
+
:verb => :post,
|
21
|
+
:uri => "https://example.com/",
|
22
|
+
:headers => {:accept => "application/json"},
|
23
|
+
:body => '{"hello": "world!"}'
|
14
24
|
)
|
15
25
|
end
|
16
26
|
|
17
27
|
it "should log the request" do
|
18
28
|
feature.wrap_request(request)
|
19
29
|
|
20
|
-
expect(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
expect(logdev.string).to eq <<~OUTPUT
|
31
|
+
** INFO **
|
32
|
+
> POST https://example.com/
|
33
|
+
** DEBUG **
|
34
|
+
Accept: application/json
|
35
|
+
Host: example.com
|
36
|
+
User-Agent: http.rb/#{HTTP::VERSION}
|
27
37
|
|
28
|
-
|
29
|
-
|
30
|
-
]
|
31
|
-
)
|
38
|
+
{"hello": "world!"}
|
39
|
+
OUTPUT
|
32
40
|
end
|
33
41
|
end
|
34
42
|
|
@@ -36,39 +44,24 @@ RSpec.describe HTTP::Features::Logging do
|
|
36
44
|
let(:response) do
|
37
45
|
HTTP::Response.new(
|
38
46
|
:version => "1.1",
|
39
|
-
:uri
|
40
|
-
:status
|
47
|
+
:uri => "https://example.com",
|
48
|
+
:status => 200,
|
41
49
|
:headers => {:content_type => "application/json"},
|
42
|
-
:body
|
50
|
+
:body => '{"success": true}'
|
43
51
|
)
|
44
52
|
end
|
45
53
|
|
46
54
|
it "should log the response" do
|
47
55
|
feature.wrap_response(response)
|
48
56
|
|
49
|
-
expect(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
{"success": true}
|
56
|
-
REQ
|
57
|
-
]
|
58
|
-
)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class TestLogger
|
63
|
-
attr_reader :output
|
64
|
-
def initialize
|
65
|
-
@output = []
|
66
|
-
end
|
57
|
+
expect(logdev.string).to eq <<~OUTPUT
|
58
|
+
** INFO **
|
59
|
+
< 200 OK
|
60
|
+
** DEBUG **
|
61
|
+
Content-Type: application/json
|
67
62
|
|
68
|
-
|
69
|
-
|
70
|
-
@output << (block ? block.call : args)
|
71
|
-
end
|
63
|
+
{"success": true}
|
64
|
+
OUTPUT
|
72
65
|
end
|
73
66
|
end
|
74
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2019-01-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: http_parser.rb
|
@@ -190,15 +190,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
190
|
requirements:
|
191
191
|
- - ">="
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: '2.
|
193
|
+
version: '2.3'
|
194
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
195
|
requirements:
|
196
196
|
- - ">="
|
197
197
|
- !ruby/object:Gem::Version
|
198
198
|
version: '0'
|
199
199
|
requirements: []
|
200
|
-
|
201
|
-
rubygems_version: 2.7.6
|
200
|
+
rubygems_version: 3.0.1
|
202
201
|
signing_key:
|
203
202
|
specification_version: 4
|
204
203
|
summary: HTTP should be easy
|