File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,13 @@ def read_next
8989 if @body
9090 # User's may forget to call #close...
9191 if chunk = @body . read
92+ # If the user reads exactly the content length, we close the stream automatically:
93+ # https://github.com/socketry/async-http/issues/183
94+ if @body . empty?
95+ @body . close
96+ @body = nil
97+ end
98+
9299 return chunk
93100 else
94101 # So if we are at the end of the stream, we close it automatically:
Original file line number Diff line number Diff line change 5252 expect ( input . body ) . to be_nil
5353 end
5454
55+ it "can read exactly the content length" do
56+ expect ( body ) . to receive ( :close )
57+
58+ expect ( input . read ( sample_data . join . bytesize ) ) . to be == sample_data . join
59+ end
60+
5561 it "can read no input" do
5662 expect ( input . read ( 0 ) ) . to be == ""
5763 end
You can’t perform that action at this time.
0 commit comments