Module Ethon::Easy::ResponseCallbacks
In: lib/ethon/easy/response_callbacks.rb

This module contains the logic for the response callbacks. The on_complete callback is the only one at the moment.

You can set multiple callbacks, which are then executed in the same order.

  easy.on_complete { p 1 }
  easy.on_complete { p 2 }
  easy.complete
  #=> 1
  #=> 2

You can clear the callbacks:

  easy.on_complete { p 1 }
  easy.on_complete { p 2 }
  easy.on_complete.clear
  easy.on_complete
  #=> []

Methods

Public Instance methods

Execute on_body callbacks.

@example Execute on_body.

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

@return [ Object ] If there are no on_body callbacks, returns the symbol :unyielded.

Execute on_complete callbacks.

@example Execute on_completes.

  request.complete

Execute on_headers callbacks.

@example Execute on_headers.

  request.headers

Set on_body callback.

@example Set on_body.

  request.on_body { |chunk| p "yay" }

@param [ Block ] block The block to execute.

Set on_complete callback.

@example Set on_complete.

  request.on_complete { p "yay" }

@param [ Block ] block The block to execute.

Set on_headers callback.

@example Set on_headers.

  request.on_headers { p "yay" }

@param [ Block ] block The block to execute.

Set on_progress callback.

@example Set on_progress.

  request.on_progress {|dltotal, dlnow, ultotal, ulnow| p "#{dltotal} #{dlnow} #{ultotal} #{ulnow}" }

@param [ Block ] block The block to execute.

Execute on_progress callbacks.

@example Execute on_progress.

  request.body(1, 1, 1, 1)

[Validate]