Skip to content

Commit 93df4e7

Browse files
committed
Minor improvements to documentation.
1 parent 7330bc6 commit 93df4e7

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/protocol/http1/body/chunked.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def read
5757
if length == 0
5858
read_trailer
5959

60+
# The final chunk has been read and the stream is now closed:
6061
@stream = nil
6162
@finished = true
6263

@@ -75,6 +76,7 @@ def read
7576
return chunk
7677
end
7778

79+
# If the stream has been closed before we have read the final chunk, raise an error:
7880
raise EOFError, "Stream closed before expected length was read!"
7981
end
8082
end

lib/protocol/http1/body/fixed.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Body
1111
class Fixed < HTTP::Body::Readable
1212
def initialize(stream, length)
1313
@stream = stream
14+
1415
@length = length
1516
@remaining = length
1617
end
@@ -39,14 +40,15 @@ def close(error = nil)
3940
def read
4041
if @remaining > 0
4142
if @stream
42-
# `readpartial` will raise `EOFError` if the stream is closed/finished:
43+
# `readpartial` will raise `EOFError` if the stream is finished, or `IOError` if the stream is closed.
4344
if chunk = @stream.readpartial(@remaining)
4445
@remaining -= chunk.bytesize
4546

4647
return chunk
4748
end
4849
end
4950

51+
# If the stream has been closed before we have read the expected length, raise an error:
5052
raise EOFError, "Stream closed before expected length was read!"
5153
end
5254
end

lib/protocol/http1/body/remainder.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
module Protocol
99
module HTTP1
1010
module Body
11+
# A body that reads all remaining data from the stream.
1112
class Remainder < HTTP::Body::Readable
1213
BLOCK_SIZE = 1024 * 64
1314

@@ -22,8 +23,8 @@ def empty?
2223

2324
def close(error = nil)
2425
if @stream
25-
@stream.close_read
2626
# We can't really do anything in this case except close the connection.
27+
@stream.close_read
2728
@stream = nil
2829
end
2930

0 commit comments

Comments
 (0)