net-http-persistent 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ === 1.2.2 / 2010-06-22
2
+
3
+ * Bug Fixes
4
+ * #request only finishes a connection instead of restarting it. This helps
5
+ prevents errors on non-idempotent HTTP requests after errors.
6
+ * #connection_for handles EHOSTDOWN like #reset
7
+
1
8
  === 1.2.1 / 2010-05-25
2
9
 
3
10
  * Bug Fixes
@@ -36,7 +36,7 @@ class Net::HTTP::Persistent
36
36
  ##
37
37
  # The version of Net::HTTP::Persistent use are using
38
38
 
39
- VERSION = '1.2.1'
39
+ VERSION = '1.2.2'
40
40
 
41
41
  ##
42
42
  # Error class for errors raised by Net::HTTP::Persistent. Various
@@ -216,6 +216,8 @@ class Net::HTTP::Persistent
216
216
  connection
217
217
  rescue Errno::ECONNREFUSED
218
218
  raise Error, "connection refused: #{connection.address}:#{connection.port}"
219
+ rescue Errno::EHOSTDOWN
220
+ raise Error, "host down: #{connection.address}:#{connection.port}"
219
221
  end
220
222
 
221
223
  ##
@@ -236,6 +238,16 @@ class Net::HTTP::Persistent
236
238
  URI.escape str if str
237
239
  end
238
240
 
241
+ ##
242
+ # Finishes the Net::HTTP +connection+
243
+
244
+ def finish connection
245
+ Thread.current[@request_key].delete connection.object_id
246
+
247
+ connection.finish
248
+ rescue IOError
249
+ end
250
+
239
251
  ##
240
252
  # Is +req+ idempotent according to RFC 2616?
241
253
 
@@ -287,10 +299,7 @@ class Net::HTTP::Persistent
287
299
  def reset connection
288
300
  Thread.current[@request_key].delete connection.object_id
289
301
 
290
- begin
291
- connection.finish
292
- rescue IOError
293
- end
302
+ finish connection
294
303
 
295
304
  connection.start
296
305
  rescue Errno::ECONNREFUSED
@@ -123,6 +123,21 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
123
123
  assert_same c, conns['example.com:80']
124
124
  end
125
125
 
126
+ def test_connection_for_host_down
127
+ cached = Object.new
128
+ def cached.address; 'example.com' end
129
+ def cached.port; 80 end
130
+ def cached.start; raise Errno::EHOSTDOWN end
131
+ def cached.started?; false end
132
+ conns['example.com:80'] = cached
133
+
134
+ e = assert_raises Net::HTTP::Persistent::Error do
135
+ @http.connection_for @uri
136
+ end
137
+
138
+ assert_match %r%host down%, e.message
139
+ end
140
+
126
141
  def test_connection_for_name
127
142
  http = Net::HTTP::Persistent.new 'name'
128
143
  uri = URI.parse 'http://example/'
@@ -179,6 +194,35 @@ class TestNetHttpPersistent < MiniTest::Unit::TestCase
179
194
  assert_equal '%20', @http.escape(' ')
180
195
  end
181
196
 
197
+ def test_finish
198
+ c = Object.new
199
+ def c.finish; @finished = true end
200
+ def c.finished?; @finished end
201
+ def c.start; @started = true end
202
+ def c.started?; @started end
203
+ reqs[c.object_id] = 5
204
+
205
+ @http.finish c
206
+
207
+ refute c.started?
208
+ assert c.finished?
209
+ assert_nil reqs[c.object_id]
210
+ end
211
+
212
+ def test_finish_io_error
213
+ c = Object.new
214
+ def c.finish; @finished = true; raise IOError end
215
+ def c.finished?; @finished end
216
+ def c.start; @started = true end
217
+ def c.started?; @started end
218
+ reqs[c.object_id] = 5
219
+
220
+ @http.finish c
221
+
222
+ refute c.started?
223
+ assert c.finished?
224
+ end
225
+
182
226
  def test_idempotent_eh
183
227
  assert @http.idempotent? Net::HTTP::Delete.new '/'
184
228
  assert @http.idempotent? Net::HTTP::Get.new '/'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http-persistent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Hodel
@@ -36,7 +36,7 @@ cert_chain:
36
36
  x52qPcexcYZR7w==
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2010-05-25 00:00:00 -07:00
39
+ date: 2010-06-22 00:00:00 -07:00
40
40
  default_executable:
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  requirements: []
157
157
 
158
158
  rubyforge_project: seattlerb
159
- rubygems_version: 1.3.7.pre.1
159
+ rubygems_version: 1.3.7
160
160
  signing_key:
161
161
  specification_version: 3
162
162
  summary: Persistent connections using Net::HTTP plus a speed fix for 1.8
metadata.gz.sig CHANGED
Binary file