async-http 0.77.0 → 0.78.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/http/client.rb +0 -1
- data/lib/async/http/protocol/http1/finishable.rb +58 -0
- data/lib/async/http/protocol/http1/server.rb +20 -5
- data/lib/async/http/protocol/request.rb +4 -0
- data/lib/async/http/protocol/response.rb +4 -0
- data/lib/async/http/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
- data/lib/async/http/body/finishable.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76e78af8d20808d557b1c13c850af0a268de5535726ba07708b2012eb8752029
|
4
|
+
data.tar.gz: 53bdf9b950394a03ca8c1fd47befe51e8ba51a5cce82aa47c01111df7efd21b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43c49b50bb88955088b74926e3fe33310f38f4b09d9b9ecdc538a9835c9be5b8be0e172e09794324a53db99e09b0102ae96fc179af13578a758f42644d6f4011
|
7
|
+
data.tar.gz: fa1a0d97f326bdd72010f07cfe21004b0da8f75fe4556778bd3b918f42e2e85f22bc41cd07e2a64b4395540e531a879480e634a8fe401ee0d0d7c146af8b61d7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/async/http/client.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
require "protocol/http/body/wrapper"
|
7
|
+
require "async/variable"
|
8
|
+
|
9
|
+
module Async
|
10
|
+
module HTTP
|
11
|
+
module Protocol
|
12
|
+
module HTTP1
|
13
|
+
# Keeps track of whether a body is being read, and if so, waits for it to be closed.
|
14
|
+
class Finishable < ::Protocol::HTTP::Body::Wrapper
|
15
|
+
def initialize(body)
|
16
|
+
super(body)
|
17
|
+
|
18
|
+
@closed = Async::Variable.new
|
19
|
+
@error = nil
|
20
|
+
|
21
|
+
@reading = false
|
22
|
+
end
|
23
|
+
|
24
|
+
def reading?
|
25
|
+
@reading
|
26
|
+
end
|
27
|
+
|
28
|
+
def read
|
29
|
+
@reading = true
|
30
|
+
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def close(error = nil)
|
35
|
+
unless @closed.resolved?
|
36
|
+
@error = error
|
37
|
+
@closed.value = true
|
38
|
+
end
|
39
|
+
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def wait
|
44
|
+
if @reading
|
45
|
+
@closed.wait
|
46
|
+
else
|
47
|
+
self.discard
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def inspect
|
52
|
+
"#<#{self.class} closed=#{@closed} error=#{@error}> | #{super}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# Copyright, 2024, by Anton Zhuravsky.
|
8
8
|
|
9
9
|
require_relative "connection"
|
10
|
-
require_relative "
|
10
|
+
require_relative "finishable"
|
11
11
|
|
12
12
|
require "console/event/failure"
|
13
13
|
|
@@ -16,6 +16,18 @@ module Async
|
|
16
16
|
module Protocol
|
17
17
|
module HTTP1
|
18
18
|
class Server < Connection
|
19
|
+
def initialize(...)
|
20
|
+
super
|
21
|
+
|
22
|
+
@ready = Async::Notification.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def closed!
|
26
|
+
super
|
27
|
+
|
28
|
+
@ready.signal
|
29
|
+
end
|
30
|
+
|
19
31
|
def fail_request(status)
|
20
32
|
@persistent = false
|
21
33
|
write_response(@version, status, {})
|
@@ -26,6 +38,11 @@ module Async
|
|
26
38
|
end
|
27
39
|
|
28
40
|
def next_request
|
41
|
+
# Wait for the connection to become idle before reading the next request:
|
42
|
+
unless idle?
|
43
|
+
@ready.wait
|
44
|
+
end
|
45
|
+
|
29
46
|
# The default is true.
|
30
47
|
return unless @persistent
|
31
48
|
|
@@ -49,7 +66,7 @@ module Async
|
|
49
66
|
|
50
67
|
while request = next_request
|
51
68
|
if body = request.body
|
52
|
-
finishable =
|
69
|
+
finishable = Finishable.new(body)
|
53
70
|
request.body = finishable
|
54
71
|
end
|
55
72
|
|
@@ -126,10 +143,8 @@ module Async
|
|
126
143
|
request&.finish
|
127
144
|
end
|
128
145
|
|
146
|
+
# Discard or wait for the input body to be consumed:
|
129
147
|
finishable&.wait
|
130
|
-
|
131
|
-
# This ensures we yield at least once every iteration of the loop and allow other fibers to execute.
|
132
|
-
task.yield
|
133
148
|
rescue => error
|
134
149
|
raise
|
135
150
|
ensure
|
data/lib/async/http/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.78.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -58,7 +58,7 @@ cert_chain:
|
|
58
58
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
59
59
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
60
60
|
-----END CERTIFICATE-----
|
61
|
-
date: 2024-09-
|
61
|
+
date: 2024-09-22 00:00:00.000000000 Z
|
62
62
|
dependencies:
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: async
|
@@ -182,7 +182,6 @@ files:
|
|
182
182
|
- bake/async/http/h2spec.rb
|
183
183
|
- lib/async/http.rb
|
184
184
|
- lib/async/http/body.rb
|
185
|
-
- lib/async/http/body/finishable.rb
|
186
185
|
- lib/async/http/body/hijack.rb
|
187
186
|
- lib/async/http/body/pipe.rb
|
188
187
|
- lib/async/http/body/writable.rb
|
@@ -198,6 +197,7 @@ files:
|
|
198
197
|
- lib/async/http/protocol/http1.rb
|
199
198
|
- lib/async/http/protocol/http1/client.rb
|
200
199
|
- lib/async/http/protocol/http1/connection.rb
|
200
|
+
- lib/async/http/protocol/http1/finishable.rb
|
201
201
|
- lib/async/http/protocol/http1/request.rb
|
202
202
|
- lib/async/http/protocol/http1/response.rb
|
203
203
|
- lib/async/http/protocol/http1/server.rb
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2024, by Samuel Williams.
|
5
|
-
|
6
|
-
require "protocol/http/body/wrapper"
|
7
|
-
require "async/variable"
|
8
|
-
|
9
|
-
module Async
|
10
|
-
module HTTP
|
11
|
-
module Body
|
12
|
-
# Keeps track of whether a body is being read, and if so, waits for it to be closed.
|
13
|
-
class Finishable < ::Protocol::HTTP::Body::Wrapper
|
14
|
-
def initialize(body)
|
15
|
-
super(body)
|
16
|
-
|
17
|
-
@closed = Async::Variable.new
|
18
|
-
@error = nil
|
19
|
-
|
20
|
-
@reading = false
|
21
|
-
end
|
22
|
-
|
23
|
-
def reading?
|
24
|
-
@reading
|
25
|
-
end
|
26
|
-
|
27
|
-
def read
|
28
|
-
@reading = true
|
29
|
-
|
30
|
-
super
|
31
|
-
end
|
32
|
-
|
33
|
-
def close(error = nil)
|
34
|
-
unless @closed.resolved?
|
35
|
-
@error = error
|
36
|
-
@closed.value = true
|
37
|
-
end
|
38
|
-
|
39
|
-
super
|
40
|
-
end
|
41
|
-
|
42
|
-
def wait
|
43
|
-
if @reading
|
44
|
-
@closed.wait
|
45
|
-
else
|
46
|
-
self.discard
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def inspect
|
51
|
-
"#<#{self.class} closed=#{@closed} error=#{@error}> | #{super}"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|