Skip to content

Commit

Permalink
Stream#gets to use read_partial(limit) instead of read(limit).
Browse files Browse the repository at this point in the history
Having `gets` block is undesirable.
  • Loading branch information
ioquatix committed Oct 17, 2024
1 parent 60cdce5 commit 43eaec8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/protocol/http/body/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def gets(separator = NEWLINE, limit = nil, chomp: false)

# If no separator is given, this is the same as a read operation:
if separator.nil?
return read(limit)
# I tried using `read(limit)` here but it will block until the limit is reached, which is not usually desirable behaviour.
return read_partial(limit)
end

# We don't want to split on the separator, so we subtract the size of the separator:
Expand Down

0 comments on commit 43eaec8

Please sign in to comment.