persistent_http 2.0.1 → 2.0.2
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 +4 -4
- data/History.md +5 -0
- data/lib/persistent_http.rb +1 -1
- data/lib/persistent_http/connection.rb +19 -1
- data/lib/persistent_http/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d523aa4ce9ba2f4c152ca0dff6fed4a3fa11db58
|
4
|
+
data.tar.gz: 5188aa8505323ede2e9f1651372e6f215132548b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c13143f9fd45f59c0ff7d3a34353fa8229aa4af30d723ce0babc33b7d64efa5497afd57fa17a9009389487c68150a6e4bd47f5e23abb807de0ff62e942ccc8f5
|
7
|
+
data.tar.gz: 159fef3e71ff5ca9e65a7a75a2a18818dc63c8b0f8d5c63b2e2e7522146f98cd625b37d1d8d201f81a6e9c6c7e47f8817a10983ba8db89d072e44d5396ab21d9
|
data/History.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
PersistentHttp Changelog
|
2
2
|
========================
|
3
3
|
|
4
|
+
2.0.2
|
5
|
+
|
6
|
+
- Add OpenSSL::SSL::SSLError to retriable exceptions if it's defined.
|
7
|
+
- Add after_connect option for manipulating connection after connect.
|
8
|
+
|
4
9
|
2.0.1
|
5
10
|
|
6
11
|
- Put default_path, host and port getters back into persistent_http for backwards compatibility
|
data/lib/persistent_http.rb
CHANGED
@@ -84,7 +84,7 @@ class PersistentHTTP
|
|
84
84
|
#
|
85
85
|
# Set +name+ to keep your connections apart from everybody else's. Not
|
86
86
|
# required currently, but highly recommended. Your library name should be
|
87
|
-
# good enough.
|
87
|
+
# good enough.
|
88
88
|
#
|
89
89
|
# +proxy+ may be set to a URI::HTTP or :ENV to pick up proxy options from
|
90
90
|
# the environment. See proxy_from_env for details.
|
@@ -28,6 +28,18 @@ require 'uri'
|
|
28
28
|
class PersistentHTTP
|
29
29
|
class Connection
|
30
30
|
|
31
|
+
##
|
32
|
+
# Exceptions rescued for automatic retry on ruby 2.0.0. This overlaps with
|
33
|
+
# the exception list for ruby 1.x.
|
34
|
+
RETRIED_EXCEPTIONS = [ # :nodoc:
|
35
|
+
IOError,
|
36
|
+
EOFError,
|
37
|
+
Errno::ECONNRESET,
|
38
|
+
Errno::ECONNABORTED,
|
39
|
+
Errno::EPIPE,
|
40
|
+
(OpenSSL::SSL::SSLError if defined? OpenSSL::SSL),
|
41
|
+
].compact
|
42
|
+
|
31
43
|
##
|
32
44
|
# An SSL certificate authority. Setting this will set verify_mode to
|
33
45
|
# VERIFY_PEER.
|
@@ -118,6 +130,10 @@ class PersistentHTTP
|
|
118
130
|
# You can use +verify_mode+ to override any default values.
|
119
131
|
attr_accessor :verify_mode
|
120
132
|
|
133
|
+
##
|
134
|
+
# Proc to execute after connect which will get passed the Net::HTTP connection
|
135
|
+
attr_accessor :after_connect
|
136
|
+
|
121
137
|
##
|
122
138
|
# Creates a new HTTP Connection.
|
123
139
|
#
|
@@ -153,6 +169,7 @@ class PersistentHTTP
|
|
153
169
|
@use_ssl = options[:use_ssl]
|
154
170
|
@verify_callback = options[:verify_callback]
|
155
171
|
@verify_mode = options[:verify_mode]
|
172
|
+
@after_connect = options[:after_connect]
|
156
173
|
# Because maybe we want a non-persistent connection and are just using this for the proxy stuff
|
157
174
|
@non_persistent = options[:non_persistent]
|
158
175
|
|
@@ -206,6 +223,7 @@ class PersistentHTTP
|
|
206
223
|
|
207
224
|
@connection.start
|
208
225
|
@logger.debug { "#{@name} #{@connection}: Connection created" } if @logger
|
226
|
+
@after_connect.call(@connection) if @after_connect
|
209
227
|
rescue Errno::ECONNREFUSED
|
210
228
|
raise Error, "connection refused: #{@connection.address}:#{@connection.port}"
|
211
229
|
rescue Errno::EHOSTDOWN
|
@@ -266,7 +284,7 @@ class PersistentHTTP
|
|
266
284
|
retry
|
267
285
|
end
|
268
286
|
|
269
|
-
rescue
|
287
|
+
rescue *RETRIED_EXCEPTIONS => e
|
270
288
|
due_to = "(due to #{e.message} - #{e.class})"
|
271
289
|
if retried or not (idempotent? req or @force_retry)
|
272
290
|
@logger.info "#{@name}: Removing connection #{due_to} #{error_message}" if @logger
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: persistent_http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Pardee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - '>='
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '1.3'
|
20
|
-
|
19
|
+
name: gene_pool
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
23
|
requirements:
|
22
24
|
- - '>='
|
23
25
|
- !ruby/object:Gem::Version
|
24
26
|
version: '1.3'
|
25
|
-
prerelease: false
|
26
|
-
type: :runtime
|
27
27
|
description: Persistent HTTP connections using a connection pool
|
28
28
|
email:
|
29
29
|
- bradpardee@gmail.com
|