rest-client 2.0.0.rc3-x86-mswin32 → 2.0.0.rc4-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9619b56074f57c7b3a3781da1f0e7132f151d4b1
4
- data.tar.gz: c5f4ece186655aa494474fb30351743520dc619d
3
+ metadata.gz: 54555b609f694d43c1a52f4a043ee6df6c68bf17
4
+ data.tar.gz: d3613ca55fb039c4624ef1538dc614d4b6b5002a
5
5
  SHA512:
6
- metadata.gz: be4a0eb8bf0210f241e3f835b1f8776c16b09ac8c215120ce8de9cc83d02acc0258aa826b939e918a4965781654d6aa22ead967a8fe303b9b3f5d618f6f1b11c
7
- data.tar.gz: cee75b4f75326e37aeb59cae88d436dcfecc67b584102ea2ddc9bbdd63115cc80a5200cac5df43db248da25bf9ab1d100610398302db142febf0b2f56f24615c
6
+ metadata.gz: ef4c1eb54c3e8dce4f874465f63788342365338935963648545b2575b32ea03d50328758a98c6dae88b1c9d4e7ebb53e07b2183f8849d4cb519106fd7dddab4e
7
+ data.tar.gz: 385a9eff6d878a444571eae99675061cc48c1d2298e8424c1964e274c2418cb262581501a6005b1a6bb182010ddb27903933a5398a30b39ca064f6c24e992e52
data/README.md CHANGED
@@ -177,6 +177,38 @@ end
177
177
  ➔ 404 Resource Not Found | text/html 282 bytes
178
178
  ```
179
179
 
180
+ ### Manually following redirection
181
+
182
+ To disable automatic redirection, set `:max_redirects => 0`.
183
+
184
+ ```ruby
185
+ >> RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1')
186
+ => RestClient::Response 200 "{\n "args":..."
187
+
188
+ >> RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1', max_redirects: 0)
189
+ RestClient::Found: 302 Found
190
+ ```
191
+
192
+ To manually follow redirection, you can call `Response#follow_redirection`. Or
193
+ you could of course inspect the result and choose custom behavior.
194
+
195
+ ```ruby
196
+ >> RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1', max_redirects: 0)
197
+ RestClient::Found: 302 Found
198
+ >> begin
199
+ RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1', max_redirects: 0)
200
+ rescue RestClient::ExceptionWithResponse => err
201
+ end
202
+ >> err
203
+ => #<RestClient::Found: 302 Found>
204
+ >> err.response
205
+ => RestClient::Response 302 "<!DOCTYPE H..."
206
+ >> err.response.headers[:location]
207
+ => "/get"
208
+ >> err.response.follow_redirection
209
+ => RestClient::Response 200 "{\n "args":..."
210
+ ```
211
+
180
212
  ## Result handling
181
213
 
182
214
  The result of a `RestClient::Request` is a `RestClient::Response` object.
data/history.md CHANGED
@@ -8,7 +8,7 @@ This release is largely API compatible, but makes several breaking changes.
8
8
  rest-client would not override the string encoding chosen by Net::HTTP. Now
9
9
  responses that specify a charset will yield a body string in that encoding.
10
10
  For example, `Content-Type: text/plain; charset=EUC-JP` will return a String
11
- encoded with `Encoding::EUC_JP`.
11
+ encoded with `Encoding::EUC_JP`. (#361)
12
12
  - Change exceptions raised on request timeout. Instead of
13
13
  `RestClient::RequestTimeout` (which is still used for HTTP 408), network
14
14
  timeouts will now raise either `RestClient::Exceptions::ReadTimeout` or
@@ -48,8 +48,8 @@ This release is largely API compatible, but makes several breaking changes.
48
48
  Set-Cookie, which is special) by joining the values with a comma space,
49
49
  compliant with RFC 7230
50
50
  - Rewrite cookie support to be much smarter and to use cookie jars consistently
51
- for requests, responses, and redirection (resolving long-standing complaints
52
- about the previously broken behavior):
51
+ for requests, responses, and redirection in order to resolve long-standing
52
+ complaints about the previously broken behavior: (#498)
53
53
  - The `:cookies` option may now be a Hash of Strings, an Array of
54
54
  HTTP::Cookie objects, or a full HTTP::CookieJar.
55
55
  - Add `RestClient::Request#cookie_jar` and reimplement `Request#cookies` to
@@ -73,7 +73,7 @@ This release is largely API compatible, but makes several breaking changes.
73
73
  treat any object that responds to `.read` as a streaming payload and pass it
74
74
  through to `.body_stream=` on the Net:HTTP object. This massively reduces the
75
75
  memory required for large file uploads.
76
- - Changes to redirection behavior:
76
+ - Changes to redirection behavior: (#381, #484)
77
77
  - Remove `RestClient::MaxRedirectsReached` in favor of the normal
78
78
  `ExceptionWithResponse` subclasses. This makes the response accessible on
79
79
  the exception object as `.response`, making it possible for callers to tell
@@ -90,7 +90,14 @@ This release is largely API compatible, but makes several breaking changes.
90
90
  - Run tests on Travis's beta OS X support.
91
91
  - Make `Request#transmit` a private method, along with a few others.
92
92
  - Refactor URI parsing to happen earlier, in Request initialization.
93
- - When adding URL params, handle URLs that already contain params.
93
+ - Improve consistency and functionality of complex URL parameter handling:
94
+ - When adding URL params, handle URLs that already contain params.
95
+ - Add new convention for handling URL params containing deeply nested arrays
96
+ and hashes, unify handling of null/empty values, and use the same code for
97
+ GET and POST params. (#437)
98
+ - Add the RestClient::ParamsArray class, a simple array-like container that
99
+ can be used to pass multiple keys with same name or keys where the ordering
100
+ is significant.
94
101
  - Add a few more exception classes for obscure HTTP status codes.
95
102
  - Multipart: use a much more robust multipart boundary with greater entropy.
96
103
  - Make `RestClient::Payload::Base#inspect` stop pretending to be a String.
@@ -132,8 +132,10 @@ module RestClient
132
132
  @cookie_jar = process_cookie_args!(@uri, @headers, args)
133
133
 
134
134
  @payload = Payload.generate(args[:payload])
135
- @user = args[:user]
136
- @password = args[:password]
135
+
136
+ @user = args[:user] if args.include?(:user)
137
+ @password = args[:password] if args.include?(:password)
138
+
137
139
  if args.include?(:timeout)
138
140
  @read_timeout = args[:timeout]
139
141
  @open_timeout = args[:timeout]
@@ -1,5 +1,5 @@
1
1
  module RestClient
2
- VERSION_INFO = [2, 0, 0, 'rc3'] unless defined?(self::VERSION_INFO)
2
+ VERSION_INFO = [2, 0, 0, 'rc4'] 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
@@ -68,5 +68,19 @@ describe RestClient::Request do
68
68
  expect(ex.response.cookies['foo']).to eq '"bar:baz"'
69
69
  }
70
70
  end
71
+
72
+ it 'sends basic auth' do
73
+ user = 'user'
74
+ pass = 'pass'
75
+
76
+ data = execute_httpbin_json("basic-auth/#{user}/#{pass}", method: :get, user: user, password: pass)
77
+ expect(data).to eq({'authenticated' => true, 'user' => user})
78
+
79
+ expect {
80
+ execute_httpbin_json("basic-auth/#{user}/#{pass}", method: :get, user: user, password: 'badpass')
81
+ }.to raise_error(RestClient::Unauthorized) { |ex|
82
+ expect(ex.http_code).to eq 401
83
+ }
84
+ end
71
85
  end
72
86
  end
@@ -103,25 +103,33 @@ describe RestClient::Request, :include_helpers do
103
103
 
104
104
  describe "user - password" do
105
105
  it "extracts the username and password when parsing http://user:password@example.com/" do
106
- allow(URI).to receive(:parse).and_return(double('uri', user: 'joe', password: 'pass1', hostname: 'example.com'))
107
106
  @request.send(:parse_url_with_auth!, 'http://joe:pass1@example.com/resource')
108
107
  expect(@request.user).to eq 'joe'
109
108
  expect(@request.password).to eq 'pass1'
110
109
  end
111
110
 
112
111
  it "extracts with escaping the username and password when parsing http://user:password@example.com/" do
113
- allow(URI).to receive(:parse).and_return(double('uri', user: 'joe%20', password: 'pass1', hostname: 'example.com'))
114
112
  @request.send(:parse_url_with_auth!, 'http://joe%20:pass1@example.com/resource')
115
113
  expect(@request.user).to eq 'joe '
116
114
  expect(@request.password).to eq 'pass1'
117
115
  end
118
116
 
119
117
  it "doesn't overwrite user and password (which may have already been set by the Resource constructor) if there is no user/password in the url" do
120
- allow(URI).to receive(:parse).and_return(double('uri', user: nil, password: nil, hostname: 'example.com'))
121
- @request = RestClient::Request.new(:method => 'get', :url => 'example.com', :user => 'beth', :password => 'pass2')
122
- @request.send(:parse_url_with_auth!, 'http://example.com/resource')
123
- expect(@request.user).to eq 'beth'
124
- expect(@request.password).to eq 'pass2'
118
+ request = RestClient::Request.new(method: :get, url: 'http://example.com/resource', user: 'beth', password: 'pass2')
119
+ expect(request.user).to eq 'beth'
120
+ expect(request.password).to eq 'pass2'
121
+ end
122
+
123
+ it 'uses the username and password from the URL' do
124
+ request = RestClient::Request.new(method: :get, url: 'http://person:secret@example.com/resource')
125
+ expect(request.user).to eq 'person'
126
+ expect(request.password).to eq 'secret'
127
+ end
128
+
129
+ it 'overrides URL user/pass with explicit options' do
130
+ request = RestClient::Request.new(method: :get, url: 'http://person:secret@example.com/resource', user: 'beth', password: 'pass2')
131
+ expect(request.user).to eq 'beth'
132
+ expect(request.password).to eq 'pass2'
125
133
  end
126
134
  end
127
135
 
@@ -253,19 +261,17 @@ describe RestClient::Request, :include_helpers do
253
261
  end
254
262
 
255
263
  it "uses netrc credentials" do
256
- allow(URI).to receive(:parse).and_return(double('uri', :user => nil, :password => nil, :hostname => 'example.com'))
257
- allow(Netrc).to receive(:read).and_return('example.com' => ['a', 'b'])
258
- @request.send(:parse_url_with_auth!, 'http://example.com/resource')
259
- expect(@request.user).to eq 'a'
260
- expect(@request.password).to eq 'b'
264
+ expect(Netrc).to receive(:read).and_return('example.com' => ['a', 'b'])
265
+ request = RestClient::Request.new(:method => :put, :url => 'http://example.com/', :payload => 'payload')
266
+ expect(request.user).to eq 'a'
267
+ expect(request.password).to eq 'b'
261
268
  end
262
269
 
263
270
  it "uses credentials in the url in preference to netrc" do
264
- allow(URI).to receive(:parse).and_return(double('uri', :user => 'joe%20', :password => 'pass1', :hostname => 'example.com'))
265
271
  allow(Netrc).to receive(:read).and_return('example.com' => ['a', 'b'])
266
- @request.send(:parse_url_with_auth!, 'http://joe%20:pass1@example.com/resource')
267
- expect(@request.user).to eq 'joe '
268
- expect(@request.password).to eq 'pass1'
272
+ request = RestClient::Request.new(:method => :put, :url => 'http://joe%20:pass1@example.com/', :payload => 'payload')
273
+ expect(request.user).to eq 'joe '
274
+ expect(request.password).to eq 'pass1'
269
275
  end
270
276
 
271
277
  it "determines the Net::HTTP class to instantiate by the method name" do
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.rc3
4
+ version: 2.0.0.rc4
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-06-06 00:00:00.000000000 Z
11
+ date: 2016-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webmock