module Ethon::Easy::Operations

This module contains the logic to prepare and perform an easy.

Public Instance Methods

cleanup() click to toggle source

Clean up the easy.

@example Perform clean up.

easy.cleanup

@return the result of the free which is nil

# File lib/ethon/easy/operations.rb, line 44
def cleanup
  handle.free
end
handle() click to toggle source

Returns a pointer to the curl easy handle.

@example Return the handle.

easy.handle

@return [ FFI::Pointer ] A pointer to the curl easy handle.

# File lib/ethon/easy/operations.rb, line 13
def handle
  @handle ||= FFI::AutoPointer.new(Curl.easy_init, Curl.method(:easy_cleanup))
end
handle=(h) click to toggle source

Sets a pointer to the curl easy handle. @param [ ::FFI::Pointer ] Easy handle that will be assigned.

# File lib/ethon/easy/operations.rb, line 19
def handle=(h)
  @handle = h
end
perform() click to toggle source

Perform the easy request.

@example Perform the request.

easy.perform

@return [ Integer ] The return code.

# File lib/ethon/easy/operations.rb, line 29
def perform
  @return_code = Curl.easy_perform(handle)
  if Ethon.logger.debug?
    Ethon.logger.debug { "ETHON: performed #{log_inspect}" }
  end
  complete
  @return_code
end
prepare() click to toggle source

Prepare the easy. Options, headers and callbacks were set.

@example Prepare easy.

easy.prepare

@deprecated It is no longer necessary to call prepare.

# File lib/ethon/easy/operations.rb, line 55
def prepare
  Ethon.logger.warn(
    "ETHON: It is no longer necessary to call "+
    "Easy#prepare. It's going to be removed "+
    "in future versions."
  )
end