lib/async/http/body/chunked.rb in async-http-0.24.3 vs lib/async/http/body/chunked.rb in async-http-0.25.0
- old
+ new
@@ -26,41 +26,45 @@
class Chunked < Readable
def initialize(protocol)
@protocol = protocol
@finished = false
- @bytesize = 0
+ @length = 0
@count = 0
end
def empty?
@finished
end
+ def stop(error)
+ @protocol.close
+ @finished = true
+ end
+
def read
return nil if @finished
- size = @protocol.read_line.to_i(16)
+ length = @protocol.read_line.to_i(16)
- if size == 0
+ if length == 0
+ @finished = true
@protocol.read_line
- @finished = true
-
return nil
end
- chunk = @protocol.stream.read(size)
+ chunk = @protocol.stream.read(length)
@protocol.read_line # Consume the trailing CRLF
- @bytesize += size
+ @length += length
@count += 1
return chunk
end
def inspect
- "\#<#{self.class} #{@bytesize} bytes read in #{@count} chunks>"
+ "\#<#{self.class} #{@length} bytes read in #{@count} chunks>"
end
end
end
end
end