diff --git a/lib/protocol/rack/body/streaming.rb b/lib/protocol/rack/body/streaming.rb index 1b5557e..10571ed 100644 --- a/lib/protocol/rack/body/streaming.rb +++ b/lib/protocol/rack/body/streaming.rb @@ -41,15 +41,23 @@ def write(chunk) end end - def close + def close(error = nil) @fiber = nil if from = @from @from = nil - from.transfer(nil) + if error + from.raise(error) + else + from.transfer(nil) + end end end + def close_write(error = nil) + close(error) + end + def read raise RuntimeError, "Stream is already being read!" if @from