class Protocol::HTTP::Body::Wrapper
Wrapping body instance. Typically you’d override ‘#read`.
def self.wrap(message)
@parameter message [Request | Response] the message to wrap.
Wrap the body of the given message in a new instance of this class.
def self.wrap(message) if body = message.body message.body = self.new(body) end end
def as_json(...)
Convert the body to a hash suitable for serialization.
def as_json(...) { class: self.class.name, body: @body&.as_json } end
def buffered
def buffered @body.buffered end
def close(error = nil)
Close the body.
def close(error = nil) @body.close(error) # It's a no-op: # super end
def discard
def discard @body.discard end
def empty?
def empty? @body.empty? end
def initialize(body)
Initialize the wrapper with the given body.
def initialize(body) @body = body end
def inspect
Inspect the wrapped body. The wrapper, by default, is transparent.
def inspect @body.inspect end
def length
def length @body.length end
def read
def read @body.read end
def ready?
def ready? @body.ready? end
def rewind
def rewind @body.rewind end
def rewindable?
def rewindable? @body.rewindable? end
def to_json(...)
Convert the body to JSON.
def to_json(...) as_json.to_json(...) end