restify 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +94 -53
- data/README.md +1 -0
- data/lib/restify/adapter/typhoeus.rb +1 -0
- data/lib/restify/error.rb +21 -0
- data/lib/restify/link.rb +4 -4
- data/lib/restify/promise.rb +1 -0
- data/lib/restify/relation.rb +1 -0
- data/lib/restify/timeout.rb +1 -0
- data/lib/restify/version.rb +1 -1
- data/spec/restify/error_spec.rb +66 -0
- data/spec/spec_helper.rb +9 -5
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9393a0338cd138604044dd16e2ced2370b317d00c4317dfb05f559d4dd9111e4
|
4
|
+
data.tar.gz: '0348f419a9d4aadb7edc5e5c5ded5f3317ddac726571eaec3a81e180993323b0'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36f07fdcba6ed8bdfebd6ef58bcb1929a8ae4bb96a0201936fceccc618c095cb8ca4ca7cb387d9b98dcd9551bf08f22ed304eb67651a2ba71c25a657b3804b4f
|
7
|
+
data.tar.gz: 3ab69445ea47a84ad59aa9dc2050ec8fa507283d89fb9aca641a55e7a51893e6c0989d3052f00d8160cbfd6530808b566ae593e91711cf460f3ee1d7b3cf2a53
|
data/CHANGELOG.md
CHANGED
@@ -1,91 +1,132 @@
|
|
1
1
|
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
2
3
|
|
3
|
-
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
4
6
|
|
5
|
-
* Raise more specific error on a few status codes (#17)
|
6
|
-
* Complete promises with an empty list (but a list) of dependencies (#18)
|
7
7
|
|
8
|
-
##
|
8
|
+
## Unreleased
|
9
|
+
---
|
9
10
|
|
10
|
-
|
11
|
+
### New
|
11
12
|
|
12
|
-
|
13
|
+
### Changes
|
13
14
|
|
14
|
-
|
15
|
+
### Fixes
|
15
16
|
|
16
|
-
|
17
|
+
### Breaks
|
17
18
|
|
18
|
-
* Introduce promise dependency timeouts (#15)
|
19
19
|
|
20
|
-
## 1.
|
20
|
+
## 1.11.0 - (2019-07-11)
|
21
|
+
### New
|
22
|
+
* Explicit exception classes for HTTP status codes 500, 502, 503, 504
|
21
23
|
|
22
|
-
|
24
|
+
## 1.10.0 - 2018-12-11
|
25
|
+
### Changed
|
26
|
+
- Raise more specific error on a few status codes (#17)
|
27
|
+
- Complete promises with an empty list (but a list) of dependencies (#18)
|
23
28
|
|
24
|
-
## 1.
|
29
|
+
## 1.9.0 - 2018-11-13
|
30
|
+
### Changed
|
31
|
+
- Do not raise error on 3XX responses but return responses
|
25
32
|
|
26
|
-
|
27
|
-
|
33
|
+
## 1.8.0 - 2018-08-22
|
34
|
+
### Added
|
35
|
+
- Add HEAD request method (#16)
|
28
36
|
|
29
|
-
## 1.
|
37
|
+
## 1.7.0 - 2018-08-15
|
38
|
+
### Added
|
39
|
+
- Introduce promise dependency timeouts (#15)
|
30
40
|
|
31
|
-
|
32
|
-
|
41
|
+
## 1.6.0 - 2018-08-09
|
42
|
+
### Changed
|
43
|
+
- Specify headers on restify clients and individual requests (#14)
|
33
44
|
|
34
|
-
## 1.
|
45
|
+
## 1.5.0 - 2018-07-31
|
46
|
+
### Added
|
47
|
+
- Add MessagePack processor enabled by default
|
35
48
|
|
36
|
-
|
37
|
-
|
49
|
+
### Changed
|
50
|
+
- Tune typhoeus adapter to be more race-condition resilent
|
38
51
|
|
39
|
-
## 1.4.
|
52
|
+
## 1.4.4 - 2018-07-13
|
53
|
+
### Added
|
54
|
+
- Add `#request` to `NetworkError` to ease debugging
|
40
55
|
|
41
|
-
|
56
|
+
### Changed
|
57
|
+
- Fix race condition in typhoeus adapter
|
42
58
|
|
43
|
-
## 1.4.
|
59
|
+
## 1.4.3 - 2017-11-15
|
60
|
+
### Added
|
61
|
+
- Add advanced logging capabilities using logging gem
|
44
62
|
|
45
|
-
|
46
|
-
|
63
|
+
### Changed
|
64
|
+
- Improve compatibility with webmocks returning `nil` as headers
|
47
65
|
|
48
|
-
## 1.
|
66
|
+
## 1.4.1 - 2017-11-15
|
67
|
+
### Changed
|
68
|
+
- Fix possible deadlock issues
|
49
69
|
|
50
|
-
|
51
|
-
|
70
|
+
## 1.4.0 - 2017-11-10
|
71
|
+
### Added
|
72
|
+
- Add timeout option to requests (only supported by typhoeus adapter)
|
52
73
|
|
53
|
-
|
74
|
+
### Changed
|
75
|
+
- Fix possible concurrency issue with typhoeus adapter
|
54
76
|
|
55
|
-
|
56
|
-
|
77
|
+
## 1.3.1 - 2017-11-10
|
78
|
+
### Changed
|
79
|
+
- Improve typhoeus adapters initial request queuing
|
80
|
+
- Disable default pipelining
|
57
81
|
|
58
|
-
## 1.
|
82
|
+
## 1.3.0 - 2017-11-08
|
83
|
+
### Changed
|
84
|
+
- Improve typhoeus adapter to better utilize concurrency
|
85
|
+
- Default to new typhoeus adapter
|
59
86
|
|
60
|
-
|
87
|
+
## 1.2.1 - 2017-10-30
|
88
|
+
### Changed
|
89
|
+
- Fix issue with Ruby 2.2 compatibility
|
61
90
|
|
62
|
-
## 1.2.0
|
91
|
+
## 1.2.0 - 2017-10-30
|
92
|
+
### Added
|
93
|
+
- Add experimental PooledEM adapter (#10)
|
63
94
|
|
64
|
-
|
65
|
-
|
95
|
+
### Changed
|
96
|
+
- Improve marshaling of resources
|
66
97
|
|
67
|
-
## 1.1.0
|
98
|
+
## 1.1.0 - 2017-05-12
|
99
|
+
### Added
|
100
|
+
- Add shortcuts for creating fulfilled / rejected promises (#6)
|
68
101
|
|
69
|
-
|
70
|
-
|
102
|
+
### Changed
|
103
|
+
- Return response body if no processor matches (#7)
|
71
104
|
|
72
|
-
## 1.0.0
|
105
|
+
## 1.0.0 - 2016-08-22
|
106
|
+
### Added
|
107
|
+
- Experimental cache API doing nothing for now
|
73
108
|
|
74
|
-
|
75
|
-
|
109
|
+
### Changed
|
110
|
+
- Use `~> 1.0` of `concurrent-ruby`
|
76
111
|
|
77
|
-
## 0.5.0
|
112
|
+
## 0.5.0 - 2016-04-04
|
113
|
+
### Added
|
114
|
+
- Add `sync` option to typhoeus adapter
|
115
|
+
- Add registry for storing entry points
|
78
116
|
|
79
|
-
|
80
|
-
|
81
|
-
* Make eventmachine based adapter default
|
117
|
+
### Changed
|
118
|
+
- Make eventmachine based adapter default
|
82
119
|
|
83
|
-
## 0.4.0
|
120
|
+
## 0.4.0 - 2016-02-24
|
121
|
+
### Added
|
122
|
+
- Add method to explicit access resource data
|
84
123
|
|
85
|
-
|
86
|
-
|
124
|
+
### Changed
|
125
|
+
- Use typhoeus as default adapter
|
126
|
+
- `Restify.new` returns relation now instead of resource
|
127
|
+
|
128
|
+
### Removed
|
129
|
+
- Drop obligation in favor of simple Concurrent::IVar based promise class.
|
87
130
|
Notable changes:
|
88
|
-
|
89
|
-
|
90
|
-
* Use typhoeus as default adapter
|
91
|
-
* `Restify.new` returns relation now instead of resource
|
131
|
+
- Returned object us of type `Restify::Promise` now.
|
132
|
+
- `value` will not raise exception but return `nil` in case of failure. Use `value!` for old behavior.
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Restify
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/jgraichen/restify.svg?branch=master)](https://travis-ci.org/jgraichen/restify)
|
4
|
+
[![Code Quality](https://codebeat.co/badges/18ffe6b7-8239-493a-b5b6-be329b9f275d)](https://codebeat.co/projects/github-com-jgraichen-restify-master)
|
4
5
|
|
5
6
|
Restify is an hypermedia REST client that does parallel, concurrent and keep-alive requests by default.
|
6
7
|
|
data/lib/restify/error.rb
CHANGED
@@ -34,6 +34,14 @@ module Restify
|
|
34
34
|
UnprocessableEntity.new(response)
|
35
35
|
when 400...500
|
36
36
|
ClientError.new(response)
|
37
|
+
when 500
|
38
|
+
InternalServerError.new(response)
|
39
|
+
when 502
|
40
|
+
BadGateway.new(response)
|
41
|
+
when 503
|
42
|
+
ServiceUnavailable.new(response)
|
43
|
+
when 504
|
44
|
+
GatewayTimeout.new(response)
|
37
45
|
when 500...600
|
38
46
|
ServerError.new(response)
|
39
47
|
else
|
@@ -87,6 +95,13 @@ module Restify
|
|
87
95
|
# 5XX status code.
|
88
96
|
class ServerError < ResponseError; end
|
89
97
|
|
98
|
+
# A {GatewayError} is the common base class for 502, 503 and 504
|
99
|
+
# response codes often used by load balancers when upstream servers are
|
100
|
+
# failing or not available.
|
101
|
+
#
|
102
|
+
# This can be used to catch "common" gateway responses.
|
103
|
+
class GatewayError < ResponseError; end
|
104
|
+
|
90
105
|
###
|
91
106
|
# CONCRETE SUBCLASSES FOR TYPICAL STATUS CODES
|
92
107
|
#
|
@@ -97,4 +112,10 @@ module Restify
|
|
97
112
|
class NotFound < ClientError; end
|
98
113
|
class NotAcceptable < ClientError; end
|
99
114
|
class UnprocessableEntity < ClientError; end
|
115
|
+
|
116
|
+
class InternalServerError < ServerError; end
|
117
|
+
|
118
|
+
class BadGateway < GatewayError; end
|
119
|
+
class ServiceUnavailable < GatewayError; end
|
120
|
+
class GatewayTimeout < GatewayError; end
|
100
121
|
end
|
data/lib/restify/link.rb
CHANGED
@@ -25,10 +25,10 @@ module Restify
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class << self
|
28
|
-
REGEXP_URI = /<[^>]*>\s
|
29
|
-
REGEXP_PAR = /;\s*\w+\s*=\s*/i
|
30
|
-
REGEXP_QUT = /"[^"]*"\s
|
31
|
-
REGEXP_ARG = /\w+\s*/i
|
28
|
+
REGEXP_URI = /<[^>]*>\s*/.freeze
|
29
|
+
REGEXP_PAR = /;\s*\w+\s*=\s*/i.freeze
|
30
|
+
REGEXP_QUT = /"[^"]*"\s*/.freeze
|
31
|
+
REGEXP_ARG = /\w+\s*/i.freeze
|
32
32
|
|
33
33
|
def parse(string)
|
34
34
|
scanner = StringScanner.new(string.strip)
|
data/lib/restify/promise.rb
CHANGED
data/lib/restify/relation.rb
CHANGED
data/lib/restify/timeout.rb
CHANGED
data/lib/restify/version.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Restify::ResponseError do
|
6
|
+
let(:response) { double 'response' }
|
7
|
+
let(:message) { 'Error' }
|
8
|
+
let(:uri) { 'http://localhost' }
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(response).to receive(:uri).and_return(uri)
|
12
|
+
allow(response).to receive(:code).and_return(code)
|
13
|
+
allow(response).to receive(:message).and_return(message)
|
14
|
+
allow(response).to receive(:decoded_body).and_return({})
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
describe '.from_code' do
|
19
|
+
subject(:err) { described_class.from_code(response) }
|
20
|
+
|
21
|
+
context 'with 400 Bad Request' do
|
22
|
+
let(:code) { 400 }
|
23
|
+
it { is_expected.to be_a ::Restify::BadRequest }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with 401 Unauthorized' do
|
27
|
+
let(:code) { 401 }
|
28
|
+
it { is_expected.to be_a ::Restify::Unauthorized }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with 404 Unauthorized' do
|
32
|
+
let(:code) { 404 }
|
33
|
+
it { is_expected.to be_a ::Restify::NotFound }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with 406 Not Acceptable' do
|
37
|
+
let(:code) { 406 }
|
38
|
+
it { is_expected.to be_a ::Restify::NotAcceptable }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with 422 Unprocessable Entity' do
|
42
|
+
let(:code) { 422 }
|
43
|
+
it { is_expected.to be_a ::Restify::UnprocessableEntity }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with 500 Internal Server Error' do
|
47
|
+
let(:code) { 500 }
|
48
|
+
it { is_expected.to be_a ::Restify::InternalServerError }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with 502 Bad Gateway' do
|
52
|
+
let(:code) { 502 }
|
53
|
+
it { is_expected.to be_a ::Restify::BadGateway }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with 503 Service Unavailable' do
|
57
|
+
let(:code) { 503 }
|
58
|
+
it { is_expected.to be_a ::Restify::ServiceUnavailable }
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with 504 Gateway Timeout' do
|
62
|
+
let(:code) { 504 }
|
63
|
+
it { is_expected.to be_a ::Restify::GatewayTimeout }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,11 +3,14 @@
|
|
3
3
|
require 'rspec'
|
4
4
|
require 'webmock/rspec'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter 'spec'
|
9
|
+
end
|
10
|
+
|
11
|
+
if ENV['CI']
|
12
|
+
require 'codecov'
|
13
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
11
14
|
end
|
12
15
|
|
13
16
|
require 'restify'
|
@@ -51,6 +54,7 @@ RSpec.configure do |config|
|
|
51
54
|
::Logging.logger.root.add_appenders ::Logging.appenders.stdout
|
52
55
|
end
|
53
56
|
|
57
|
+
config.warnings = true
|
54
58
|
config.after(:suite) do
|
55
59
|
EventMachine.stop if defined?(EventMachine) && EventMachine.reactor_running?
|
56
60
|
end
|
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.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -140,16 +140,16 @@ dependencies:
|
|
140
140
|
name: bundler
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '0'
|
153
153
|
description: An experimental hypermedia REST client that uses parallel, keep-alive
|
154
154
|
and pipelined requests by default.
|
155
155
|
email:
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- lib/restify/version.rb
|
187
187
|
- spec/restify/cache_spec.rb
|
188
188
|
- spec/restify/context_spec.rb
|
189
|
+
- spec/restify/error_spec.rb
|
189
190
|
- spec/restify/features/head_requests_spec.rb
|
190
191
|
- spec/restify/features/request_headers_spec.rb
|
191
192
|
- spec/restify/features/response_errors.rb
|
@@ -221,13 +222,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
222
|
version: '0'
|
222
223
|
requirements: []
|
223
224
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.7.
|
225
|
+
rubygems_version: 2.7.7
|
225
226
|
signing_key:
|
226
227
|
specification_version: 4
|
227
228
|
summary: An experimental hypermedia REST client.
|
228
229
|
test_files:
|
229
230
|
- spec/restify/cache_spec.rb
|
230
231
|
- spec/restify/context_spec.rb
|
232
|
+
- spec/restify/error_spec.rb
|
231
233
|
- spec/restify/features/head_requests_spec.rb
|
232
234
|
- spec/restify/features/request_headers_spec.rb
|
233
235
|
- spec/restify/features/response_errors.rb
|