lib/async/http/protocol/http2/stream.rb in async-http-0.45.3 vs lib/async/http/protocol/http2/stream.rb in async-http-0.45.4

- old
+ new

@@ -28,13 +28,17 @@ def initialize(delegate, *args) super(*args) @delegate = delegate - @body = body + # This is the body that is being sent. + @body = nil + + # The remainder of the current chunk being sent. @remainder = nil + # The task that is handling sending the body. @task = nil end attr_accessor :delegate attr :body @@ -45,16 +49,10 @@ def accept_push_promise_stream(headers, stream_id) @delegate.accept_push_promise_stream(headers, stream_id) end - def close! - super - - @delegate.close! - end - def send_body(body, task: Async::Task.current) # TODO Might need to stop this task when body is cancelled. @task = task.async do |subtask| subtask.annotate "Sending body: #{body.class}" @@ -140,16 +138,24 @@ @delegate.receive_reset_stream(self, error_code) return error_code end - def stop_connection(error) + def close! + @delegate.close! + + super + end + + def close(error = nil) + super + if @body @body.close(error) @body = nil end - @delegate.stop_connection(error) + @delegate.stream_closed(error) end end end end end