module Ethon::Easies::Callbacks

def set_read_callback(body)

Parameters:
  • body (String) -- The body.

Other tags:
    Example: Set the callback. -
def set_read_callback(body)
  @request_body_read = 0
  @read_callback = proc {|stream, size, num, object|
    size = size * num
    left = body.bytesize - @request_body_read
    size = left if size > left
    if size > 0
      stream.write_string(body.byteslice(@request_body_read, size), size)
      @request_body_read += size
    end
    size
  }
  self.readfunction = read_callback
end