Skip to content

Commit ea2ea41

Browse files
committed
Add "rewindable?" predicate to body.
1 parent a472da1 commit ea2ea41

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

lib/protocol/http/body/buffered.rb

+6
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,14 @@ def write(chunk)
7777
@chunks << chunk
7878
end
7979

80+
def rewindable?
81+
true
82+
end
83+
8084
def rewind
8185
@index = 0
86+
87+
return true
8288
end
8389

8490
def inspect

lib/protocol/http/body/completable.rb

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ def initialize(body, callback)
2424
@callback = callback
2525
end
2626

27+
def rewindable?
28+
false
29+
end
30+
31+
def rewind
32+
false
33+
end
34+
2735
def finish
2836
super.tap do
2937
if @callback

lib/protocol/http/body/readable.rb

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ def ready?
2929
false
3030
end
3131

32+
def rewindable?
33+
false
34+
end
35+
36+
def rewind
37+
false
38+
end
39+
3240
def length
3341
nil
3442
end

lib/protocol/http/body/rewindable.rb

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def rewind
5454
@index = 0
5555
end
5656

57+
def rewindable?
58+
true
59+
end
60+
5761
def inspect
5862
"\#<#{self.class} #{@index}/#{@chunks.size} chunks read>"
5963
end

lib/protocol/http/body/wrapper.rb

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ def ready?
4242
@body.ready?
4343
end
4444

45+
def rewind
46+
@body.rewind
47+
end
48+
49+
def rewindable?
50+
@body.rewind?
51+
end
52+
4553
def length
4654
@body.length
4755
end

0 commit comments

Comments
 (0)