lib/protocol/http/body/stream.rb in protocol-http-0.33.0 vs lib/protocol/http/body/stream.rb in protocol-http-0.34.0

- old
+ new

@@ -19,10 +19,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 @@ -249,24 +250,25 @@ # This is currently a no-op. def flush end # Close the input body. - def close_read - if @input + def close_read(error = nil) + if input = @input + @input = nil @closed_read = true @buffer = nil - @input&.close - @input = nil + input.close(error) end end # Close the output body. - def close_write - if @output - @output&.close + def close_write(error = nil) + if output = @output @output = nil + + output.close_write(error) end end # Close the input and output bodies. def close(error = nil)