rest-client 2.0.0.rc4-x86-mswin32 → 2.0.0-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +59 -2
- data/lib/restclient/request.rb +4 -0
- data/lib/restclient/utils.rb +2 -2
- data/lib/restclient/version.rb +1 -1
- data/spec/integration/integration_spec.rb +5 -3
- data/spec/unit/request_spec.rb +2 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af1e5a6298b95569f890b60bf3422e0ef5bc05cf
|
4
|
+
data.tar.gz: 3311792f7f45cce8df085042e797f51786a6bc9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f02d6679180319385d5e3277ad20362efc423ce9e7502e4a05eeacded8e4a0e11130ed38181eef1600a6c81b48c3b0de7584e6e1166209a10bcbe5cc42612c69
|
7
|
+
data.tar.gz: 6cafffe7561f7dcaad6ffc239bc5048365683781171cafe5b00574b70775a0a9549c47e5deb88ca1f6ad65cf4e78afe6dea7221c9ea01208a688fd98a9be5a5a
|
data/README.md
CHANGED
@@ -45,6 +45,35 @@ There are also several development dependencies. It's recommended to use
|
|
45
45
|
[bundler](http://bundler.io/) to manage these dependencies for hacking on
|
46
46
|
rest-client.
|
47
47
|
|
48
|
+
### Upgrading to rest-client 2.0 from 1.x
|
49
|
+
|
50
|
+
Users are encouraged to upgrade to rest-client 2.0, which cleans up a number of
|
51
|
+
API warts and wrinkles, making rest-client generally more useful. Usage is
|
52
|
+
largely compatible, so many applications will be able to upgrade with no
|
53
|
+
changes.
|
54
|
+
|
55
|
+
Overview of significant changes:
|
56
|
+
|
57
|
+
* requires Ruby >= 2.0
|
58
|
+
* `RestClient::Response` objects are a subclass of `String` rather than a
|
59
|
+
Frankenstein monster. And `#body` or `#to_s` return a true `String` object.
|
60
|
+
* cleanup of exception classes, including new `RestClient::Exceptions::Timeout`
|
61
|
+
* improvements to handling of redirects: responses and history are properly
|
62
|
+
exposed
|
63
|
+
* major changes to cookie support: cookie jars are used for browser-like
|
64
|
+
behavior throughout
|
65
|
+
* encoding: Content-Type charset response headers are used to automatically set
|
66
|
+
the encoding of the response string
|
67
|
+
* HTTP params: handling of GET/POST params is more consistent and sophisticated
|
68
|
+
for deeply nested hash objects, and `ParamsArray` can be used to pass ordered
|
69
|
+
params
|
70
|
+
* improved proxy support with per-request proxy configuration, plus the ability
|
71
|
+
to disable proxies set by environment variables
|
72
|
+
* default request headers: rest-client sets `Accept: */*` and
|
73
|
+
`User-Agent: rest-client/...`
|
74
|
+
|
75
|
+
See [history.md](./history.md) for a more complete description of changes.
|
76
|
+
|
48
77
|
## Usage: Raw URL
|
49
78
|
```ruby
|
50
79
|
require 'rest-client'
|
@@ -177,10 +206,38 @@ end
|
|
177
206
|
➔ 404 Resource Not Found | text/html 282 bytes
|
178
207
|
```
|
179
208
|
|
180
|
-
###
|
209
|
+
### Redirection
|
210
|
+
|
211
|
+
By default, rest-client will follow HTTP 30x redirection requests.
|
212
|
+
|
213
|
+
__New in 2.0:__ `RestClient::Response` exposes a `#history` method that returns
|
214
|
+
a list of each response received in a redirection chain.
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
>> r = RestClient.get('http://httpbin.org/redirect/2')
|
218
|
+
=> <RestClient::Response 200 "{\n \"args\":...">
|
219
|
+
|
220
|
+
# see each response in the redirect chain
|
221
|
+
>> r.history
|
222
|
+
=> [<RestClient::Response 302 "<!DOCTYPE H...">, <RestClient::Response 302 "">]
|
223
|
+
|
224
|
+
# see each requested URL
|
225
|
+
>> r.request.url
|
226
|
+
=> "http://httpbin.org/get"
|
227
|
+
>> r.history.map {|x| x.request.url}
|
228
|
+
=> ["http://httpbin.org/redirect/2", "http://httpbin.org/relative-redirect/1"]
|
229
|
+
```
|
230
|
+
|
231
|
+
#### Manually following redirection
|
181
232
|
|
182
233
|
To disable automatic redirection, set `:max_redirects => 0`.
|
183
234
|
|
235
|
+
__New in 2.0:__ Prior versions of rest-client would raise
|
236
|
+
`RestClient::MaxRedirectsReached`, with no easy way to access the server's
|
237
|
+
response. In 2.0, rest-client raises the normal
|
238
|
+
`RestClient::ExceptionWithResponse` as it would with any other non-HTTP-20x
|
239
|
+
response.
|
240
|
+
|
184
241
|
```ruby
|
185
242
|
>> RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1')
|
186
243
|
=> RestClient::Response 200 "{\n "args":..."
|
@@ -226,7 +283,7 @@ Response objects have several useful methods. (See the class rdoc for more detai
|
|
226
283
|
- `Response#cookies`: A hash of HTTP cookies set by the server
|
227
284
|
- `Response#cookie_jar`: <em>New in 1.8</em> An HTTP::CookieJar of cookies
|
228
285
|
- `Response#request`: The RestClient::Request object used to make the request
|
229
|
-
- `Response#history`: If redirection was followed, a list of prior Response objects
|
286
|
+
- `Response#history`: <em>New in 2.0</em> If redirection was followed, a list of prior Response objects
|
230
287
|
|
231
288
|
```ruby
|
232
289
|
RestClient.get('http://example.com')
|
data/lib/restclient/request.rb
CHANGED
@@ -59,6 +59,10 @@ module RestClient
|
|
59
59
|
#
|
60
60
|
# This list will be used by default if the Ruby global OpenSSL default
|
61
61
|
# ciphers appear to be a weak list.
|
62
|
+
#
|
63
|
+
# TODO: either remove this code or always use it, since Ruby uses a decent
|
64
|
+
# cipher list in versions >= 2.0.
|
65
|
+
#
|
62
66
|
DefaultCiphers = %w{
|
63
67
|
!aNULL
|
64
68
|
!eNULL
|
data/lib/restclient/utils.rb
CHANGED
@@ -8,8 +8,8 @@ module RestClient
|
|
8
8
|
# text. This differs from the older RFC 2616 behavior, which specifies
|
9
9
|
# using ISO-8859-1 for text/* content types without a charset.
|
10
10
|
#
|
11
|
-
# Strings will
|
12
|
-
#
|
11
|
+
# Strings will use the default encoding when this method returns nil. This
|
12
|
+
# default is likely to be UTF-8 for Ruby >= 2.0
|
13
13
|
#
|
14
14
|
# @param headers [Hash<Symbol,String>]
|
15
15
|
#
|
data/lib/restclient/version.rb
CHANGED
@@ -88,14 +88,15 @@ describe RestClient do
|
|
88
88
|
expect(response.encode('utf-8')).to eq body_utf8
|
89
89
|
end
|
90
90
|
|
91
|
-
it 'defaults to
|
91
|
+
it 'defaults to the default encoding' do
|
92
92
|
stub_request(:get, 'www.example.com').to_return(
|
93
93
|
body: 'abc', status: 200, headers: {
|
94
94
|
'Content-Type' => 'text/plain'
|
95
95
|
})
|
96
96
|
|
97
97
|
response = RestClient.get 'www.example.com'
|
98
|
-
expect(response.encoding).to eq Encoding.default_external
|
98
|
+
# expect(response.encoding).to eq Encoding.default_external
|
99
|
+
expect(response.encoding).to eq Encoding::UTF_8
|
99
100
|
end
|
100
101
|
|
101
102
|
it 'handles invalid encoding' do
|
@@ -105,7 +106,8 @@ describe RestClient do
|
|
105
106
|
})
|
106
107
|
|
107
108
|
response = RestClient.get 'www.example.com'
|
108
|
-
expect(response.encoding).to eq Encoding.default_external
|
109
|
+
# expect(response.encoding).to eq Encoding.default_external
|
110
|
+
expect(response.encoding).to eq Encoding::UTF_8
|
109
111
|
end
|
110
112
|
|
111
113
|
it 'leaves images as binary' do
|
data/spec/unit/request_spec.rb
CHANGED
@@ -567,7 +567,8 @@ describe RestClient::Request, :include_helpers do
|
|
567
567
|
allow(ENV).to receive(:[]).with("http_proxy").and_return("http://127.0.0.1")
|
568
568
|
allow(ENV).to receive(:[]).with("no_proxy").and_return(nil)
|
569
569
|
allow(ENV).to receive(:[]).with("NO_PROXY").and_return(nil)
|
570
|
-
allow(
|
570
|
+
allow(Netrc).to receive(:read).and_return({})
|
571
|
+
|
571
572
|
req = RestClient::Request.new(:method => :put, :url => 'http://some/resource', :payload => 'payload')
|
572
573
|
obj = req.net_http_object('host', 80)
|
573
574
|
expect(obj.proxy?).to be true
|
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
|
5
5
|
platform: x86-mswin32
|
6
6
|
authors:
|
7
7
|
- REST Client Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|
@@ -253,9 +253,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
253
|
version: 2.0.0
|
254
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
255
255
|
requirements:
|
256
|
-
- - "
|
256
|
+
- - ">="
|
257
257
|
- !ruby/object:Gem::Version
|
258
|
-
version:
|
258
|
+
version: '0'
|
259
259
|
requirements: []
|
260
260
|
rubyforge_project:
|
261
261
|
rubygems_version: 2.4.5.1
|