net-http-persistent 1.7 → 1.8
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +8 -0
- data/lib/net/http/persistent.rb +23 -3
- data/test/test_net_http_persistent.rb +12 -0
- metadata +12 -13
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 1.8 / 2011-06-27
|
2
|
+
|
3
|
+
* Minor Enhancement
|
4
|
+
* Added Net::HTTP::Persistent#retry_change_requests which allows POST and
|
5
|
+
other non-idempotent requests to be retried automatically. Take care when
|
6
|
+
enabling this option to ensure the server will handle multiple POSTs with
|
7
|
+
the same data in a sane manner.
|
8
|
+
|
1
9
|
=== 1.7 / 2011-04-17
|
2
10
|
|
3
11
|
* Minor Enhancement
|
data/lib/net/http/persistent.rb
CHANGED
@@ -42,7 +42,7 @@ class Net::HTTP::Persistent
|
|
42
42
|
##
|
43
43
|
# The version of Net::HTTP::Persistent use are using
|
44
44
|
|
45
|
-
VERSION = '1.
|
45
|
+
VERSION = '1.8'
|
46
46
|
|
47
47
|
##
|
48
48
|
# Error class for errors raised by Net::HTTP::Persistent. Various
|
@@ -152,6 +152,17 @@ class Net::HTTP::Persistent
|
|
152
152
|
|
153
153
|
attr_accessor :verify_mode
|
154
154
|
|
155
|
+
##
|
156
|
+
# Enable retries of non-idempotent requests that change data (e.g. POST
|
157
|
+
# requests) when the server has disconnected.
|
158
|
+
#
|
159
|
+
# This will in the worst case lead to multiple requests with the same data,
|
160
|
+
# but it may be useful for some applications. Take care when enabling
|
161
|
+
# this option to ensure it is safe to POST or perform other non-idempotent
|
162
|
+
# requests to the server.
|
163
|
+
|
164
|
+
attr_accessor :retry_change_requests
|
165
|
+
|
155
166
|
##
|
156
167
|
# Creates a new Net::HTTP::Persistent.
|
157
168
|
#
|
@@ -211,6 +222,8 @@ class Net::HTTP::Persistent
|
|
211
222
|
@private_key = nil
|
212
223
|
@verify_callback = nil
|
213
224
|
@verify_mode = nil
|
225
|
+
|
226
|
+
@retry_change_requests = false
|
214
227
|
end
|
215
228
|
|
216
229
|
##
|
@@ -305,6 +318,13 @@ class Net::HTTP::Persistent
|
|
305
318
|
end
|
306
319
|
end
|
307
320
|
|
321
|
+
##
|
322
|
+
# Is the request idempotent or is retry_change_requests allowed
|
323
|
+
|
324
|
+
def can_retry? req
|
325
|
+
retry_change_requests or idempotent?(req)
|
326
|
+
end
|
327
|
+
|
308
328
|
##
|
309
329
|
# Adds "http://" to the String +uri+ if it is missing.
|
310
330
|
|
@@ -409,7 +429,7 @@ class Net::HTTP::Persistent
|
|
409
429
|
finish connection
|
410
430
|
|
411
431
|
raise Error, "too many bad responses #{message}" if
|
412
|
-
bad_response or not
|
432
|
+
bad_response or not can_retry? req
|
413
433
|
|
414
434
|
bad_response = true
|
415
435
|
retry
|
@@ -417,7 +437,7 @@ class Net::HTTP::Persistent
|
|
417
437
|
Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE,
|
418
438
|
Errno::EINVAL => e
|
419
439
|
|
420
|
-
if retried or not
|
440
|
+
if retried or not can_retry? req
|
421
441
|
due_to = "(due to #{e.message} - #{e.class})"
|
422
442
|
message = error_message connection
|
423
443
|
|
@@ -783,5 +783,17 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
|
|
783
783
|
assert_equal OpenSSL::SSL::VERIFY_NONE, c.verify_mode
|
784
784
|
end
|
785
785
|
|
786
|
+
def test_can_retry_change_requests
|
787
|
+
get = Net::HTTP::Get.new('/')
|
788
|
+
post = Net::HTTP::Post.new('/')
|
789
|
+
assert @http.can_retry?(get)
|
790
|
+
refute @http.retry_change_requests
|
791
|
+
refute @http.can_retry?(post)
|
792
|
+
@http.retry_change_requests = true
|
793
|
+
assert @http.can_retry?(get)
|
794
|
+
assert @http.retry_change_requests
|
795
|
+
assert @http.can_retry?(post)
|
796
|
+
end
|
797
|
+
|
786
798
|
end
|
787
799
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-http-persistent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: "1.
|
8
|
+
- 8
|
9
|
+
version: "1.8"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Eric Hodel
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
x52qPcexcYZR7w==
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2011-
|
38
|
+
date: 2011-06-27 00:00:00 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: minitest
|
@@ -45,12 +45,12 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
hash:
|
48
|
+
hash: 1
|
49
49
|
segments:
|
50
50
|
- 2
|
51
|
-
-
|
52
|
-
-
|
53
|
-
version: 2.
|
51
|
+
- 3
|
52
|
+
- 1
|
53
|
+
version: 2.3.1
|
54
54
|
type: :development
|
55
55
|
version_requirements: *id001
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -59,14 +59,13 @@ dependencies:
|
|
59
59
|
requirement: &id002 !ruby/object:Gem::Requirement
|
60
60
|
none: false
|
61
61
|
requirements:
|
62
|
-
- -
|
62
|
+
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
64
|
+
hash: 17
|
65
65
|
segments:
|
66
66
|
- 2
|
67
67
|
- 9
|
68
|
-
|
69
|
-
version: 2.9.4
|
68
|
+
version: "2.9"
|
70
69
|
type: :development
|
71
70
|
version_requirements: *id002
|
72
71
|
description: |-
|
@@ -130,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
129
|
requirements: []
|
131
130
|
|
132
131
|
rubyforge_project: net-http-persistent
|
133
|
-
rubygems_version: 1.
|
132
|
+
rubygems_version: 1.8.5
|
134
133
|
signing_key:
|
135
134
|
specification_version: 3
|
136
135
|
summary: Manages persistent connections using Net::HTTP plus a speed fix for 1.8
|
metadata.gz.sig
CHANGED
Binary file
|