Skip to content

Commit fa63b5f

Browse files
committed
Don't stream body wrappers that don't support it.
1 parent 05d0c13 commit fa63b5f

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

lib/protocol/http/body/deflate.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ def self.for(body, window_size = GZIP, level = DEFAULT_LEVEL)
8989
self.new(body, Zlib::Deflate.new(level, window_size))
9090
end
9191

92+
def stream?
93+
# We might want to revisit this design choice.
94+
# We could wrap the streaming body in a Deflate stream, but that would require an extra stream wrapper which we don't have right now. See also `Digestable#stream?`.
95+
false
96+
end
97+
9298
def read
9399
return if @stream.finished?
94100

lib/protocol/http/body/digestable.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def etag
5050
@digest.hexdigest.dump
5151
end
5252

53+
def stream?
54+
false
55+
end
56+
5357
def read
5458
if chunk = super
5559
@digest.update(chunk)

lib/protocol/http/body/file.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ def rewind
7373
@file.seek(@offset)
7474
end
7575

76+
def stream?
77+
false
78+
end
79+
7680
def read
7781
if @remaining > 0
7882
amount = [@remaining, @block_size].min

lib/protocol/http/body/inflate.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ def self.for(body, encoding = GZIP)
3232
self.new(body, Zlib::Inflate.new(encoding))
3333
end
3434

35+
def stream?
36+
false
37+
end
38+
3539
def read
3640
return if @stream.finished?
3741

lib/protocol/http/body/rewindable.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def buffered
4848
Buffered.new(@chunks)
4949
end
5050

51+
def stream?
52+
false
53+
end
54+
5155
def read
5256
if @index < @chunks.size
5357
chunk = @chunks[@index]

0 commit comments

Comments
 (0)