class Ethon::Easy

See curl.haxx.se/libcurl/c/libcurl-easy.html for more informations.
This is the class representing the libcurl easy interface

def finalizer(easy)

Parameters:
  • easy (Easy) -- The easy to free.

Other tags:
    Example: Free easy handle. -
def finalizer(easy)
  proc {
    Curl.slist_free_all(easy.header_list) if easy.header_list
    Curl.easy_cleanup(easy.handle)
  }
end

def handle

Returns:
  • (FFI::Pointer) - A pointer to the curl easy handle.

Other tags:
    Example: Return the handle. -
def handle
  @handle ||= Curl.easy_init
end

def initialize(options = {})

Returns:
  • (Easy) - A new Easy.

Parameters:
  • options (Hash) -- The options to set.

Other tags:
    Example: Create a new Easy. -
def initialize(options = {})
  Curl.init
  ObjectSpace.define_finalizer(self, self.class.finalizer(self))
  set_attributes(options)
end

def reset

Other tags:
    Example: Reset. -
def reset
  (instance_variables - [:@handle, :@header_list]).each do |ivar|
    instance_variable_set(ivar, nil)
  end
  Curl.easy_reset(handle)
end

def set_attributes(options)

Parameters:
  • options (Hash) -- The options.

Other tags:
    Example: Set options. -
def set_attributes(options)
  options.each_pair do |key, value|
    method("#{key}=").call(value) if respond_to?("#{key}=")
  end
end

def to_hash

def to_hash
  hash = {}
  hash[:return_code] = return_code
  hash[:response_header] = response_header
  hash[:response_body] = response_body
  Easies::Informations::AVAILABLE_INFORMATIONS.keys.each do |info|
    hash[info] = method(info).call
  end
  hash
end