Skip to content

Commit 479d0bf

Browse files
Ensure binary encoding.
1 parent 1ed69f0 commit 479d0bf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/protocol/http/body/stream.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ module Reader
5252
# @parameter buffer [String] the buffer which will receive the data
5353
# @returns [String] a buffer containing the data
5454
def read(length = nil, buffer = nil)
55-
return (buffer ? buffer.clear : String.new) if length == 0
55+
if length == 0
56+
return (buffer ? buffer.clear : String.new(encoding: Encoding::BINARY))
57+
end
5658

57-
buffer ||= String.new.force_encoding(Encoding::BINARY)
59+
buffer ||= String.new(encoding: Encoding::BINARY)
5860

5961
# Take any previously buffered data and replace it into the given buffer.
6062
if @buffer

0 commit comments

Comments
 (0)