Module: Ethon::Curls::Infos

Included in:
Ethon::Curl
Defined in:
lib/ethon/curls/infos.rb

Overview

This module contains logic for the available informations on an easy, eg.: connect_time.

Instance Method Summary collapse

Instance Method Details

#debug_info_typesHash

Examples:

Return debug info types.

Ethon::Curl.debug_info_types

Returns:

  • (Hash)

    The info types available to curl_debug_callback.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ethon/curls/infos.rb', line 30

def debug_info_types
  [
    :text, 0,
    :header_in,
    :header_out,
    :data_in,
    :data_out,
    :ssl_data_in,
    :ssl_data_out
  ]
end

#double_ptr::FFI::Pointer

Return a double pointer.

Examples:

Return a double pointer.

Curl.double_ptr

Returns:

  • (::FFI::Pointer)

    The double pointer.



168
169
170
# File 'lib/ethon/curls/infos.rb', line 168

def double_ptr
  @double_ptr ||= ::FFI::MemoryPointer.new(:double)
end

#get_info_double(option, handle) ⇒ Float

Return info as float

Examples:

Return info.

Curl.get_info_double(:response_code, easy)

Parameters:

  • option (Symbol)

    The option name.

  • handle (::FFI::Pointer)

    The easy handle.

Returns:

  • (Float)

    The info.



136
137
138
139
140
# File 'lib/ethon/curls/infos.rb', line 136

def get_info_double(option, handle)
  if easy_getinfo(handle, option, double_ptr) == :ok
    double_ptr.read_double
  end
end

#get_info_long(option, handle) ⇒ Integer

Return info as integer.

Examples:

Return info.

Curl.get_info_long(:response_code, easy)

Parameters:

  • option (Symbol)

    The option name.

  • handle (::FFI::Pointer)

    The easy handle.

Returns:

  • (Integer)

    The info.



121
122
123
124
125
# File 'lib/ethon/curls/infos.rb', line 121

def get_info_long(option, handle)
  if easy_getinfo(handle, option, long_ptr) == :ok
    long_ptr.read_long
  end
end

#get_info_string(option, handle) ⇒ String

Return info as string.

Examples:

Return info.

Curl.get_info_string(:primary_ip, easy)

Parameters:

  • option (Symbol)

    The option name.

  • handle (::FFI::Pointer)

    The easy handle.

Returns:

  • (String)

    The info.



106
107
108
109
110
# File 'lib/ethon/curls/infos.rb', line 106

def get_info_string(option, handle)
  if easy_getinfo(handle, option, string_ptr) == :ok
    string_ptr.read_pointer.read_string
  end
end

#info_typesHash

Return info types.

Examples:

Return info types.

Ethon::Curl.info_types

Returns:

  • (Hash)

    The info types.



14
15
16
17
18
19
20
21
# File 'lib/ethon/curls/infos.rb', line 14

def info_types
  {
    :string =>0x100000,
    :long =>  0x200000,
    :double =>0x300000,
    :slist => 0x400000
  }
end

#infosHash

Return Info details, refer github.com/bagder/curl/blob/master/src/tool_writeout.c#L66 for details

Examples:

Return infos.

Ethon::Curl.infos

Returns:

  • (Hash)

    The infos.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ethon/curls/infos.rb', line 49

def infos
  {
    :effective_url =>          info_types[:string] + 1,
    :response_code =>          info_types[:long]   + 2,
    :total_time =>             info_types[:double] + 3,
    :namelookup_time =>        info_types[:double] + 4,
    :connect_time =>           info_types[:double] + 5,
    :pretransfer_time =>       info_types[:double] + 6,
    :size_upload =>            info_types[:double] + 7,
    :size_download =>          info_types[:double] + 8,
    :speed_download =>         info_types[:double] + 9,
    :speed_upload =>           info_types[:double] + 10,
    :header_size =>            info_types[:long]   + 11,
    :request_size =>           info_types[:long]   + 12,
    :ssl_verifyresult =>       info_types[:long]   + 13,
    :filetime =>               info_types[:long]   + 14,
    :content_length_download =>info_types[:double] + 15,
    :content_length_upload =>  info_types[:double] + 16,
    :starttransfer_time =>     info_types[:double] + 17,
    :content_type =>           info_types[:string] + 18,
    :redirect_time =>          info_types[:double] + 19,
    :redirect_count =>         info_types[:long]   + 20,
    :private =>                info_types[:string] + 21,
    :http_connectcode =>       info_types[:long]   + 22,
    :httpauth_avail =>         info_types[:long]   + 23,
    :proxyauth_avail =>        info_types[:long]   + 24,
    :os_errno =>               info_types[:long]   + 25,
    :num_connects =>           info_types[:long]   + 26,
    :ssl_engines =>            info_types[:slist]  + 27,
    :cookielist =>             info_types[:slist]  + 28,
    :lastsocket =>             info_types[:long]   + 29,
    :ftp_entry_path =>         info_types[:string] + 30,
    :redirect_url =>           info_types[:string] + 31,
    :primary_ip =>             info_types[:string] + 32,
    :appconnect_time =>        info_types[:double] + 33,
    :certinfo =>               info_types[:slist]  + 34,
    :condition_unmet =>        info_types[:long]   + 35,
    :rtsp_session_id =>        info_types[:string] + 36,
    :rtsp_client_cseq =>       info_types[:long]   + 37,
    :rtsp_server_cseq =>       info_types[:long]   + 38,
    :rtsp_cseq_recv =>         info_types[:long]   + 39,
    :primary_port =>           info_types[:long]   + 40,
    :local_ip =>               info_types[:string] + 41,
    :local_port =>             info_types[:long]   + 42,
    :last =>42
  }
end

#long_ptr::FFI::Pointer

Return a long pointer.

Examples:

Return a long pointer.

Curl.long_ptr

Returns:

  • (::FFI::Pointer)

    The long pointer.



158
159
160
# File 'lib/ethon/curls/infos.rb', line 158

def long_ptr
  @long_ptr ||= ::FFI::MemoryPointer.new(:long)
end

#string_ptr::FFI::Pointer

Return a string pointer.

Examples:

Return a string pointer.

Curl.string_ptr

Returns:

  • (::FFI::Pointer)

    The string pointer.



148
149
150
# File 'lib/ethon/curls/infos.rb', line 148

def string_ptr
  @string_ptr ||= ::FFI::MemoryPointer.new(:pointer)
end