We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8244dbf commit dbc874aCopy full SHA for dbc874a
lib/protocol/http/body/stream.rb
@@ -295,7 +295,14 @@ def empty?
295
296
def read_next
297
if @input
298
- return @input.read
+ # User's may forget to call #close...
299
+ if chunk = @input.read
300
+ return chunk
301
+ else
302
+ # So if we are at the end of the stream, we close it automatically:
303
+ @input.close
304
+ @input = nil
305
+ end
306
elsif @closed_read
307
raise IOError, "Stream is not readable, input has been closed!"
308
end
test/protocol/http/body/streamable.rb
@@ -175,9 +175,10 @@
175
176
with "#close" do
177
it "can close the body" do
178
- expect(input).not.to receive(:close)
+ expect(input).to receive(:close)
179
180
expect(body.read).to be == "Hello"
181
+
182
body.close
183
184
0 commit comments