async-http 0.77.0 → 0.78.0

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
  SHA256:
3
- metadata.gz: 5a6e20407a7969b8eebeaf3f3a2dac09bdb3fe48130454ae49f46251a03b5c98
4
- data.tar.gz: a827ae19dc5c7f60ed338357091f556d1e48b183fe8ab0c119d75547fce4a6cd
3
+ metadata.gz: 76e78af8d20808d557b1c13c850af0a268de5535726ba07708b2012eb8752029
4
+ data.tar.gz: 53bdf9b950394a03ca8c1fd47befe51e8ba51a5cce82aa47c01111df7efd21b4
5
5
  SHA512:
6
- metadata.gz: 116770838b19e96fdc9ed4e1db8af834f0ed8676542d1090ed88c90d02ac0b978bd94378b41edc151108d86e61c39d2fbb9680d217790e1b1cb3f2ceed2aa64e
7
- data.tar.gz: 2b05b93835b83052a89127f12db03fdcd79007b6b0f396134d9818352e48ffaf012057c0b818a56633f3e8b510e7861438e8016d2519bd4d0dec425dfd1113f7
6
+ metadata.gz: 43c49b50bb88955088b74926e3fe33310f38f4b09d9b9ecdc538a9835c9be5b8be0e172e09794324a53db99e09b0102ae96fc179af13578a758f42644d6f4011
7
+ data.tar.gz: fa1a0d97f326bdd72010f07cfe21004b0da8f75fe4556778bd3b918f42e2e85f22bc41cd07e2a64b4395540e531a879480e634a8fe401ee0d0d7c146af8b61d7
checksums.yaml.gz.sig CHANGED
Binary file
@@ -14,7 +14,6 @@ require "protocol/http/methods"
14
14
  require "traces/provider"
15
15
 
16
16
  require_relative "protocol"
17
- require_relative "body/finishable"
18
17
 
19
18
  module Async
20
19
  module HTTP
@@ -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 "../../body/finishable"
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 = Body::Finishable.new(body)
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
@@ -41,6 +41,10 @@ module Async
41
41
  def remote_address= value
42
42
  @remote_address = value
43
43
  end
44
+
45
+ def inspect
46
+ "#<#{self.class}:0x#{self.object_id.to_s(16)} method=#{method} path=#{path} version=#{version}>"
47
+ end
44
48
  end
45
49
  end
46
50
  end
@@ -33,6 +33,10 @@ module Async
33
33
  def remote_address= value
34
34
  @remote_address = value
35
35
  end
36
+
37
+ def inspect
38
+ "#<#{self.class}:0x#{self.object_id.to_s(16)} status=#{status}>"
39
+ end
36
40
  end
37
41
  end
38
42
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module HTTP
8
- VERSION = "0.77.0"
8
+ VERSION = "0.78.0"
9
9
  end
10
10
  end
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.77.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-19 00:00:00.000000000 Z
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