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
89
89
if @body
90
90
# User's may forget to call #close...
91
91
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
+
92
99
return chunk
93
100
else
94
101
# So if we are at the end of the stream, we close it automatically:
Original file line number Diff line number Diff line change 52
52
expect ( input . body ) . to be_nil
53
53
end
54
54
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
+
55
61
it "can read no input" do
56
62
expect ( input . read ( 0 ) ) . to be == ""
57
63
end
You can’t perform that action at this time.
0 commit comments