async-http 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e71a596dc1dee6c4eab53691aa115ca3131f7af6
4
- data.tar.gz: 46ed7eb01476eb5e2296a81f4e3dccb9c6c42eba
3
+ metadata.gz: a9be0535f6b1fe7573ca409923d89338e0b024d2
4
+ data.tar.gz: 6d2cdc0d28de05c3e78db9f4be5585a1e2a4861b
5
5
  SHA512:
6
- metadata.gz: 4c978a492a58171e6fb5009af835aabf11ee44d9b1ca27dc4a003782210b51ced1d83fe9f1aef6fb916660fe92a63c009eb70db6a0a6af0381b93116447d7f5c
7
- data.tar.gz: aa00d677dfb29f8ff334ee6d664e42c37cc8b31b75483bda223842f9245f94e91a2a1a56c54c30292fdc71bae4184250dbe605fb44532ce6f1a0f35fe0933521
6
+ metadata.gz: 076440e10a4aa34b45da40891ed7c58a63f4eeaca246894b6c186b1cd2da3e8d68366e485d31438289bfe46f855600079b4fb0258655f609f6b7834a7aaad741
7
+ data.tar.gz: dde1b7737ad31b7b67803cc7703030aaccb8b3af12366f3dcdd3550c35eab0ccb60d4e9452f3b87db403826acc064358e7e3a5710ba4a0fdfc6f7f4abbc02261
@@ -60,9 +60,6 @@ module Async
60
60
 
61
61
  break unless keep_alive?(request.headers) && keep_alive?(headers)
62
62
  end
63
-
64
- rescue EOFError, Errno::ECONNRESET
65
- return nil
66
63
  end
67
64
 
68
65
  # Client request.
@@ -51,9 +51,6 @@ module Async
51
51
  method, path, version = self.peek_line.split(/\s+/, 3)
52
52
 
53
53
  create_handler(version).receive_requests(&block)
54
-
55
- rescue EOFError, Errno::ECONNRESET
56
- return nil
57
54
  end
58
55
 
59
56
  def send_request(request, &block)
@@ -34,29 +34,35 @@ module Async
34
34
  [200, {}, []]
35
35
  end
36
36
 
37
+ def accept(peer, address)
38
+ stream = Async::IO::Stream.new(peer)
39
+
40
+ protocol = @protocol_class.new(stream)
41
+
42
+ # puts "Opening session on child pid #{Process.pid}"
43
+
44
+ hijack = catch(:hijack) do
45
+ protocol.receive_requests do |request|
46
+ handle_request(request, peer, address)
47
+ end
48
+ end
49
+
50
+ if hijack
51
+ hijack.call
52
+ end
53
+
54
+ # puts "Closing session"
55
+
56
+ rescue EOFError, Errno::ECONNRESET, Errno::EPIPE
57
+ # Sometimes client will disconnect without completing a result or reading the entire buffer.
58
+ return nil
59
+ end
60
+
37
61
  def run
38
62
  Async::IO::Address.each(@addresses) do |address|
39
63
  # puts "Binding to #{address} on process #{Process.pid}"
40
64
 
41
- address.accept do |peer|
42
- stream = Async::IO::Stream.new(peer)
43
-
44
- protocol = @protocol_class.new(stream)
45
-
46
- # puts "Opening session on child pid #{Process.pid}"
47
-
48
- hijack = catch(:hijack) do
49
- protocol.receive_requests do |request|
50
- handle_request(request, peer, address)
51
- end
52
- end
53
-
54
- if hijack
55
- hijack.call
56
- end
57
-
58
- # puts "Closing session"
59
- end
65
+ address.accept(&self.method(:accept))
60
66
  end
61
67
  end
62
68
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.2.0"
23
+ VERSION = "0.2.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-15 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-io