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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 241fd43c8e40d2a0c2c839443df03106edf3c8e491cac9338277ff4327a3927f
4
- data.tar.gz: d8eea64a1de42ee6eb4666feb510669b69482f24c72a0f5c883f3482143751ca
3
+ metadata.gz: 95d9cf12fd58e2f17bd1d3c046dfda23eaa38ec2fb99fe0c9b7e1034e014cd1f
4
+ data.tar.gz: b995cf5d935ba1c83b403fedf18d4c35154ea0ad60d4be0437fa98c89281d687
5
5
  SHA512:
6
- metadata.gz: 603395d24a3ecad6d35b217ef2d154cd0982f9cd9181769b2a5aa949e134f0f9af1a15cc731f54a2d700e3bd1162b667240420e5669af20b48c66a1ba84fc2c5
7
- data.tar.gz: 89e64dcd00dde5a7711922619380d2003db5f8c42a7cbc473b19678b6ed251134ffe4b4c94b86afaa7efa7dea030c6d43876e57c00c85ea76523f9f7029f6804
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
@@ -4,7 +4,7 @@ module Restify
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 15
7
- PATCH = 0
7
+ PATCH = 1
8
8
  STAGE = nil
9
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
10
10
 
@@ -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.rb'
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.1
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
@@ -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
- # If no stub matched `nil` is returned.
44
- if response
45
- status = response.status
46
- status = status.to_s.split(' ', 2) unless status.is_a?(Array)
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.0
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-09 00:00:00.000000000 Z
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.2.22
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