lib/async/http/body/stream.rb in async-http-0.40.0 vs lib/async/http/body/stream.rb in async-http-0.40.1

- old
+ new

@@ -29,10 +29,11 @@ @input = input @output = output # Will hold remaining data in `#read`. @buffer = nil + @closed = false end attr :input attr :output @@ -108,12 +109,25 @@ # close must never be called on the input stream. huh? def close_write @output&.close end + # Close the input and output bodies. def close self.close_read self.close_write + ensure + @closed = true + end + + # Whether the stream has been closed. + def closed? + @closed + end + + # Whether there are any output chunks remaining? + def empty? + @output.empty? end private def read_next