rest-client 2.0.0.rc1-x86-mingw32 → 2.0.0.rc2-x86-mingw32
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/AUTHORS +1 -0
- data/README.rdoc +19 -1
- data/history.md +19 -5
- data/lib/restclient/exceptions.rb +27 -25
- data/lib/restclient/request.rb +1 -0
- data/lib/restclient/version.rb +1 -1
- data/spec/unit/exceptions_spec.rb +15 -0
- data/spec/unit/request_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f554990ccd624b28550a1e74d7e563efaf2ac0bd
|
4
|
+
data.tar.gz: 1c16a11c16b30878c6d1927fa7b183f9d46fb502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 732c64356b5fc1ac2f3b67ce00205efa5a9145b9f6d2304bbd320a405e1177e0666e0cda8c572dca45457a456bde8489886dc1506b0d87c470180e749662e6cc
|
7
|
+
data.tar.gz: f2048aadadb9a828cf370ac0a5f670f9115673a5732b06a31e2a296ccf7e1ba93e0d3b755606d6aa54fd6d007683f4229bbacbd88f930c90db29b72003adc8cc
|
data/AUTHORS
CHANGED
data/README.rdoc
CHANGED
@@ -8,6 +8,12 @@ of specifying actions: get, put, post, delete.
|
|
8
8
|
* Main page: https://github.com/rest-client/rest-client
|
9
9
|
* Mailing list: rest.client@librelist.com (send a mail to subscribe).
|
10
10
|
|
11
|
+
=== Mailing list changes
|
12
|
+
|
13
|
+
The Librelist mailing list is currently *defunct*, as Librelist appears to be
|
14
|
+
broken and not accepting new mail. We will choose a new email list provider
|
15
|
+
soon.
|
16
|
+
|
11
17
|
== Requirements
|
12
18
|
|
13
19
|
MRI Ruby 1.9.3 and newer are supported. Alternative interpreters compatible with
|
@@ -74,6 +80,10 @@ helpers are just thin wrappers around RestClient::Request.execute.
|
|
74
80
|
RestClient::Request.execute(method: :get, url: 'http://example.com/resource',
|
75
81
|
timeout: 10)
|
76
82
|
|
83
|
+
RestClient::Request.execute(method: :get, url: 'http://example.com/resource',
|
84
|
+
ssl_ca_file: 'myca.pem',
|
85
|
+
ssl_ciphers: 'AESGCM:!aNULL')
|
86
|
+
|
77
87
|
You can also use this to pass a payload for HTTP verbs like DELETE, where the
|
78
88
|
RestClient.delete helper doesn't accept a payload.
|
79
89
|
|
@@ -332,7 +342,15 @@ extract and set headers for them as needed:
|
|
332
342
|
)
|
333
343
|
# ...response body
|
334
344
|
|
335
|
-
== SSL
|
345
|
+
== SSL/TLS support
|
346
|
+
|
347
|
+
Various options are supported for configuring rest-client's TLS settings. By
|
348
|
+
default, rest-client will verify certificates using the system's CA store on
|
349
|
+
all platforms. (This is intended to be similar to how browsers behave.) You can
|
350
|
+
specify an :ssl_ca_file, :ssl_ca_path, or :ssl_cert_store to customize the
|
351
|
+
certificate authorities accepted.
|
352
|
+
|
353
|
+
=== SSL Client Certificates
|
336
354
|
|
337
355
|
RestClient::Resource.new(
|
338
356
|
'https://example.com',
|
data/history.md
CHANGED
@@ -9,11 +9,17 @@ This release is largely API compatible, but makes several breaking changes.
|
|
9
9
|
For example, `Content-Type: text/plain; charset=EUC-JP` will return a String
|
10
10
|
encoded with `Encoding::EUC_JP`.
|
11
11
|
- Change exceptions raised on request timeout. Instead of
|
12
|
-
RestClient::RequestTimeout (which is still used for HTTP 408), network
|
13
|
-
timeouts will now raise either RestClient::Exceptions::ReadTimeout or
|
14
|
-
RestClient::Exceptions::OpenTimeout
|
15
|
-
RestClient::Exceptions::Timeout
|
16
|
-
|
12
|
+
`RestClient::RequestTimeout` (which is still used for HTTP 408), network
|
13
|
+
timeouts will now raise either `RestClient::Exceptions::ReadTimeout` or
|
14
|
+
`RestClient::Exceptions::OpenTimeout`, both of which inherit from
|
15
|
+
`RestClient::Exceptions::Timeout`. For backwards compatibility, this still
|
16
|
+
inherits from `RestClient::RequestTimeout` so existing uses will still work.
|
17
|
+
This may change in a future major release. These new timeout classes also
|
18
|
+
make the original wrapped exception available as `#original_exception`.
|
19
|
+
- Unify request exceptions under `RestClient::RequestFailed`, which still
|
20
|
+
inherits from `ExceptionWithResponse`. Previously, HTTP 304, 401, and 404
|
21
|
+
inherited directly from `ExceptionWithResponse` rather than from
|
22
|
+
`RequestFailed`. Now _all_ HTTP status code exceptions inherit from both.
|
17
23
|
- Rename `:timeout` to `:read_timeout`. When `:timeout` is passed, now set both
|
18
24
|
`:read_timeout` and `:open_timeout`.
|
19
25
|
- Change default HTTP Accept header to `*/*`
|
@@ -59,6 +65,14 @@ This release is largely API compatible, but makes several breaking changes.
|
|
59
65
|
possible to add procs like `RestClient.add_before_execution_proc` to a single
|
60
66
|
request without global state.
|
61
67
|
|
68
|
+
# 2.0.0.rc1
|
69
|
+
|
70
|
+
Changes in the release candidate that did not persist through the final 2.0.0
|
71
|
+
release:
|
72
|
+
- RestClient::Exceptions::Timeout was originally going to be a direct subclass
|
73
|
+
of RestClient::Exception in the release candidate. This exception tree was
|
74
|
+
made a subclass of RestClient::RequestTimeout prior to the final release.
|
75
|
+
|
62
76
|
# 1.8.0
|
63
77
|
|
64
78
|
- Security: implement standards compliant cookie handling by adding a
|
@@ -100,20 +100,16 @@ module RestClient
|
|
100
100
|
@response.body if @response
|
101
101
|
end
|
102
102
|
|
103
|
-
def inspect
|
104
|
-
"#{message}: #{http_body}"
|
105
|
-
end
|
106
|
-
|
107
103
|
def to_s
|
108
|
-
|
104
|
+
message
|
109
105
|
end
|
110
106
|
|
111
107
|
def message
|
112
|
-
@message ||
|
108
|
+
@message || default_message
|
113
109
|
end
|
114
110
|
|
115
|
-
def
|
116
|
-
self.name
|
111
|
+
def default_message
|
112
|
+
self.class.name
|
117
113
|
end
|
118
114
|
end
|
119
115
|
|
@@ -124,7 +120,7 @@ module RestClient
|
|
124
120
|
# The request failed with an error code not managed by the code
|
125
121
|
class RequestFailed < ExceptionWithResponse
|
126
122
|
|
127
|
-
def
|
123
|
+
def default_message
|
128
124
|
"HTTP status code #{http_code}"
|
129
125
|
end
|
130
126
|
|
@@ -141,11 +137,30 @@ module RestClient
|
|
141
137
|
module Exceptions
|
142
138
|
# Map http status codes to the corresponding exception class
|
143
139
|
EXCEPTIONS_MAP = {}
|
140
|
+
end
|
141
|
+
|
142
|
+
# Create HTTP status exception classes
|
143
|
+
STATUSES.each_pair do |code, message|
|
144
|
+
klass = Class.new(RequestFailed) do
|
145
|
+
send(:define_method, :default_message) {"#{http_code ? "#{http_code} " : ''}#{message}"}
|
146
|
+
end
|
147
|
+
klass_constant = const_set(message.delete(' \-\''), klass)
|
148
|
+
Exceptions::EXCEPTIONS_MAP[code] = klass_constant
|
149
|
+
end
|
150
|
+
|
151
|
+
# Backwards compatibility. "Not Found" is the actual text in the RFCs.
|
152
|
+
ResourceNotFound = NotFound
|
153
|
+
|
154
|
+
module Exceptions
|
155
|
+
# We have to split the Exceptions module like we do here because the
|
156
|
+
# EXCEPTIONS_MAP is under Exceptions, but we depend on
|
157
|
+
# RestClient::RequestTimeout below.
|
144
158
|
|
145
159
|
# Base class for request timeouts.
|
160
|
+
#
|
146
161
|
# NB: Previous releases of rest-client would raise RequestTimeout both for
|
147
162
|
# HTTP 408 responses and for actual connection timeouts.
|
148
|
-
class Timeout < RestClient::
|
163
|
+
class Timeout < RestClient::RequestTimeout
|
149
164
|
def initialize(message=nil, original_exception=nil)
|
150
165
|
super(nil, nil)
|
151
166
|
self.message = message if message
|
@@ -156,7 +171,7 @@ module RestClient
|
|
156
171
|
# Timeout when connecting to a server. Typically wraps Net::OpenTimeout (in
|
157
172
|
# ruby 2.0 or greater).
|
158
173
|
class OpenTimeout < Timeout
|
159
|
-
def
|
174
|
+
def default_message
|
160
175
|
'Timed out connecting to server'
|
161
176
|
end
|
162
177
|
end
|
@@ -164,25 +179,12 @@ module RestClient
|
|
164
179
|
# Timeout when reading from a server. Typically wraps Net::ReadTimeout (in
|
165
180
|
# ruby 2.0 or greater).
|
166
181
|
class ReadTimeout < Timeout
|
167
|
-
def
|
182
|
+
def default_message
|
168
183
|
'Timed out reading data from server'
|
169
184
|
end
|
170
185
|
end
|
171
186
|
end
|
172
187
|
|
173
|
-
STATUSES.each_pair do |code, message|
|
174
|
-
|
175
|
-
# Compatibility
|
176
|
-
superclass = ([304, 401, 404].include? code) ? ExceptionWithResponse : RequestFailed
|
177
|
-
klass = Class.new(superclass) do
|
178
|
-
send(:define_method, :message) {"#{http_code ? "#{http_code} " : ''}#{message}"}
|
179
|
-
end
|
180
|
-
klass_constant = const_set message.delete(' \-\''), klass
|
181
|
-
Exceptions::EXCEPTIONS_MAP[code] = klass_constant
|
182
|
-
end
|
183
|
-
|
184
|
-
# Backwards compatibility. "Not Found" is the actual text in the RFCs.
|
185
|
-
ResourceNotFound = NotFound
|
186
188
|
|
187
189
|
# The server broke the connection prior to the request completing. Usually
|
188
190
|
# this means it crashed, or sometimes that your network connection was
|
data/lib/restclient/request.rb
CHANGED
@@ -248,6 +248,7 @@ module RestClient
|
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
251
|
+
user_headers = user_headers.dup
|
251
252
|
user_headers[:cookie] = @cookies.map { |key, val| "#{key}=#{val}" }.sort.join('; ')
|
252
253
|
end
|
253
254
|
headers = stringify_headers(default_headers).merge(stringify_headers(user_headers))
|
data/lib/restclient/version.rb
CHANGED
@@ -84,4 +84,19 @@ describe "backwards compatibility" do
|
|
84
84
|
it 'aliases RestClient::NotFound as ResourceNotFound' do
|
85
85
|
RestClient::ResourceNotFound.should eq RestClient::NotFound
|
86
86
|
end
|
87
|
+
|
88
|
+
it 'subclasses NotFound from RequestFailed, ExceptionWithResponse' do
|
89
|
+
RestClient::NotFound.should be < RestClient::RequestFailed
|
90
|
+
RestClient::NotFound.should be < RestClient::ExceptionWithResponse
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'subclasses timeout from RestClient::RequestTimeout, RequestFailed, EWR' do
|
94
|
+
RestClient::Exceptions::OpenTimeout.should be < RestClient::Exceptions::Timeout
|
95
|
+
RestClient::Exceptions::ReadTimeout.should be < RestClient::Exceptions::Timeout
|
96
|
+
|
97
|
+
RestClient::Exceptions::Timeout.should be < RestClient::RequestTimeout
|
98
|
+
RestClient::Exceptions::Timeout.should be < RestClient::RequestFailed
|
99
|
+
RestClient::Exceptions::Timeout.should be < RestClient::ExceptionWithResponse
|
100
|
+
end
|
101
|
+
|
87
102
|
end
|
data/spec/unit/request_spec.rb
CHANGED
@@ -383,6 +383,19 @@ describe RestClient::Request, :include_helpers do
|
|
383
383
|
lambda { @request.transmit(@uri, 'req', nil) }.should raise_error(RestClient::Exceptions::OpenTimeout)
|
384
384
|
end
|
385
385
|
|
386
|
+
it "uses correct error message for ReadTimeout",
|
387
|
+
:if => defined?(Net::ReadTimeout) do
|
388
|
+
@http.stub(:request).and_raise(Net::ReadTimeout)
|
389
|
+
lambda { @request.transmit(@uri, 'req', nil) }.should raise_error(RestClient::Exceptions::ReadTimeout, 'Timed out reading data from server')
|
390
|
+
end
|
391
|
+
|
392
|
+
it "uses correct error message for OpenTimeout",
|
393
|
+
:if => defined?(Net::OpenTimeout) do
|
394
|
+
@http.stub(:request).and_raise(Net::OpenTimeout)
|
395
|
+
lambda { @request.transmit(@uri, 'req', nil) }.should raise_error(RestClient::Exceptions::OpenTimeout, 'Timed out connecting to server')
|
396
|
+
end
|
397
|
+
|
398
|
+
|
386
399
|
it "class method execute wraps constructor" do
|
387
400
|
req = double("rest request")
|
388
401
|
RestClient::Request.should_receive(:new).with(1 => 2).and_return(req)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc2
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- REST Client Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|