Method: Ethon::Easy::ResponseCallbacks#body

Defined in:
lib/ethon/easy/response_callbacks.rb

#body(chunk) ⇒ Object

Execute on_body callbacks.

Examples:

Execute on_body.

request.body("This data came from HTTP.")

Returns:

  • (Object)

    If there are no on_body callbacks, returns the symbol :unyielded.



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/ethon/easy/response_callbacks.rb', line 122

def body(chunk)
  if defined?(@on_body) and not @on_body.nil?
    result = nil
    @on_body.each do |callback|
      result = callback.call(chunk, self)
      break if result == :abort
    end
    result
  else
    :unyielded
  end
end