Module: Ethon::Easy::Operations

Included in:
Ethon::Easy
Defined in:
lib/ethon/easy/operations.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#cleanupObject

Clean up the easy.

Examples:

Perform clean up.

easy.cleanup

Returns:

  • the result of the free which is nil


44
45
46
# File 'lib/ethon/easy/operations.rb', line 44

def cleanup
  handle.free
end

#handleFFI::Pointer

Returns a pointer to the curl easy handle.

Examples:

Return the handle.

easy.handle

Returns:

  • (FFI::Pointer)

    A pointer to the curl easy handle.


13
14
15
# File 'lib/ethon/easy/operations.rb', line 13

def handle
  @handle ||= FFI::AutoPointer.new(Curl.easy_init, Curl.method(:easy_cleanup))
end

#handle=(h) ⇒ Object

Sets a pointer to the curl easy handle.

Parameters:

  • Easy (::FFI::Pointer)

    handle that will be assigned.


19
20
21
# File 'lib/ethon/easy/operations.rb', line 19

def handle=(h)
  @handle = h
end

#performInteger

Perform the easy request.

Examples:

Perform the request.

easy.perform

Returns:

  • (Integer)

    The return code.


29
30
31
32
33
34
35
36
# 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

#prepareObject

Deprecated.

It is no longer necessary to call prepare.

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

Examples:

Prepare easy.

easy.prepare

55
56
57
58
59
60
61
# 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