File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ module Body
10
10
# General operations for interacting with a request or response body.
11
11
module Reader
12
12
# Read chunks from the body.
13
- # @yield [String] read chunks from the body.
13
+ # @yields {|chunk| ...} chunks from the body.
14
14
def each ( &block )
15
15
if @body
16
16
@body . each ( &block )
@@ -19,7 +19,7 @@ def each(&block)
19
19
end
20
20
21
21
# Reads the entire request/response body.
22
- # @return [String] the entire body as a string.
22
+ # @returns [String] the entire body as a string.
23
23
def read
24
24
if @body
25
25
buffer = @body . join
@@ -30,7 +30,7 @@ def read
30
30
end
31
31
32
32
# Gracefully finish reading the body. This will buffer the remainder of the body.
33
- # @return [Buffered] buffers the entire body.
33
+ # @returns [Buffered] buffers the entire body.
34
34
def finish
35
35
if @body
36
36
body = @body . finish
@@ -40,6 +40,16 @@ def finish
40
40
end
41
41
end
42
42
43
+ # Buffer the entire request/response body.
44
+ # @returns [Readable] the buffered body.
45
+ def buffered!
46
+ if @body
47
+ @body = @body . finish
48
+
49
+ return @body
50
+ end
51
+ end
52
+
43
53
# Write the body of the response to the given file path.
44
54
def save ( path , mode = ::File ::WRONLY |::File ::CREAT |::File ::TRUNC , **options )
45
55
if @body
You can’t perform that action at this time.
0 commit comments