lib/ftw/protocol.rb in ftw-0.0.34 vs lib/ftw/protocol.rb in ftw-0.0.35
- old
+ new
@@ -67,11 +67,11 @@
end
end # def write_http_body
# Encode the given text as in 'chunked' encoding.
def encode_chunked(text)
- return sprintf("%x%s%s%s", text.size, CRLF, text, CRLF)
+ return sprintf("%x%s%s%s", text.bytesize, CRLF, text, CRLF)
end # def encode_chunked
def write_http_body_chunked(body, io)
if body.is_a?(String)
io.write(encode_chunked(body))
@@ -147,18 +147,18 @@
# given. This method is generally only called by http clients, not servers.
def read_http_body_length(length, &block)
remaining = length
while remaining > 0
data = @body.read(remaining)
- @logger.debug("Read bytes", :length => data.size)
- if data.size > remaining
+ @logger.debug("Read bytes", :length => data.bytesize)
+ if data.bytesize > remaining
# Read too much data, only wanted part of this. Push the rest back.
yield data[0..remaining]
remaining = 0
@body.pushback(data[remaining .. -1]) if remaining < 0
else
yield data
- remaining -= data.size
+ remaining -= data.bytesize
end
end
end # def read_http_body_length
# This is kind of messed, need to fix it.