class Async::HTTP::Protocol::HTTP1::Finishable
Keeps track of whether a body is being read, and if so, waits for it to be closed.
def close(error = nil)
def close(error = nil) super unless @closed.resolved? @error = error @closed.resolve(true) end end
def initialize(body)
Initialize the finishable wrapper.
def initialize(body) super(body) @closed = Async::Promise.new @error = nil @reading = false end
def inspect
def inspect "#<#{self.class} closed=#{@closed} error=#{@error}> | #{super}" end
def read
Read the next chunk from the body.
def read @reading = true super end
def reading?
def reading? @reading end
def wait(persistent = true)
Wait for the body to be fully consumed or discard it.
def wait(persistent = true) if @reading @closed.wait elsif persistent # If the connection can be reused, let's gracefully discard the body: self.discard else # Else, we don't care about the body, so we can close it immediately: self.close end end