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 +4 -4
- data/lib/async/http/protocol/http11.rb +0 -3
- data/lib/async/http/protocol/http1x.rb +0 -3
- data/lib/async/http/server.rb +25 -19
- data/lib/async/http/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9be0535f6b1fe7573ca409923d89338e0b024d2
|
4
|
+
data.tar.gz: 6d2cdc0d28de05c3e78db9f4be5585a1e2a4861b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 076440e10a4aa34b45da40891ed7c58a63f4eeaca246894b6c186b1cd2da3e8d68366e485d31438289bfe46f855600079b4fb0258655f609f6b7834a7aaad741
|
7
|
+
data.tar.gz: dde1b7737ad31b7b67803cc7703030aaccb8b3af12366f3dcdd3550c35eab0ccb60d4e9452f3b87db403826acc064358e7e3a5710ba4a0fdfc6f7f4abbc02261
|
data/lib/async/http/server.rb
CHANGED
@@ -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
|
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
|
data/lib/async/http/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-io
|