File tree 4 files changed +13
-187
lines changed
4 files changed +13
-187
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
spec . add_dependency "async" , ">= 1.25"
21
21
spec . add_dependency "async-io" , ">= 1.28"
22
22
spec . add_dependency "async-pool" , ">= 0.2"
23
- spec . add_dependency "protocol-http" , "~> 0.22.0 "
23
+ spec . add_dependency "protocol-http" , "~> 0.22.9 "
24
24
spec . add_dependency "protocol-http1" , "~> 0.14.0"
25
25
spec . add_dependency "protocol-http2" , "~> 0.14.0"
26
26
spec . add_dependency "traces" , "~> 0.4.0"
Original file line number Diff line number Diff line change 21
21
# THE SOFTWARE.
22
22
23
23
require 'protocol/http/body/readable'
24
- require_relative 'stream'
24
+ require 'protocol/http/body/stream'
25
+
26
+ require_relative 'writable'
25
27
26
28
module Async
27
29
module HTTP
@@ -42,6 +44,7 @@ def initialize(block, input = nil)
42
44
43
45
@task = nil
44
46
@stream = nil
47
+ @output = nil
45
48
end
46
49
47
50
# We prefer streaming directly as it's the lowest overhead.
@@ -57,23 +60,18 @@ def call(stream)
57
60
58
61
# Has the producer called #finish and has the reader consumed the nil token?
59
62
def empty?
60
- if @stream
61
- @stream . empty?
62
- else
63
- false
64
- end
63
+ @output &.empty?
65
64
end
66
65
67
66
def ready?
68
- if @stream
69
- @stream . output . ready?
70
- end
67
+ @output &.ready?
71
68
end
72
69
73
70
# Read the next available chunk.
74
71
def read
75
- unless @task
76
- @stream = Stream . new ( @input )
72
+ unless @output
73
+ @output = Writable . new
74
+ @stream = ::Protocol ::HTTP ::Body ::Stream . new ( @input , @output )
77
75
78
76
@task = Task . current . async do |task |
79
77
task . annotate "Streaming hijacked body."
@@ -82,7 +80,7 @@ def read
82
80
end
83
81
end
84
82
85
- return @stream . output . read
83
+ return @output . read
86
84
end
87
85
88
86
def inspect
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 20
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
# THE SOFTWARE.
22
22
23
- require_relative '../.. /body/stream'
23
+ require 'protocol/http /body/stream'
24
24
25
25
module Async
26
26
module HTTP
@@ -88,7 +88,7 @@ def stream(task)
88
88
89
89
input = @stream . wait_for_input
90
90
91
- @body . call ( Body ::Stream . new ( input , self ) )
91
+ @body . call ( :: Protocol :: HTTP :: Body ::Stream . new ( input , self ) )
92
92
rescue Async ::Stop
93
93
# Ignore.
94
94
end
You can’t perform that action at this time.
0 commit comments