lib/protocol/http/body/stream.rb in protocol-http-0.24.2 vs lib/protocol/http/body/stream.rb in protocol-http-0.24.3
- old
+ new
@@ -17,10 +17,11 @@
raise ArgumentError, "Non-writable output!" unless output.respond_to?(:write)
# Will hold remaining data in `#read`.
@buffer = nil
@closed = false
+ @closed_read = false
end
attr :input
attr :output
@@ -144,10 +145,13 @@
def flush
end
def close_read
+ @closed_read = true
+ @buffer = nil
+
@input&.close
@input = nil
end
# close must never be called on the input stream. huh?
@@ -179,11 +183,10 @@
private
def read_next
if @input
return @input.read
- else
- @input = nil
+ elsif @closed_read
raise IOError, "Stream is not readable, input has been closed!"
end
end
end
end