Module: Ethon::Curl

Extended by:
Ethon::Curls::AuthTypes, Ethon::Curls::Codes, Ethon::Curls::FormOptions, Ethon::Curls::Functions, Ethon::Curls::Infos, Ethon::Curls::Messages, Ethon::Curls::Options, Ethon::Curls::ProxyTypes, Ethon::Curls::SslVersions, FFI::Library
Defined in:
lib/ethon/curl.rb,
lib/ethon/curls/classes.rb,
lib/ethon/curls/settings.rb,
lib/ethon/curls/constants.rb

Overview

FFI Wrapper module for Curl. Holds constants and required initializers.

Defined Under Namespace

Classes: FDSet, Msg, MsgData, Timeval

Constant Summary collapse

VERSION_NOW =

:nodoc:

3
GLOBAL_SSL =

Flag. Initialize SSL.

0x01
GLOBAL_WIN32 =

Flag. Initialize win32 socket libraries.

0x02
GLOBAL_ALL =

Flag. Initialize everything possible.

(GLOBAL_SSL | GLOBAL_WIN32)
GLOBAL_DEFAULT =

Flag. Initialize everything by default.

GLOBAL_ALL
EasyCode =

:nodoc:

enum(:easy_code, easy_codes)
MultiCode =

:nodoc:

enum(:multi_code, multi_codes)
Option =

:nodoc:

enum(:option, options.to_a.flatten)
OptionType =

:nodoc:

enum(option_types.to_a.flatten)
InfoType =

:nodoc:

enum(info_types.to_a.flatten)
Info =
enum(:info, infos.to_a.flatten)
FormOption =

Form options, used by FormAdd for temporary storage, refer github.com/bagder/curl/blob/master/lib/formdata.h#L51 for details

enum(:form_option, form_options)
Auth =

:nodoc:

enum(auth_types.to_a.flatten)
Proxy =

:nodoc:

enum(proxy_types.to_a.flatten)
SSLVersion =

:nodoc:

enum(ssl_versions.to_a.flatten)
MsgCode =

:nodoc:

enum(:msg_code, msg_codes)
@@initialized =
false
@@init_mutex =
Mutex.new

Class Method Summary collapse

Methods included from Ethon::Curls::Codes

easy_codes, multi_codes

Methods included from Ethon::Curls::Options

option_types, options, set_option

Methods included from Ethon::Curls::Infos

double_ptr, get_info_double, get_info_long, get_info_string, info_types, infos, long_ptr, string_ptr

Methods included from Ethon::Curls::FormOptions

form_options

Methods included from Ethon::Curls::AuthTypes

auth_types

Methods included from Ethon::Curls::ProxyTypes

proxy_types

Methods included from Ethon::Curls::SslVersions

ssl_versions

Methods included from Ethon::Curls::Messages

msg_codes

Methods included from Ethon::Curls::Functions

extended

Class Method Details

.initObject

This function sets up the program environment that libcurl needs. Think of it as an extension of the library loader.

This function must be called at least once within a program (a program is all the code that shares a memory space) before the program calls any other function in libcurl. The environment it sets up is constant for the life of the program and is the same for every program, so multiple calls have the same effect as one call.

The flags option is a bit pattern that tells libcurl exactly what features to init, as described below. Set the desired bits by ORing the values together. In normal operation, you must specify CURL_GLOBAL_ALL. Don’t use any other value unless you are familiar with it and mean to control internal operations of libcurl.

This function is not thread safe. You must not call it when any other thread in the program (i.e. a thread sharing the same memory) is running. This doesn’t just mean no other thread that is using libcurl. Because curl_global_init() calls functions of other libraries that are similarly thread unsafe, it could conflict with any other thread that uses these other libraries.



61
62
63
64
65
66
67
68
69
# File 'lib/ethon/curl.rb', line 61

def init
  @@init_mutex.synchronize {
    if not @@initialized
      raise Errors::GlobalInit.new if Curl.global_init(GLOBAL_ALL) != 0
      @@initialized = true
      Ethon.logger.debug("ETHON: Libcurl initialized") if Ethon.logger
    end
  }
end

.windows?Boolean

:nodoc:

Returns:

  • (Boolean)


14
15
16
# File 'lib/ethon/curls/classes.rb', line 14

def Curl.windows?
  !(RbConfig::CONFIG['host_os'] !~ /mingw|mswin|bccwin/)
end