class Protocol::HTTP::Body::Completable
Invokes a callback once the body has completed, either successfully or due to an error.
def self.wrap(message, &block)
@parameter message [Request | Response] the message body.
Wrap a message body with a callback. If the body is empty, the callback is invoked immediately.
def self.wrap(message, &block) if body = message&.body and !body.empty? message.body = self.new(message.body, block) else yield end end
def close(error = nil)
Close the body and invoke the callback. If an error is given, it is passed to the callback.
def close(error = nil) if @callback @callback.call(error) @callback = nil end super end
def initialize(body, callback)
@parameter body [Readable] the body to wrap.
Initialize the completable body with a callback.
def initialize(body, callback) super(body) @callback = callback end
def rewind
def rewind false end
def rewindable?
def rewindable? false end