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.

Options Hash: (**options)
  • :verbose (Boolean) -- See
  • :userpwd (String) -- See
  • :useragent (String) -- See
  • :url (String) -- See
  • :upload (Boolean) -- See
  • :timeout (Integer) -- See
  • :sslversion (String) -- See
  • :sslkeytype (String) -- See
  • :sslkey (String) -- See
  • :sslcerttype (String) -- See
  • :sslcert (String) -- See
  • :ssl_verifypeer (Boolean) -- See
  • :ssl_verifyhost (Integer) -- See
  • :readfunction (String) -- See
  • :readdata (String) -- See
  • :put (String) -- See
  • :proxytype (String) -- See
  • :proxyauth (String) -- See
  • :proxy (String) -- See
  • :postfieldsize (Integer) -- See
  • :nosignal (Boolean) -- See
  • :nobody (Boolean) -- See
  • :maxredirs (Integer) -- See
  • :interface (String) -- See
  • :infilesize (Integer) -- See
  • :httppost (String) -- See
  • :httpget (Boolean) -- See
  • :httpauth (String) -- See
  • :followlocation (Boolean) -- See
  • :dns_cache_timeout (Integer) -- See
  • :customrequest (String) -- See
  • :copypostfields (String) -- See
  • :connecttimeout (Integer) -- See
  • :capath (String) -- See
  • :cainfo (String) -- See

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)

Other tags:
    See: initialize -

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

Returns:
  • (Hash) - The informations 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