restify 1.15.0 → 1.15.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/CHANGELOG.md +8 -0
- data/lib/restify/adapter/typhoeus.rb +6 -5
- data/lib/restify/version.rb +1 -1
- data/spec/restify/features/request_errors_spec.rb +19 -0
- data/spec/spec_helper.rb +9 -2
- data/spec/support/stub_server.rb +15 -11
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95d9cf12fd58e2f17bd1d3c046dfda23eaa38ec2fb99fe0c9b7e1034e014cd1f
|
4
|
+
data.tar.gz: b995cf5d935ba1c83b403fedf18d4c35154ea0ad60d4be0437fa98c89281d687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96b5f22cc74ca967876f2ecc86bf30c70fa21ceee6f8726117862ad0e94a6319a9384673cd83a4222bd40b49f4b6eeb48cdec7bd5d1e94ac70fcdab787a8ed5b
|
7
|
+
data.tar.gz: 98199df1ecf1b9467b609ae57f58f2ae459f42f7121c1947763a9d49acb7224d6b8dc50088e74cd7f563719fb81f507d88fca2252a823856e57bbf995db5cbbe
|
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
18
18
|
### Breaks
|
19
19
|
|
20
20
|
|
21
|
+
## 1.15.1 - (2021-07-15)
|
22
|
+
---
|
23
|
+
|
24
|
+
### Fixes
|
25
|
+
* Typhoeus internal exception when request timed out
|
26
|
+
|
27
|
+
|
21
28
|
## 1.15.0 - (2021-07-09)
|
22
29
|
---
|
23
30
|
|
@@ -33,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
33
40
|
|
34
41
|
|
35
42
|
## 1.14.0 - (2020-12-15)
|
43
|
+
---
|
36
44
|
|
37
45
|
### New
|
38
46
|
* Allow making requests with non-JSON bodies and custom content types (#42)
|
@@ -49,7 +49,8 @@ module Restify
|
|
49
49
|
debug 'request:add',
|
50
50
|
tag: request.object_id,
|
51
51
|
method: request.method.upcase,
|
52
|
-
url: request.uri
|
52
|
+
url: request.uri,
|
53
|
+
timeout: request.timeout
|
53
54
|
|
54
55
|
@queue << convert(request, writer)
|
55
56
|
|
@@ -75,11 +76,11 @@ module Restify
|
|
75
76
|
req.on_complete do |response|
|
76
77
|
debug 'request:complete',
|
77
78
|
tag: request.object_id,
|
78
|
-
status: response.code
|
79
|
+
status: response.code,
|
80
|
+
message: response.return_message,
|
81
|
+
timeout: response.timed_out?
|
79
82
|
|
80
|
-
if response.timed_out?
|
81
|
-
writer.reject Restify::Timeout.new request
|
82
|
-
elsif response.code.zero?
|
83
|
+
if response.timed_out? || response.code.zero?
|
83
84
|
writer.reject \
|
84
85
|
Restify::NetworkError.new(request, response.return_message)
|
85
86
|
else
|
data/lib/restify/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Restify, adapter: ::Restify::Adapter::Typhoeus do
|
6
|
+
before do
|
7
|
+
stub_request(:get, 'http://stubserver/base').to_timeout
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'Timeout' do
|
11
|
+
subject(:request) { Restify.new('http://localhost:9292/base').get({}, timeout: 0.1).value! }
|
12
|
+
|
13
|
+
it 'throws a network error' do
|
14
|
+
expect { request }.to raise_error Restify::NetworkError do |error|
|
15
|
+
expect(error.message).to match(/timeout/i)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -34,13 +34,20 @@ if ENV['ADAPTER']
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
require_relative 'support/stub_server
|
37
|
+
require_relative 'support/stub_server'
|
38
38
|
|
39
39
|
RSpec.configure do |config|
|
40
40
|
config.order = 'random'
|
41
41
|
|
42
42
|
config.before(:suite) do
|
43
|
-
::Restify::Timeout.default_timeout = 0
|
43
|
+
::Restify::Timeout.default_timeout = 1.0
|
44
|
+
end
|
45
|
+
|
46
|
+
config.before(:each) do |example|
|
47
|
+
next unless (adapter = example.metadata[:adapter])
|
48
|
+
next if Restify.adapter.is_a?(adapter)
|
49
|
+
|
50
|
+
skip 'Spec not enabled for current adapter'
|
44
51
|
end
|
45
52
|
|
46
53
|
config.before(:each) do
|
data/spec/support/stub_server.rb
CHANGED
@@ -40,18 +40,22 @@ module Stub
|
|
40
40
|
WebMock::RequestRegistry.instance.requested_signatures.put(signature)
|
41
41
|
response = ::WebMock::StubRegistry.instance.response_for_request(signature)
|
42
42
|
|
43
|
-
#
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
status = Integer(status[0])
|
48
|
-
|
49
|
-
[status, response.headers || {}, [response.body.to_s]]
|
50
|
-
else
|
51
|
-
# Return special HTTP 599 with the error message that would normally
|
52
|
-
# appear on missing stubs.
|
53
|
-
[599, {}, [WebMock::NetConnectNotAllowedError.new(signature).message]]
|
43
|
+
# Return special HTTP 599 with the error message that would normally
|
44
|
+
# appear on missing stubs.
|
45
|
+
unless response
|
46
|
+
return [599, {}, [WebMock::NetConnectNotAllowedError.new(signature).message]]
|
54
47
|
end
|
48
|
+
|
49
|
+
if response.should_timeout
|
50
|
+
sleep 10
|
51
|
+
return [599, {}, ['Timeout']]
|
52
|
+
end
|
53
|
+
|
54
|
+
status = response.status
|
55
|
+
status = status.to_s.split(' ', 2) unless status.is_a?(Array)
|
56
|
+
status = Integer(status[0])
|
57
|
+
|
58
|
+
[status, response.headers || {}, [response.body.to_s]]
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.15.
|
4
|
+
version: 1.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- spec/restify/error_spec.rb
|
196
196
|
- spec/restify/features/head_requests_spec.rb
|
197
197
|
- spec/restify/features/request_bodies_spec.rb
|
198
|
+
- spec/restify/features/request_errors_spec.rb
|
198
199
|
- spec/restify/features/request_headers_spec.rb
|
199
200
|
- spec/restify/features/response_errors_spec.rb
|
200
201
|
- spec/restify/global_spec.rb
|
@@ -229,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
230
|
- !ruby/object:Gem::Version
|
230
231
|
version: '0'
|
231
232
|
requirements: []
|
232
|
-
rubygems_version: 3.
|
233
|
+
rubygems_version: 3.1.6
|
233
234
|
signing_key:
|
234
235
|
specification_version: 4
|
235
236
|
summary: An experimental hypermedia REST client.
|
@@ -239,6 +240,7 @@ test_files:
|
|
239
240
|
- spec/restify/error_spec.rb
|
240
241
|
- spec/restify/features/head_requests_spec.rb
|
241
242
|
- spec/restify/features/request_bodies_spec.rb
|
243
|
+
- spec/restify/features/request_errors_spec.rb
|
242
244
|
- spec/restify/features/request_headers_spec.rb
|
243
245
|
- spec/restify/features/response_errors_spec.rb
|
244
246
|
- spec/restify/global_spec.rb
|