Skip to content

Commit

Permalink
Add support for #close_write.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Sep 10, 2024
1 parent f5e1ea1 commit f2ffaca
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/protocol/rack/body/streaming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f2ffaca

Please sign in to comment.