summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-08 00:34:42 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-08 00:34:42 +0000
commit816efa9ae1e6917d488ddf46a76ef40bcb5298a8 (patch)
treed3bdd7ed8237cfb660e97958382c6a9b920a32bc /lib
parent7fd11834676eb4df34f7160aed1cdf798e60d0b9 (diff)
net/protocol: use binary string buffers
Not an encoding expert, but this seems necessary for the next change. All of the IO#read, IO#read_nonblock and related methods will return a binary string when given a length argument; so anything appended to these buffers via << will be binary. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/protocol.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 45da560062..e1586923c8 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -84,7 +84,7 @@ module Net # :nodoc:
@read_timeout = read_timeout
@continue_timeout = continue_timeout
@debug_output = debug_output
- @rbuf = ''.dup
+ @rbuf = ''.b
end
attr_reader :io
@@ -114,7 +114,7 @@ module Net # :nodoc:
public
- def read(len, dest = ''.dup, ignore_eof = false)
+ def read(len, dest = ''.b, ignore_eof = false)
LOG "reading #{len} bytes..."
read_bytes = 0
begin
@@ -134,7 +134,7 @@ module Net # :nodoc:
dest
end
- def read_all(dest = ''.dup)
+ def read_all(dest = ''.b)
LOG 'reading all...'
read_bytes = 0
begin
@@ -193,7 +193,7 @@ module Net # :nodoc:
def rbuf_consume(len)
if len == @rbuf.size
s = @rbuf
- @rbuf = ''.dup
+ @rbuf = ''.b
else
s = @rbuf.slice!(0, len)
end
@@ -340,7 +340,7 @@ module Net # :nodoc:
end
def using_each_crlf_line
- @wbuf = ''.dup
+ @wbuf = ''.b
yield
if not @wbuf.empty? # unterminated last line
write0 dot_stuff(@wbuf.chomp) + "\r\n"