class RequestBody
A request body is used on the client side to generate the request body using a block.
As the response body isn't available until the request is sent, the response body must be Protocol::HTTP::Body::Streamable::RequestBody#stream
ed into the request body.
Definitions
def initialize(block)
Initialize the request body with the given block.
Signature
-
parameter
block
Proc
The block that generates the body.
Implementation
def initialize(block)
super(block, Writable.new)
end
def close(error = nil)
Close will be invoked when all the input is read.
Implementation
def close(error = nil)
self.close_input(error)
end
def stream(body)
Stream the response body into the block's input.
Implementation
def stream(body)
body&.each do |chunk|
@input.write(chunk)
end
rescue => error
ensure
@input.close_write(error)
end