rest-client 2.0.0.rc4-x64-mingw32 → 2.0.0-x64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3050dbd255dd32936863100ae05de5bc80ef8a5a
4
- data.tar.gz: 233e0052b744d2945b4d4cb20af6442f459e64ec
3
+ metadata.gz: 9c7fe445faf9ac8b0c2d5885ef897fe62a29eca4
4
+ data.tar.gz: 6cbd00246b48690123c0fe37ddc2aa2d279fce29
5
5
  SHA512:
6
- metadata.gz: 4687e2c33fd98d6928e49ab309aa214d4c70c438a7afe181793a7cd4c042bcf5615da9cfc28a157fda7b00d03d95d4425a6b6e686d10aed19e7cce24ab77c99e
7
- data.tar.gz: 3291917b14d0b19eb9eab6446c5decb8a962314056560a81a9a17b6fe0338017fb1688b41ee614a8878f71e3e291f6e48a1d84ee9e2238322f32b6aa7d3be7a6
6
+ metadata.gz: b65926489e73f14fec9266f8c892cff546e38d54b52aea2a84dffe033322bfb9bd47f6356d2730d7c449f7397dfa2658bf4c35450d0c2c20c624df6049eabf99
7
+ data.tar.gz: 80f8d55c65385636b7381861a9f8dd9df2c35afe0940656e2f391715cd1526bb9d6dc75db51bed0b83ae55d954d7b8e9604c3ce8075a776b92d7e2601d048413
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
- ### Manually following redirection
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')
@@ -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
@@ -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 effectively end up using `Encoding.default_external` when
12
- # this method returns nil.
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
  #
@@ -1,5 +1,5 @@
1
1
  module RestClient
2
- VERSION_INFO = [2, 0, 0, 'rc4'] unless defined?(self::VERSION_INFO)
2
+ VERSION_INFO = [2, 0, 0] unless defined?(self::VERSION_INFO)
3
3
  VERSION = VERSION_INFO.map(&:to_s).join('.') unless defined?(self::VERSION)
4
4
 
5
5
  def self.version
@@ -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 Encoding.default_external' do
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
@@ -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(ENV).to receive(:[]).with("NETRC").and_return(nil)
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.rc4
4
+ version: 2.0.0
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - REST Client Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-19 00:00:00.000000000 Z
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: 1.3.1
258
+ version: '0'
259
259
  requirements: []
260
260
  rubyforge_project:
261
261
  rubygems_version: 2.4.5.1