Skip to content

Commit 43eaec8

Browse files
committed
Stream#gets to use read_partial(limit) instead of read(limit).
Having `gets` block is undesirable.
1 parent 60cdce5 commit 43eaec8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/protocol/http/body/stream.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ def gets(separator = NEWLINE, limit = nil, chomp: false)
202202

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

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

0 commit comments

Comments
 (0)