uber-s3 0.2.3 → 0.2.4
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.
- data/lib/uber-s3/connection/net_http.rb +22 -12
- data/lib/uber-s3/version.rb +1 -1
- metadata +2 -2
@@ -12,15 +12,7 @@ module UberS3::Connection
|
|
12
12
|
self.uri = URI.parse(url)
|
13
13
|
|
14
14
|
# Init and open a HTTP connection
|
15
|
-
|
16
|
-
if !http.started? || !http.active?
|
17
|
-
http.start
|
18
|
-
|
19
|
-
if Socket.const_defined?(:TCP_NODELAY)
|
20
|
-
socket = http.instance_variable_get(:@socket)
|
21
|
-
socket.io.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
|
22
|
-
end
|
23
|
-
end
|
15
|
+
http_connect! if http.nil? || !http.started?
|
24
16
|
|
25
17
|
req_klass = instance_eval("Net::HTTP::"+verb.to_s.capitalize)
|
26
18
|
req = req_klass.new(uri.to_s, headers)
|
@@ -28,9 +20,15 @@ module UberS3::Connection
|
|
28
20
|
req.body = body if !body.nil? && !body.empty?
|
29
21
|
|
30
22
|
# Make HTTP request
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
retries = 2
|
24
|
+
begin
|
25
|
+
r = http.request(req)
|
26
|
+
rescue EOFError, Errno::EPIPE
|
27
|
+
# Something happened to our connection, lets try this again
|
28
|
+
http_connect!
|
29
|
+
retries -= 1
|
30
|
+
retry if retries >= 0
|
31
|
+
end
|
34
32
|
|
35
33
|
# Auto-decode any gzipped objects
|
36
34
|
if verb == :get && r.header['Content-Encoding'] == 'gzip'
|
@@ -47,6 +45,18 @@ module UberS3::Connection
|
|
47
45
|
:raw => r
|
48
46
|
})
|
49
47
|
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def http_connect!
|
52
|
+
self.http = Net::HTTP.new(uri.host, uri.port)
|
53
|
+
http.start
|
54
|
+
|
55
|
+
if Socket.const_defined?(:TCP_NODELAY)
|
56
|
+
socket = http.instance_variable_get(:@socket)
|
57
|
+
socket.io.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
|
58
|
+
end
|
59
|
+
end
|
50
60
|
|
51
61
|
end
|
52
62
|
end
|
data/lib/uber-s3/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uber-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
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-06
|
12
|
+
date: 2012-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mime-types
|