scnr-ethon 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +379 -0
- data/LICENSE +20 -0
- data/README.md +118 -0
- data/ethon.gemspec +29 -0
- data/lib/ethon/curl.rb +90 -0
- data/lib/ethon/curls/classes.rb +65 -0
- data/lib/ethon/curls/codes.rb +122 -0
- data/lib/ethon/curls/constants.rb +80 -0
- data/lib/ethon/curls/form_options.rb +37 -0
- data/lib/ethon/curls/functions.rb +58 -0
- data/lib/ethon/curls/infos.rb +151 -0
- data/lib/ethon/curls/messages.rb +19 -0
- data/lib/ethon/curls/options.rb +503 -0
- data/lib/ethon/curls/settings.rb +12 -0
- data/lib/ethon/easy/callbacks.rb +149 -0
- data/lib/ethon/easy/debug_info.rb +47 -0
- data/lib/ethon/easy/features.rb +31 -0
- data/lib/ethon/easy/form.rb +107 -0
- data/lib/ethon/easy/header.rb +61 -0
- data/lib/ethon/easy/http/actionable.rb +157 -0
- data/lib/ethon/easy/http/custom.rb +29 -0
- data/lib/ethon/easy/http/delete.rb +25 -0
- data/lib/ethon/easy/http/get.rb +24 -0
- data/lib/ethon/easy/http/head.rb +24 -0
- data/lib/ethon/easy/http/options.rb +24 -0
- data/lib/ethon/easy/http/patch.rb +24 -0
- data/lib/ethon/easy/http/post.rb +26 -0
- data/lib/ethon/easy/http/postable.rb +32 -0
- data/lib/ethon/easy/http/put.rb +27 -0
- data/lib/ethon/easy/http/putable.rb +25 -0
- data/lib/ethon/easy/http.rb +68 -0
- data/lib/ethon/easy/informations.rb +116 -0
- data/lib/ethon/easy/mirror.rb +36 -0
- data/lib/ethon/easy/operations.rb +65 -0
- data/lib/ethon/easy/options.rb +50 -0
- data/lib/ethon/easy/params.rb +29 -0
- data/lib/ethon/easy/queryable.rb +154 -0
- data/lib/ethon/easy/response_callbacks.rb +136 -0
- data/lib/ethon/easy/util.rb +28 -0
- data/lib/ethon/easy.rb +315 -0
- data/lib/ethon/errors/ethon_error.rb +9 -0
- data/lib/ethon/errors/global_init.rb +13 -0
- data/lib/ethon/errors/invalid_option.rb +13 -0
- data/lib/ethon/errors/invalid_value.rb +13 -0
- data/lib/ethon/errors/multi_add.rb +12 -0
- data/lib/ethon/errors/multi_fdset.rb +12 -0
- data/lib/ethon/errors/multi_remove.rb +12 -0
- data/lib/ethon/errors/multi_timeout.rb +13 -0
- data/lib/ethon/errors/select.rb +13 -0
- data/lib/ethon/errors.rb +17 -0
- data/lib/ethon/libc.rb +21 -0
- data/lib/ethon/loggable.rb +59 -0
- data/lib/ethon/multi/operations.rb +228 -0
- data/lib/ethon/multi/options.rb +117 -0
- data/lib/ethon/multi/stack.rb +49 -0
- data/lib/ethon/multi.rb +126 -0
- data/lib/ethon/version.rb +6 -0
- data/lib/ethon.rb +36 -0
- metadata +117 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Ethon
|
3
|
+
module Curl
|
4
|
+
# :nodoc:
|
5
|
+
class MsgData < ::FFI::Union
|
6
|
+
layout :whatever, :pointer, :code, :easy_code
|
7
|
+
end
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
class Msg < ::FFI::Struct
|
11
|
+
layout :code, :msg_code, :easy_handle, :pointer, :data, MsgData
|
12
|
+
end
|
13
|
+
|
14
|
+
class VersionInfoData < ::FFI::Struct
|
15
|
+
layout :curl_version, :uint8,
|
16
|
+
:version, :string,
|
17
|
+
:version_num, :int,
|
18
|
+
:host, :string,
|
19
|
+
:features, :int,
|
20
|
+
:ssl_version, :string,
|
21
|
+
:ssl_version_num, :long,
|
22
|
+
:libz_version, :string,
|
23
|
+
:protocols, :pointer
|
24
|
+
end
|
25
|
+
|
26
|
+
# :nodoc:
|
27
|
+
class FDSet < ::FFI::Struct
|
28
|
+
if Curl.windows?
|
29
|
+
layout :fd_count, :uint,
|
30
|
+
# TODO: Make it future proof by dynamically grabbing FD_SETSIZE.
|
31
|
+
:fd_array, [:uint, 2048]
|
32
|
+
|
33
|
+
def clear; self[:fd_count] = 0; end
|
34
|
+
else
|
35
|
+
# https://github.com/typhoeus/ethon/issues/182
|
36
|
+
FD_SETSIZE = begin
|
37
|
+
# Allow to override the (new) default cap
|
38
|
+
if ENV['ETHON_FD_SIZE']
|
39
|
+
ENV['ETHON_FD_SIZE']
|
40
|
+
|
41
|
+
# auto-detect ulimit, but cap at 2^16
|
42
|
+
else
|
43
|
+
[::Ethon::Libc.getdtablesize, 65_536].min
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
layout :fds_bits, [:long, FD_SETSIZE / ::FFI::Type::LONG.size]
|
48
|
+
|
49
|
+
# :nodoc:
|
50
|
+
def clear; super; end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# :nodoc:
|
55
|
+
class Timeval < ::FFI::Struct
|
56
|
+
if Curl.windows?
|
57
|
+
layout :sec, :long,
|
58
|
+
:usec, :long
|
59
|
+
else
|
60
|
+
layout :sec, :time_t,
|
61
|
+
:usec, :suseconds_t
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Ethon
|
3
|
+
module Curls # :nodoc:
|
4
|
+
|
5
|
+
# This module contains all easy and
|
6
|
+
# multi return codes.
|
7
|
+
module Codes
|
8
|
+
|
9
|
+
# Libcurl error codes, refer
|
10
|
+
# https://github.com/bagder/curl/blob/master/include/curl/curl.h for details
|
11
|
+
def easy_codes
|
12
|
+
[
|
13
|
+
:ok,
|
14
|
+
:unsupported_protocol,
|
15
|
+
:failed_init,
|
16
|
+
:url_malformat,
|
17
|
+
:not_built_in,
|
18
|
+
:couldnt_resolve_proxy,
|
19
|
+
:couldnt_resolve_host,
|
20
|
+
:couldnt_connect,
|
21
|
+
:ftp_weird_server_reply,
|
22
|
+
:remote_access_denied,
|
23
|
+
:ftp_accept_failed,
|
24
|
+
:ftp_weird_pass_reply,
|
25
|
+
:ftp_accept_timeout,
|
26
|
+
:ftp_weird_pasv_reply,
|
27
|
+
:ftp_weird_227_format,
|
28
|
+
:ftp_cant_get_host,
|
29
|
+
:obsolete16,
|
30
|
+
:ftp_couldnt_set_type,
|
31
|
+
:partial_file,
|
32
|
+
:ftp_couldnt_retr_file,
|
33
|
+
:obsolete20,
|
34
|
+
:quote_error,
|
35
|
+
:http_returned_error,
|
36
|
+
:write_error,
|
37
|
+
:obsolete24,
|
38
|
+
:upload_failed,
|
39
|
+
:read_error,
|
40
|
+
:out_of_memory,
|
41
|
+
:operation_timedout,
|
42
|
+
:obsolete29,
|
43
|
+
:ftp_port_failed,
|
44
|
+
:ftp_couldnt_use_rest,
|
45
|
+
:obsolete32,
|
46
|
+
:range_error,
|
47
|
+
:http_post_error,
|
48
|
+
:ssl_connect_error,
|
49
|
+
:bad_download_resume,
|
50
|
+
:file_couldnt_read_file,
|
51
|
+
:ldap_cannot_bind,
|
52
|
+
:ldap_search_failed,
|
53
|
+
:obsolete40,
|
54
|
+
:function_not_found,
|
55
|
+
:aborted_by_callback,
|
56
|
+
:bad_function_argument,
|
57
|
+
:obsolete44,
|
58
|
+
:interface_failed,
|
59
|
+
:obsolete46,
|
60
|
+
:too_many_redirects ,
|
61
|
+
:unknown_option,
|
62
|
+
:telnet_option_syntax ,
|
63
|
+
:obsolete50,
|
64
|
+
:peer_failed_verification,
|
65
|
+
:got_nothing,
|
66
|
+
:ssl_engine_notfound,
|
67
|
+
:ssl_engine_setfailed,
|
68
|
+
:send_error,
|
69
|
+
:recv_error,
|
70
|
+
:obsolete57,
|
71
|
+
:ssl_certproblem,
|
72
|
+
:ssl_cipher,
|
73
|
+
:bad_content_encoding,
|
74
|
+
:ldap_invalid_url,
|
75
|
+
:filesize_exceeded,
|
76
|
+
:use_ssl_failed,
|
77
|
+
:send_fail_rewind,
|
78
|
+
:ssl_engine_initfailed,
|
79
|
+
:login_denied,
|
80
|
+
:tftp_notfound,
|
81
|
+
:tftp_perm,
|
82
|
+
:remote_disk_full,
|
83
|
+
:tftp_illegal,
|
84
|
+
:tftp_unknownid,
|
85
|
+
:remote_file_exists,
|
86
|
+
:tftp_nosuchuser,
|
87
|
+
:conv_failed,
|
88
|
+
:conv_reqd,
|
89
|
+
:ssl_cacert_badfile,
|
90
|
+
:remote_file_not_found,
|
91
|
+
:ssh,
|
92
|
+
:ssl_shutdown_failed,
|
93
|
+
:again,
|
94
|
+
:ssl_crl_badfile,
|
95
|
+
:ssl_issuer_error,
|
96
|
+
:ftp_pret_failed,
|
97
|
+
:rtsp_cseq_error,
|
98
|
+
:rtsp_session_error,
|
99
|
+
:ftp_bad_file_list,
|
100
|
+
:chunk_failed,
|
101
|
+
:last
|
102
|
+
]
|
103
|
+
end
|
104
|
+
|
105
|
+
# Curl-Multi socket error codes, refer
|
106
|
+
# https://github.com/bagder/curl/blob/master/include/curl/multi.h for details
|
107
|
+
def multi_codes
|
108
|
+
[
|
109
|
+
:call_multi_perform, -1,
|
110
|
+
:ok,
|
111
|
+
:bad_handle,
|
112
|
+
:bad_easy_handle,
|
113
|
+
:out_of_memory,
|
114
|
+
:internal_error,
|
115
|
+
:bad_socket,
|
116
|
+
:unknown_option,
|
117
|
+
:last
|
118
|
+
]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Ethon
|
3
|
+
module Curl
|
4
|
+
# :nodoc:
|
5
|
+
VERSION_NOW = 3
|
6
|
+
|
7
|
+
# Flag. Initialize SSL.
|
8
|
+
GLOBAL_SSL = 0x01
|
9
|
+
# Flag. Initialize win32 socket libraries.
|
10
|
+
GLOBAL_WIN32 = 0x02
|
11
|
+
# Flag. Initialize everything possible.
|
12
|
+
GLOBAL_ALL = (GLOBAL_SSL | GLOBAL_WIN32)
|
13
|
+
# Flag. Initialize everything by default.
|
14
|
+
GLOBAL_DEFAULT = GLOBAL_ALL
|
15
|
+
|
16
|
+
# :nodoc:
|
17
|
+
EasyCode = enum(:easy_code, easy_codes)
|
18
|
+
# :nodoc:
|
19
|
+
MultiCode = enum(:multi_code, multi_codes)
|
20
|
+
|
21
|
+
# :nodoc:
|
22
|
+
EasyOption = enum(:easy_option, easy_options(:enum).to_a.flatten)
|
23
|
+
# :nodoc:
|
24
|
+
MultiOption = enum(:multi_option, multi_options(:enum).to_a.flatten)
|
25
|
+
|
26
|
+
# Used by curl_debug_callback when setting CURLOPT_DEBUGFUNCTION
|
27
|
+
# https://github.com/bagder/curl/blob/master/include/curl/curl.h#L378 for details
|
28
|
+
DebugInfoType = enum(:debug_info_type, debug_info_types)
|
29
|
+
|
30
|
+
# :nodoc:
|
31
|
+
InfoType = enum(info_types.to_a.flatten)
|
32
|
+
|
33
|
+
# Info details, refer
|
34
|
+
# https://github.com/bagder/curl/blob/master/src/tool_writeout.c#L66 for details
|
35
|
+
Info = enum(:info, infos.to_a.flatten)
|
36
|
+
|
37
|
+
# Form options, used by FormAdd for temporary storage, refer
|
38
|
+
# https://github.com/bagder/curl/blob/master/lib/formdata.h#L51 for details
|
39
|
+
FormOption = enum(:form_option, form_options)
|
40
|
+
|
41
|
+
# :nodoc:
|
42
|
+
MsgCode = enum(:msg_code, msg_codes)
|
43
|
+
|
44
|
+
VERSION_IPV6 = (1<<0) # IPv6-enabled
|
45
|
+
VERSION_KERBEROS4 = (1<<1) # kerberos auth is supported
|
46
|
+
VERSION_SSL = (1<<2) # SSL options are present
|
47
|
+
VERSION_LIBZ = (1<<3) # libz features are present
|
48
|
+
VERSION_NTLM = (1<<4) # NTLM auth is supported
|
49
|
+
VERSION_GSSNEGOTIATE = (1<<5) # Negotiate auth supp
|
50
|
+
VERSION_DEBUG = (1<<6) # built with debug capabilities
|
51
|
+
VERSION_ASYNCHDNS = (1<<7) # asynchronous dns resolves
|
52
|
+
VERSION_SPNEGO = (1<<8) # SPNEGO auth is supported
|
53
|
+
VERSION_LARGEFILE = (1<<9) # supports files bigger than 2GB
|
54
|
+
VERSION_IDN = (1<<10) # International Domain Names support
|
55
|
+
VERSION_SSPI = (1<<11) # SSPI is supported
|
56
|
+
VERSION_CONV = (1<<12) # character conversions supported
|
57
|
+
VERSION_CURLDEBUG = (1<<13) # debug memory tracking supported
|
58
|
+
VERSION_TLSAUTH_SRP = (1<<14) # TLS-SRP auth is supported
|
59
|
+
VERSION_NTLM_WB = (1<<15) # NTLM delegating to winbind helper
|
60
|
+
VERSION_HTTP2 = (1<<16) # HTTP2 support built
|
61
|
+
VERSION_GSSAPI = (1<<17) # GSS-API is supported
|
62
|
+
|
63
|
+
SOCKET_BAD = -1
|
64
|
+
SOCKET_TIMEOUT = SOCKET_BAD
|
65
|
+
|
66
|
+
PollAction = enum(:poll_action, [
|
67
|
+
:none,
|
68
|
+
:in,
|
69
|
+
:out,
|
70
|
+
:inout,
|
71
|
+
:remove
|
72
|
+
])
|
73
|
+
|
74
|
+
SocketReadiness = bitmask(:socket_readiness, [
|
75
|
+
:in, # CURL_CSELECT_IN - 0x01 (bit 0)
|
76
|
+
:out, # CURL_CSELECT_OUT - 0x02 (bit 1)
|
77
|
+
:err, # CURL_CSELECT_ERR - 0x04 (bit 2)
|
78
|
+
])
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Ethon
|
3
|
+
module Curls
|
4
|
+
|
5
|
+
# This module contains the available options for forms.
|
6
|
+
module FormOptions
|
7
|
+
|
8
|
+
# Form options, used by FormAdd for temporary storage, refer
|
9
|
+
# https://github.com/bagder/curl/blob/master/lib/formdata.h#L51 for details
|
10
|
+
def form_options
|
11
|
+
[
|
12
|
+
:none,
|
13
|
+
:copyname,
|
14
|
+
:ptrname,
|
15
|
+
:namelength,
|
16
|
+
:copycontents,
|
17
|
+
:ptrcontents,
|
18
|
+
:contentslength,
|
19
|
+
:filecontent,
|
20
|
+
:array,
|
21
|
+
:obsolete,
|
22
|
+
:file,
|
23
|
+
:buffer,
|
24
|
+
:bufferptr,
|
25
|
+
:bufferlength,
|
26
|
+
:contenttype,
|
27
|
+
:contentheader,
|
28
|
+
:filename,
|
29
|
+
:end,
|
30
|
+
:obsolete2,
|
31
|
+
:stream,
|
32
|
+
:last
|
33
|
+
]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Ethon
|
3
|
+
module Curls
|
4
|
+
|
5
|
+
# This module contains the functions to be attached in order to work with
|
6
|
+
# libcurl.
|
7
|
+
module Functions
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
def self.extended(base)
|
11
|
+
base.attach_function :global_init, :curl_global_init, [:long], :int
|
12
|
+
base.attach_function :global_cleanup, :curl_global_cleanup, [], :void
|
13
|
+
base.attach_function :free, :curl_free, [:pointer], :void
|
14
|
+
|
15
|
+
base.attach_function :easy_init, :curl_easy_init, [], :pointer
|
16
|
+
base.attach_function :easy_cleanup, :curl_easy_cleanup, [:pointer], :void
|
17
|
+
base.attach_function :easy_getinfo, :curl_easy_getinfo, [:pointer, :info, :varargs], :easy_code
|
18
|
+
base.attach_function :easy_setopt, :curl_easy_setopt, [:pointer, :easy_option, :varargs], :easy_code
|
19
|
+
base.instance_variable_set(:@blocking, true)
|
20
|
+
base.attach_function :easy_perform, :curl_easy_perform, [:pointer], :easy_code
|
21
|
+
base.attach_function :easy_strerror, :curl_easy_strerror, [:easy_code], :string
|
22
|
+
base.attach_function :easy_escape, :curl_easy_escape, [:pointer, :pointer, :int], :pointer
|
23
|
+
base.attach_function :easy_reset, :curl_easy_reset, [:pointer], :void
|
24
|
+
base.attach_function :easy_duphandle, :curl_easy_duphandle, [:pointer], :pointer
|
25
|
+
|
26
|
+
base.attach_function :formadd, :curl_formadd, [:pointer, :pointer, :varargs], :int
|
27
|
+
base.attach_function :formfree, :curl_formfree, [:pointer], :void
|
28
|
+
|
29
|
+
base.attach_function :multi_init, :curl_multi_init, [], :pointer
|
30
|
+
base.attach_function :multi_cleanup, :curl_multi_cleanup, [:pointer], :void
|
31
|
+
base.attach_function :multi_add_handle, :curl_multi_add_handle, [:pointer, :pointer], :multi_code
|
32
|
+
base.attach_function :multi_remove_handle, :curl_multi_remove_handle, [:pointer, :pointer], :multi_code
|
33
|
+
base.attach_function :multi_info_read, :curl_multi_info_read, [:pointer, :pointer], Curl::Msg.ptr
|
34
|
+
base.attach_function :multi_perform, :curl_multi_perform, [:pointer, :pointer], :multi_code
|
35
|
+
base.attach_function :multi_timeout, :curl_multi_timeout, [:pointer, :pointer], :multi_code
|
36
|
+
base.attach_function :multi_fdset, :curl_multi_fdset, [:pointer, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::FDSet.ptr, :pointer], :multi_code
|
37
|
+
base.attach_function :multi_strerror, :curl_multi_strerror, [:int], :string
|
38
|
+
base.attach_function :multi_setopt, :curl_multi_setopt, [:pointer, :multi_option, :varargs], :multi_code
|
39
|
+
base.attach_function :multi_socket_action, :curl_multi_socket_action, [:pointer, :int, :socket_readiness, :pointer], :multi_code
|
40
|
+
|
41
|
+
base.attach_function :version, :curl_version, [], :string
|
42
|
+
base.attach_function :version_info, :curl_version_info, [], Curl::VersionInfoData.ptr
|
43
|
+
|
44
|
+
base.attach_function :slist_append, :curl_slist_append, [:pointer, :string], :pointer
|
45
|
+
base.attach_function :slist_free_all, :curl_slist_free_all, [:pointer], :void
|
46
|
+
base.instance_variable_set(:@blocking, true)
|
47
|
+
|
48
|
+
if Curl.windows?
|
49
|
+
base.ffi_lib 'ws2_32'
|
50
|
+
else
|
51
|
+
base.ffi_lib ::FFI::Library::LIBC
|
52
|
+
end
|
53
|
+
|
54
|
+
base.attach_function :select, [:int, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::Timeval.ptr], :int
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Ethon
|
3
|
+
module Curls
|
4
|
+
|
5
|
+
# This module contains logic for the available informations
|
6
|
+
# on an easy, eg.: connect_time.
|
7
|
+
module Infos
|
8
|
+
|
9
|
+
# Return info types.
|
10
|
+
#
|
11
|
+
# @example Return info types.
|
12
|
+
# Ethon::Curl.info_types
|
13
|
+
#
|
14
|
+
# @return [ Hash ] The info types.
|
15
|
+
def info_types
|
16
|
+
{
|
17
|
+
:string =>0x100000,
|
18
|
+
:long => 0x200000,
|
19
|
+
:double =>0x300000,
|
20
|
+
:slist => 0x400000
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTDEBUGFUNCTION
|
25
|
+
# https://github.com/bagder/curl/blob/master/include/curl/curl.h#L378
|
26
|
+
#
|
27
|
+
# @example Return debug info types.
|
28
|
+
# Ethon::Curl.debug_info_types
|
29
|
+
#
|
30
|
+
# @return [ Hash ] The info types available to curl_debug_callback.
|
31
|
+
def debug_info_types
|
32
|
+
[
|
33
|
+
:text, 0,
|
34
|
+
:header_in,
|
35
|
+
:header_out,
|
36
|
+
:data_in,
|
37
|
+
:data_out,
|
38
|
+
:ssl_data_in,
|
39
|
+
:ssl_data_out
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
# Return Info details, refer
|
44
|
+
# https://github.com/bagder/curl/blob/master/src/tool_writeout.c#L66 for details
|
45
|
+
#
|
46
|
+
# @example Return infos.
|
47
|
+
# Ethon::Curl.infos
|
48
|
+
#
|
49
|
+
# @return [ Hash ] The infos.
|
50
|
+
def infos
|
51
|
+
{
|
52
|
+
:effective_url => info_types[:string] + 1,
|
53
|
+
:response_code => info_types[:long] + 2,
|
54
|
+
:total_time => info_types[:double] + 3,
|
55
|
+
:namelookup_time => info_types[:double] + 4,
|
56
|
+
:connect_time => info_types[:double] + 5,
|
57
|
+
:pretransfer_time => info_types[:double] + 6,
|
58
|
+
:size_upload => info_types[:double] + 7,
|
59
|
+
:size_download => info_types[:double] + 8,
|
60
|
+
:speed_download => info_types[:double] + 9,
|
61
|
+
:speed_upload => info_types[:double] + 10,
|
62
|
+
:header_size => info_types[:long] + 11,
|
63
|
+
:request_size => info_types[:long] + 12,
|
64
|
+
:ssl_verifyresult => info_types[:long] + 13,
|
65
|
+
:filetime => info_types[:long] + 14,
|
66
|
+
:content_length_download =>info_types[:double] + 15,
|
67
|
+
:content_length_upload => info_types[:double] + 16,
|
68
|
+
:starttransfer_time => info_types[:double] + 17,
|
69
|
+
:content_type => info_types[:string] + 18,
|
70
|
+
:redirect_time => info_types[:double] + 19,
|
71
|
+
:redirect_count => info_types[:long] + 20,
|
72
|
+
:private => info_types[:string] + 21,
|
73
|
+
:http_connectcode => info_types[:long] + 22,
|
74
|
+
:httpauth_avail => info_types[:long] + 23,
|
75
|
+
:proxyauth_avail => info_types[:long] + 24,
|
76
|
+
:os_errno => info_types[:long] + 25,
|
77
|
+
:num_connects => info_types[:long] + 26,
|
78
|
+
:ssl_engines => info_types[:slist] + 27,
|
79
|
+
:cookielist => info_types[:slist] + 28,
|
80
|
+
:lastsocket => info_types[:long] + 29,
|
81
|
+
:ftp_entry_path => info_types[:string] + 30,
|
82
|
+
:redirect_url => info_types[:string] + 31,
|
83
|
+
:primary_ip => info_types[:string] + 32,
|
84
|
+
:appconnect_time => info_types[:double] + 33,
|
85
|
+
:certinfo => info_types[:slist] + 34,
|
86
|
+
:condition_unmet => info_types[:long] + 35,
|
87
|
+
:rtsp_session_id => info_types[:string] + 36,
|
88
|
+
:rtsp_client_cseq => info_types[:long] + 37,
|
89
|
+
:rtsp_server_cseq => info_types[:long] + 38,
|
90
|
+
:rtsp_cseq_recv => info_types[:long] + 39,
|
91
|
+
:primary_port => info_types[:long] + 40,
|
92
|
+
:local_ip => info_types[:string] + 41,
|
93
|
+
:local_port => info_types[:long] + 42,
|
94
|
+
:last =>42
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
# Return info as string.
|
99
|
+
#
|
100
|
+
# @example Return info.
|
101
|
+
# Curl.get_info_string(:primary_ip, easy)
|
102
|
+
#
|
103
|
+
# @param [ Symbol ] option The option name.
|
104
|
+
# @param [ ::FFI::Pointer ] handle The easy handle.
|
105
|
+
#
|
106
|
+
# @return [ String ] The info.
|
107
|
+
def get_info_string(option, handle)
|
108
|
+
string_ptr = ::FFI::MemoryPointer.new(:pointer)
|
109
|
+
|
110
|
+
if easy_getinfo(handle, option, :pointer, string_ptr) == :ok
|
111
|
+
ptr=string_ptr.read_pointer
|
112
|
+
ptr.null? ? nil : ptr.read_string
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Return info as integer.
|
117
|
+
#
|
118
|
+
# @example Return info.
|
119
|
+
# Curl.get_info_long(:response_code, easy)
|
120
|
+
#
|
121
|
+
# @param [ Symbol ] option The option name.
|
122
|
+
# @param [ ::FFI::Pointer ] handle The easy handle.
|
123
|
+
#
|
124
|
+
# @return [ Integer ] The info.
|
125
|
+
def get_info_long(option, handle)
|
126
|
+
long_ptr = ::FFI::MemoryPointer.new(:long)
|
127
|
+
|
128
|
+
if easy_getinfo(handle, option, :pointer, long_ptr) == :ok
|
129
|
+
long_ptr.read_long
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Return info as float
|
134
|
+
#
|
135
|
+
# @example Return info.
|
136
|
+
# Curl.get_info_double(:response_code, easy)
|
137
|
+
#
|
138
|
+
# @param [ Symbol ] option The option name.
|
139
|
+
# @param [ ::FFI::Pointer ] handle The easy handle.
|
140
|
+
#
|
141
|
+
# @return [ Float ] The info.
|
142
|
+
def get_info_double(option, handle)
|
143
|
+
double_ptr = ::FFI::MemoryPointer.new(:double)
|
144
|
+
|
145
|
+
if easy_getinfo(handle, option, :pointer, double_ptr) == :ok
|
146
|
+
double_ptr.read_double
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Ethon
|
3
|
+
module Curls
|
4
|
+
|
5
|
+
# This module contains available message codes.
|
6
|
+
module Messages
|
7
|
+
|
8
|
+
# Return message codes.
|
9
|
+
#
|
10
|
+
# @example Return message codes.
|
11
|
+
# Ethon::Curl.msg_codes
|
12
|
+
#
|
13
|
+
# @return [ Array ] The messages codes.
|
14
|
+
def msg_codes
|
15
|
+
[:none, :done, :last]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|