Sha256: 08b4bbccd4e26d30748875d57b2fb3b278c1a351a57c84e79ca3003647087cd3
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true # Released under the MIT License. # Copyright, 2019-2024, by Samuel Williams. require "protocol/http/body/readable" module Protocol module HTTP1 module Body # A body that reads all remaining data from the connection. class Remainder < HTTP::Body::Readable BLOCK_SIZE = 1024 * 64 # block_size may be removed in the future. It is better managed by connection. def initialize(connection) @connection = connection end def empty? @connection.nil? end 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 close(error = nil) self.discard super end def read @connection&.readpartial(BLOCK_SIZE) rescue EOFError @connection.receive_end_stream! @connection = nil end def inspect "\#<#{self.class} state=#{@connection ? 'open' : 'closed'}>" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
protocol-http1-0.24.0 | lib/protocol/http1/body/remainder.rb |