class Protocol::HTTP1::Body::Remainder
Represents the remainder of the body, which reads all the data from the connection until it is finished.
def as_json(...)
def as_json(...) super.merge( block_size: @block_size, state: @connection ? "open" : "closed" ) end
def close(error = nil)
Close the connection.
def close(error = nil) self.discard super end
def discard
def discard if connection = @connection @connection = nil # Ensure no further requests can be read from the connection, as we are discarding the body which may not be fully read: connection.close_read end end
def empty?
def empty? @connection.nil? end
def initialize(connection, block_size: BLOCK_SIZE)
Initialize the body with the given connection.
def initialize(connection, block_size: BLOCK_SIZE) @connection = connection @block_size = block_size end
def inspect
def inspect "#<#{self.class} #{@block_size} byte blocks, #{empty? ? 'finished' : 'reading'}>" end
def read
Read a chunk of data.
def read @connection&.readpartial(@block_size) rescue EOFError if connection = @connection @connection = nil connection.receive_end_stream! end return nil end