net-ptth 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- net-ptth (0.0.9)
4
+ net-ptth (0.0.10)
5
5
  celluloid-io (~> 0.15.0)
6
6
  http_parser.rb (~> 0.5.3)
7
7
  rack (~> 1.4.5)
@@ -1,6 +1,8 @@
1
1
  require "celluloid/io"
2
2
 
3
3
  class Net::PTTH
4
+ SocketError = Class.new(StandardError)
5
+
4
6
  Socket = Struct.new(:host, :port) do
5
7
  include Celluloid::IO
6
8
 
@@ -9,11 +11,21 @@ class Net::PTTH
9
11
  end
10
12
 
11
13
  def write(data)
12
- raw_socket.write(data)
14
+ retries = 3
15
+ begin
16
+ raw_socket.write(data)
17
+ rescue Errno::EPIPE => e
18
+ retry_count -= 1
19
+ if retry_count > 0
20
+ retry
21
+ else
22
+ raise SocketError.new("Couldn't reconnect! Errno::EPIPE")
23
+ end
24
+ end
13
25
  end
14
26
 
15
27
  def close
16
- raw_socket.close
28
+ close_socket
17
29
  rescue IOError => e
18
30
  # I'm already closed
19
31
  end
@@ -22,6 +34,13 @@ class Net::PTTH
22
34
  !raw_socket.closed?
23
35
  end
24
36
 
37
+ private
38
+
39
+ def close_socket
40
+ @_socket = nil
41
+ raw_socket.close
42
+ end
43
+
25
44
  def raw_socket
26
45
  @_socket ||= TCPSocket.new(host, port)
27
46
  end
data/net-ptth.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "net-ptth"
3
- s.version = "0.0.9"
3
+ s.version = "0.0.10"
4
4
  s.summary = "Net::HTTP compatible reverse HTTP version"
5
5
  s.description = "PTTH Ruby client. Net::HTTP compatible... kind of"
6
6
  s.authors = ["elcuervo"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ptth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
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: 2013-10-05 00:00:00.000000000 Z
12
+ date: 2013-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack