rest 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rest (1.2.2)
4
+ rest (2.0.0)
5
5
  net-http-persistent
6
6
  rest-client (>= 0.3.0)
7
7
 
@@ -87,11 +87,13 @@ module Rest
87
87
  current_retry = 0
88
88
  current_follow = 0
89
89
  success = false
90
+ tries = 0
90
91
  res = nil
91
92
  while current_retry < max_retries && current_follow < max_follows do
93
+ tries += 1
92
94
  begin
93
95
  res = yield blk
94
- res.tries = current_retry + 1
96
+ res.tries = tries
95
97
  if res.code >= 300 && res.code < 400
96
98
  # try new location
97
99
  #p res.headers
@@ -113,6 +115,8 @@ module Rest
113
115
  break
114
116
  rescue Rest::HttpError => ex
115
117
  if ex.code == 503
118
+ raise ex if current_retry == max_retries - 1
119
+
116
120
  pow = (4 ** (current_retry)) * 100 # milliseconds
117
121
  #puts 'pow=' + pow.to_s
118
122
  s = Random.rand * pow
@@ -1,3 +1,3 @@
1
1
  module Rest
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -36,6 +36,7 @@ module Rest
36
36
  def initialize(client)
37
37
  @client = client
38
38
  @http = Net::HTTP::Persistent.new 'rest_gem'
39
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
39
40
  end
40
41
 
41
42
  def default_headers
@@ -14,7 +14,7 @@ class TestPerformance < TestBase
14
14
  def test_get_performance
15
15
  puts 'test_get_performance'
16
16
 
17
- times = 100
17
+ times = 20
18
18
 
19
19
  quicky = Quicky::Timer.new
20
20
 
@@ -25,9 +25,25 @@ class TestRest < TestBase
25
25
  response = @rest.get("http://rest-test.iron.io/code/503?switch_after=3&switch_to=200")
26
26
  p response
27
27
  p response.code
28
- p response.tries == 3
28
+ assert response.tries == 3
29
29
  assert response.code == 200
30
30
 
31
+ # Now let's try to error out
32
+ begin
33
+ response = @rest.get("http://rest-test.iron.io/code/503")
34
+ assert false, "shouldn't get here"
35
+ rescue Rest::HttpError => ex
36
+ puts "EX: " + ex.inspect
37
+ p ex.backtrace
38
+ assert ex.is_a?(Rest::HttpError)
39
+ assert ex.response
40
+ assert ex.response.body
41
+ assert ex.code == 503
42
+ #assert ex.response.tries == 5 # the default max
43
+ assert ex.response.body.include?("503")
44
+ assert ex.to_s.include?("503")
45
+ end
46
+
31
47
  end
32
48
 
33
49
  def test_gets
@@ -98,6 +114,7 @@ class TestRest < TestBase
98
114
  end
99
115
  end
100
116
 
117
+
101
118
  def test_post_with_headers
102
119
 
103
120
  @token = "abctoken"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
12
+ date: 2012-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client