ethon 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ module Ethon
2
+ module Curls # :nodoc:
3
+
4
+ # This module contains all easy and
5
+ # multi return codes.
6
+ module Codes
7
+
8
+ # Libcurl error codes, refer
9
+ # https://github.com/bagder/curl/blob/master/include/curl/curl.h for details
10
+ def easy_codes
11
+ [
12
+ :ok,
13
+ :unsupported_protocol,
14
+ :failed_init,
15
+ :url_malformat,
16
+ :not_built_in,
17
+ :couldnt_resolve_proxy,
18
+ :couldnt_resolve_host,
19
+ :couldnt_connect,
20
+ :ftp_weird_server_reply,
21
+ :remote_access_denied,
22
+ :ftp_accept_failed,
23
+ :ftp_weird_pass_reply,
24
+ :ftp_accept_timeout,
25
+ :ftp_weird_pasv_reply,
26
+ :ftp_weird_227_format,
27
+ :ftp_cant_get_host,
28
+ :obsolete16,
29
+ :ftp_couldnt_set_type,
30
+ :partial_file,
31
+ :ftp_couldnt_retr_file,
32
+ :obsolete20,
33
+ :quote_error,
34
+ :http_returned_error,
35
+ :write_error,
36
+ :obsolete24,
37
+ :upload_failed,
38
+ :read_error,
39
+ :out_of_memory,
40
+ :operation_timedout,
41
+ :obsolete29,
42
+ :ftp_port_failed,
43
+ :ftp_couldnt_use_rest,
44
+ :obsolete32,
45
+ :range_error,
46
+ :http_post_error,
47
+ :ssl_connect_error,
48
+ :bad_download_resume,
49
+ :file_couldnt_read_file,
50
+ :ldap_cannot_bind,
51
+ :ldap_search_failed,
52
+ :obsolete40,
53
+ :function_not_found,
54
+ :aborted_by_callback,
55
+ :bad_function_argument,
56
+ :obsolete44,
57
+ :interface_failed,
58
+ :obsolete46,
59
+ :too_many_redirects ,
60
+ :unknown_option,
61
+ :telnet_option_syntax ,
62
+ :obsolete50,
63
+ :peer_failed_verification,
64
+ :got_nothing,
65
+ :ssl_engine_notfound,
66
+ :ssl_engine_setfailed,
67
+ :send_error,
68
+ :recv_error,
69
+ :obsolete57,
70
+ :ssl_certproblem,
71
+ :ssl_cipher,
72
+ :ssl_cacert,
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,48 @@
1
+ module Ethon
2
+ module Curl
3
+ # :nodoc:
4
+ VERSION_NOW = 3
5
+
6
+ # Flag. Initialize SSL.
7
+ GLOBAL_SSL = 0x01
8
+ # Flag. Initialize win32 socket libraries.
9
+ GLOBAL_WIN32 = 0x02
10
+ # Flag. Initialize everything possible.
11
+ GLOBAL_ALL = (GLOBAL_SSL | GLOBAL_WIN32)
12
+ # Flag. Initialize everything by default.
13
+ GLOBAL_DEFAULT = GLOBAL_ALL
14
+
15
+ # :nodoc:
16
+ EasyCode = enum(:easy_code, easy_codes)
17
+ # :nodoc:
18
+ MultiCode = enum(:multi_code, multi_codes)
19
+
20
+ # :nodoc:
21
+ Option = enum(:option, options.to_a.flatten)
22
+ # :nodoc:
23
+ OptionType = enum(option_types.to_a.flatten)
24
+
25
+ # :nodoc:
26
+ InfoType = enum(info_types.to_a.flatten)
27
+
28
+ # Info details, refer
29
+ # https://github.com/bagder/curl/blob/master/src/tool_writeout.c#L66 for details
30
+ Info = enum(:info, infos.to_a.flatten)
31
+
32
+ # Form options, used by FormAdd for temporary storage, refer
33
+ # https://github.com/bagder/curl/blob/master/lib/formdata.h#L51 for details
34
+ FormOption = enum(:form_option, form_options)
35
+
36
+ # :nodoc:
37
+ Auth = enum(auth_types.to_a.flatten)
38
+
39
+ # :nodoc:
40
+ Proxy = enum(proxy_types.to_a.flatten)
41
+
42
+ # :nodoc:
43
+ SSLVersion = enum(ssl_versions.to_a.flatten)
44
+
45
+ # :nodoc:
46
+ MsgCode = enum(:msg_code, msg_codes)
47
+ end
48
+ end
@@ -0,0 +1,36 @@
1
+ module Ethon
2
+ module Curls
3
+
4
+ # This module contains the available options for forms.
5
+ module FormOptions
6
+
7
+ # Form options, used by FormAdd for temporary storage, refer
8
+ # https://github.com/bagder/curl/blob/master/lib/formdata.h#L51 for details
9
+ def form_options
10
+ [
11
+ :none,
12
+ :copyname,
13
+ :ptrname,
14
+ :namelength,
15
+ :copycontents,
16
+ :ptrcontents,
17
+ :contentslength,
18
+ :filecontent,
19
+ :array,
20
+ :obsolete,
21
+ :file,
22
+ :buffer,
23
+ :bufferptr,
24
+ :bufferlength,
25
+ :contenttype,
26
+ :contentheader,
27
+ :filename,
28
+ :end,
29
+ :obsolete2,
30
+ :stream,
31
+ :last
32
+ ]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,46 @@
1
+ module Ethon
2
+ module Curls
3
+
4
+ # This module contains the functions to be attached in order to work with
5
+ # libcurl.
6
+ module Functions
7
+
8
+ # :nodoc:
9
+ def self.extended(base)
10
+ base.attach_function :global_init, :curl_global_init, [:long], :int
11
+
12
+ base.attach_function :easy_init, :curl_easy_init, [], :pointer
13
+ base.attach_function :easy_cleanup, :curl_easy_cleanup, [:pointer], :void
14
+ base.attach_function :easy_getinfo, :curl_easy_getinfo, [:pointer, :info, :pointer], :easy_code
15
+ base.attach_function :easy_setopt, :curl_easy_setopt, [:pointer, :option, :pointer], :easy_code
16
+ base.attach_function :easy_setopt_ffipointer, :curl_easy_setopt, [:pointer, :option, :pointer], :easy_code
17
+ base.attach_function :easy_setopt_string, :curl_easy_setopt, [:pointer, :option, :string], :easy_code
18
+ base.attach_function :easy_setopt_long, :curl_easy_setopt, [:pointer, :option, :long], :easy_code
19
+ base.attach_function :easy_setopt_fixnum, :curl_easy_setopt, [:pointer, :option, :long], :easy_code
20
+ base.attach_function :easy_setopt_callback, :curl_easy_setopt, [:pointer, :option, :callback], :easy_code
21
+ base.attach_function :easy_setopt_proc, :curl_easy_setopt, [:pointer, :option, :callback], :easy_code
22
+ base.attach_function :easy_perform, :curl_easy_perform, [:pointer], :easy_code
23
+ base.attach_function :easy_strerror, :curl_easy_strerror, [:int], :string
24
+ base.attach_function :easy_escape, :curl_easy_escape, [:pointer, :pointer, :int], :string
25
+ base.attach_function :easy_reset, :curl_easy_reset, [:pointer], :void
26
+
27
+ base.attach_function :formadd, :curl_formadd, [:pointer, :pointer, :varargs], :int
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
+
39
+ base.attach_function :version, :curl_version, [], :string
40
+ base.attach_function :slist_append, :curl_slist_append, [:pointer, :string], :pointer
41
+ base.attach_function :slist_free_all, :curl_slist_free_all, [:pointer], :void
42
+ base.attach_function :select, [:int, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::Timeval.ptr], :int
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,154 @@
1
+ module Ethon
2
+ module Curls
3
+
4
+ # This module contains logic for the available informations
5
+ # on an easy, eg.: connect_time.
6
+ module Infos
7
+
8
+ # Return info types.
9
+ #
10
+ # @example Return info types.
11
+ # Ethon::Curl.info_types
12
+ #
13
+ # @return [ Hash ] The info types.
14
+ def info_types
15
+ {
16
+ :string =>0x100000,
17
+ :long => 0x200000,
18
+ :double =>0x300000,
19
+ :slist => 0x400000
20
+ }
21
+ end
22
+
23
+ # Return Info details, refer
24
+ # https://github.com/bagder/curl/blob/master/src/tool_writeout.c#L66 for details
25
+ #
26
+ # @example Return infos.
27
+ # Ethon::Curl.infos
28
+ #
29
+ # @return [ Hash ] The infos.
30
+ def infos
31
+ {
32
+ :effective_url => info_types[:string] + 1,
33
+ :response_code => info_types[:long] + 2,
34
+ :total_time => info_types[:double] + 3,
35
+ :namelookup_time => info_types[:double] + 4,
36
+ :connect_time => info_types[:double] + 5,
37
+ :pretransfer_time => info_types[:double] + 6,
38
+ :size_upload => info_types[:double] + 7,
39
+ :size_download => info_types[:double] + 8,
40
+ :speed_download => info_types[:double] + 9,
41
+ :speed_upload => info_types[:double] + 10,
42
+ :header_size => info_types[:long] + 11,
43
+ :request_size => info_types[:long] + 12,
44
+ :ssl_verifyresult => info_types[:long] + 13,
45
+ :filetime => info_types[:long] + 14,
46
+ :content_length_download =>info_types[:double] + 15,
47
+ :content_length_upload => info_types[:double] + 16,
48
+ :starttransfer_time => info_types[:double] + 17,
49
+ :content_type => info_types[:string] + 18,
50
+ :redirect_time => info_types[:double] + 19,
51
+ :redirect_count => info_types[:long] + 20,
52
+ :private => info_types[:string] + 21,
53
+ :http_connectcode => info_types[:long] + 22,
54
+ :httpauth_avail => info_types[:long] + 23,
55
+ :proxyauth_avail => info_types[:long] + 24,
56
+ :os_errno => info_types[:long] + 25,
57
+ :num_connects => info_types[:long] + 26,
58
+ :ssl_engines => info_types[:slist] + 27,
59
+ :cookielist => info_types[:slist] + 28,
60
+ :lastsocket => info_types[:long] + 29,
61
+ :ftp_entry_path => info_types[:string] + 30,
62
+ :redirect_url => info_types[:string] + 31,
63
+ :primary_ip => info_types[:string] + 32,
64
+ :appconnect_time => info_types[:double] + 33,
65
+ :certinfo => info_types[:slist] + 34,
66
+ :condition_unmet => info_types[:long] + 35,
67
+ :rtsp_session_id => info_types[:string] + 36,
68
+ :rtsp_client_cseq => info_types[:long] + 37,
69
+ :rtsp_server_cseq => info_types[:long] + 38,
70
+ :rtsp_cseq_recv => info_types[:long] + 39,
71
+ :primary_port => info_types[:long] + 40,
72
+ :local_ip => info_types[:string] + 41,
73
+ :local_port => info_types[:long] + 42,
74
+ :last =>42
75
+ }
76
+ end
77
+
78
+ # Return info as string.
79
+ #
80
+ # @example Return info.
81
+ # Curl.get_info_string(:primary_ip, easy)
82
+ #
83
+ # @param [ Symbol ] option The option name.
84
+ # @param [ ::FFI::Pointer ] handle The easy handle.
85
+ #
86
+ # @return [ String ] The info.
87
+ def get_info_string(option, handle)
88
+ if easy_getinfo(handle, option, string_ptr) == :ok
89
+ string_ptr.read_pointer.read_string
90
+ end
91
+ end
92
+
93
+ # Return info as integer.
94
+ #
95
+ # @example Return info.
96
+ # Curl.get_info_long(:response_code, easy)
97
+ #
98
+ # @param [ Symbol ] option The option name.
99
+ # @param [ ::FFI::Pointer ] handle The easy handle.
100
+ #
101
+ # @return [ Integer ] The info.
102
+ def get_info_long(option, handle)
103
+ if easy_getinfo(handle, option, long_ptr) == :ok
104
+ long_ptr.read_long
105
+ end
106
+ end
107
+
108
+ # Return info as float
109
+ #
110
+ # @example Return info.
111
+ # Curl.get_info_double(:response_code, easy)
112
+ #
113
+ # @param [ Symbol ] option The option name.
114
+ # @param [ ::FFI::Pointer ] handle The easy handle.
115
+ #
116
+ # @return [ Float ] The info.
117
+ def get_info_double(option, handle)
118
+ if easy_getinfo(handle, option, double_ptr) == :ok
119
+ double_ptr.read_double
120
+ end
121
+ end
122
+
123
+ # Return a string pointer.
124
+ #
125
+ # @example Return a string pointer.
126
+ # Curl.string_ptr
127
+ #
128
+ # @return [ ::FFI::Pointer ] The string pointer.
129
+ def string_ptr
130
+ @string_ptr ||= ::FFI::MemoryPointer.new(:pointer)
131
+ end
132
+
133
+ # Return a long pointer.
134
+ #
135
+ # @example Return a long pointer.
136
+ # Curl.long_ptr
137
+ #
138
+ # @return [ ::FFI::Pointer ] The long pointer.
139
+ def long_ptr
140
+ @long_ptr ||= ::FFI::MemoryPointer.new(:long)
141
+ end
142
+
143
+ # Return a double pointer.
144
+ #
145
+ # @example Return a double pointer.
146
+ # Curl.double_ptr
147
+ #
148
+ # @return [ ::FFI::Pointer ] The double pointer.
149
+ def double_ptr
150
+ @double_ptr ||= ::FFI::MemoryPointer.new(:double)
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,18 @@
1
+ module Ethon
2
+ module Curls
3
+
4
+ # This module contains available message codes.
5
+ module Messages
6
+
7
+ # Return message codes.
8
+ #
9
+ # @example Return message codes.
10
+ # Ethon::Curl.msg_codes
11
+ #
12
+ # @return [ Array ] The messages codes.
13
+ def msg_codes
14
+ [:none, :done, :last]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,174 @@
1
+ module Ethon
2
+ module Curls
3
+
4
+ # This module contains logic for setting options on
5
+ # easy or multi interface.
6
+ module Options
7
+
8
+ # Sets appropriate option for easy, depending on value type.
9
+ def set_option(option, value, handle)
10
+ return unless value
11
+
12
+ name = "easy_setopt_#{value.class.to_s.downcase.delete(':')}"
13
+ send(name, handle, option, value)
14
+ end
15
+
16
+ # :nodoc:
17
+ def option_types
18
+ {
19
+ :long => 0,
20
+ :object_point => 10000,
21
+ :function_point => 20000,
22
+ :off_t => 30000
23
+ }
24
+ end
25
+
26
+ # Curl options, refer
27
+ # https://github.com/bagder/curl/blob/master/src/tool_cfgable.h for details
28
+ def options
29
+ {
30
+ :file => option_types[:object_point] + 1,
31
+ :writedata => option_types[:object_point] + 1,
32
+ :url => option_types[:object_point] + 2,
33
+ :port => option_types[:long] + 3,
34
+ :proxy => option_types[:object_point] + 4,
35
+ :userpwd => option_types[:object_point] + 5,
36
+ :proxyuserpwd => option_types[:object_point] + 6,
37
+ :range => option_types[:object_point] + 7,
38
+ :infile => option_types[:object_point] + 9,
39
+ :readdata => option_types[:object_point] + 9,
40
+ :errorbuffer => option_types[:object_point] + 10,
41
+ :writefunction => option_types[:function_point] + 11,
42
+ :readfunction => option_types[:function_point] + 12,
43
+ :timeout => option_types[:long] + 13,
44
+ :infilesize => option_types[:long] + 14,
45
+ :postfields => option_types[:object_point] + 15,
46
+ :referer => option_types[:object_point] + 16,
47
+ :ftpport => option_types[:object_point] + 17,
48
+ :useragent => option_types[:object_point] + 18,
49
+ :low_speed_time => option_types[:long] + 20,
50
+ :resume_from => option_types[:long] + 21,
51
+ :cookie => option_types[:object_point] + 22,
52
+ :httpheader => option_types[:object_point] + 23,
53
+ :httppost => option_types[:object_point] + 24,
54
+ :sslcert => option_types[:object_point] + 25,
55
+ :sslcertpasswd => option_types[:object_point] + 26,
56
+ :sslkeypasswd => option_types[:object_point] + 26,
57
+ :crlf => option_types[:long] + 27,
58
+ :quote => option_types[:object_point] + 28,
59
+ :writeheader => option_types[:object_point] + 29,
60
+ :headerdata => option_types[:object_point] + 29,
61
+ :cookiefile => option_types[:object_point] + 31,
62
+ :sslversion => option_types[:long] + 32,
63
+ :timecondition => option_types[:long] + 33,
64
+ :timevalue => option_types[:long] + 34,
65
+ :customrequest => option_types[:object_point] + 36,
66
+ :stderr => option_types[:object_point] + 37,
67
+ :postquote => option_types[:object_point] + 39,
68
+ :writeinfo => option_types[:object_point] + 40,
69
+ :verbose => option_types[:long] + 41,
70
+ :header => option_types[:long] + 42,
71
+ :noprogress => option_types[:long] + 43,
72
+ :nobody => option_types[:long] + 44,
73
+ :failonerror => option_types[:long] + 45,
74
+ :upload => option_types[:long] + 46,
75
+ :post => option_types[:long] + 47,
76
+ :ftplistonly => option_types[:long] + 48,
77
+ :ftpappend => option_types[:long] + 50,
78
+ :netrc => option_types[:long] + 51,
79
+ :followlocation => option_types[:long] + 52,
80
+ :transfertext => option_types[:long] + 53,
81
+ :put => option_types[:long] + 54,
82
+ :progressfunction => option_types[:function_point] + 56,
83
+ :progressdata => option_types[:object_point] + 57,
84
+ :autoreferer => option_types[:long] + 58,
85
+ :proxyport => option_types[:long] + 59,
86
+ :postfieldsize => option_types[:long] + 60,
87
+ :httpproxytunnel => option_types[:long] + 61,
88
+ :interface => option_types[:object_point] + 62,
89
+ :ssl_verifypeer => option_types[:long] + 64,
90
+ :cainfo => option_types[:object_point] + 65,
91
+ :maxredirs => option_types[:long] + 68,
92
+ :filetime => option_types[:long] + 69,
93
+ :telnetoptions => option_types[:object_point] + 70,
94
+ :maxconnects => option_types[:long] + 71,
95
+ :closepolicy => option_types[:long] + 72,
96
+ :fresh_connect => option_types[:long] + 74,
97
+ :forbid_reuse => option_types[:long] + 75,
98
+ :random_file => option_types[:object_point] + 76,
99
+ :egdsocket => option_types[:object_point] + 77,
100
+ :connecttimeout => option_types[:long] + 78,
101
+ :headerfunction => option_types[:function_point] + 79,
102
+ :httpget => option_types[:long] + 80,
103
+ :ssl_verifyhost => option_types[:long] + 81,
104
+ :cookiejar => option_types[:object_point] + 82,
105
+ :ssl_cipher_list => option_types[:object_point] + 83,
106
+ :http_version => option_types[:long] + 84,
107
+ :ftp_use_epsv => option_types[:long] + 85,
108
+ :sslcerttype => option_types[:object_point] + 86,
109
+ :sslkey => option_types[:object_point] + 87,
110
+ :sslkeytype => option_types[:object_point] + 88,
111
+ :sslengine => option_types[:object_point] + 89,
112
+ :sslengine_default => option_types[:long] + 90,
113
+ :dns_use_global_cache => option_types[:long] + 91,
114
+ :dns_cache_timeout => option_types[:long] + 92,
115
+ :prequote => option_types[:object_point] + 93,
116
+ :debugfunction => option_types[:function_point] + 94,
117
+ :debugdata => option_types[:object_point] + 95,
118
+ :cookiesession => option_types[:long] + 96,
119
+ :capath => option_types[:object_point] + 97,
120
+ :buffersize => option_types[:long] + 98,
121
+ :nosignal => option_types[:long] + 99,
122
+ :share => option_types[:object_point] + 100,
123
+ :proxytype => option_types[:long] + 101,
124
+ :encoding => option_types[:object_point] + 102,
125
+ :private => option_types[:object_point] + 103,
126
+ :unrestricted_auth => option_types[:long] + 105,
127
+ :ftp_use_eprt => option_types[:long] + 106,
128
+ :httpauth => option_types[:long] + 107,
129
+ :ssl_ctx_function => option_types[:function_point] + 108,
130
+ :ssl_ctx_data => option_types[:object_point] + 109,
131
+ :ftp_create_missing_dirs => option_types[:long] + 110,
132
+ :proxyauth => option_types[:long] + 111,
133
+ :ipresolve => option_types[:long] + 113,
134
+ :maxfilesize => option_types[:long] + 114,
135
+ :infilesize_large => option_types[:off_t] + 115,
136
+ :resume_from_large => option_types[:off_t] + 116,
137
+ :maxfilesize_large => option_types[:off_t] + 117,
138
+ :netrc_file => option_types[:object_point] + 118,
139
+ :ftp_ssl => option_types[:long] + 119,
140
+ :postfieldsize_large => option_types[:off_t] + 120,
141
+ :tcp_nodelay => option_types[:long] + 121,
142
+ :ftpsslauth => option_types[:long] + 129,
143
+ :ioctlfunction => option_types[:function_point] + 130,
144
+ :ioctldata => option_types[:object_point] + 131,
145
+ :ftp_account => option_types[:object_point] + 134,
146
+ :cookielist => option_types[:object_point] + 135,
147
+ :ignore_content_length => option_types[:long] + 136,
148
+ :ftp_skip_pasv_ip => option_types[:long] + 137,
149
+ :ftp_filemethod => option_types[:long] + 138,
150
+ :localport => option_types[:long] + 139,
151
+ :localportrange => option_types[:long] + 140,
152
+ :connect_only => option_types[:long] + 141,
153
+ :conv_from_network_function => option_types[:function_point] + 142,
154
+ :conv_to_network_function => option_types[:function_point] + 143,
155
+ :max_send_speed_large => option_types[:off_t] + 145,
156
+ :max_recv_speed_large => option_types[:off_t] + 146,
157
+ :ftp_alternative_to_user => option_types[:object_point] + 147,
158
+ :sockoptfunction => option_types[:function_point] + 148,
159
+ :sockoptdata => option_types[:object_point] + 149,
160
+ :ssl_sessionid_cache => option_types[:long] + 150,
161
+ :ssh_auth_types => option_types[:long] + 151,
162
+ :ssh_public_keyfile => option_types[:object_point] + 152,
163
+ :ssh_private_keyfile => option_types[:object_point] + 153,
164
+ :ftp_ssl_ccc => option_types[:long] + 154,
165
+ :timeout_ms => option_types[:long] + 155,
166
+ :connecttimeout_ms => option_types[:long] + 156,
167
+ :http_transfer_decoding => option_types[:long] + 157,
168
+ :http_content_decoding => option_types[:long] + 158,
169
+ :copypostfields => option_types[:object_point] + 165
170
+ }
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,25 @@
1
+ module Ethon
2
+ module Curls
3
+
4
+ # This module contains the available proxy types.
5
+ module ProxyTypes
6
+
7
+ # Return proxy types.
8
+ #
9
+ # @example Return proxy types.
10
+ # Ethon::Curl.proxy_types
11
+ #
12
+ # @return [ Hash ] The proxy_types.
13
+ def proxy_types
14
+ {
15
+ :http => 0,
16
+ :http_1_0 => 1,
17
+ :socks4 => 4,
18
+ :socks5 => 5,
19
+ :socks4a => 6,
20
+ :socks5_hostname =>7
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ module Ethon
2
+ module Curl
3
+ callback :callback, [:pointer, :size_t, :size_t, :pointer], :size_t
4
+ ffi_lib_flags :now, :global
5
+ ffi_lib ['libcurl', 'libcurl.so.4']
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ module Ethon
2
+ module Curls
3
+
4
+ # This module contains the ssl version.
5
+ module SslVersions
6
+
7
+ # Return the ssl versions.
8
+ #
9
+ # @example Retur the ssl versions.
10
+ # Ethon::Curl.ssl_versions
11
+ #
12
+ # @return [ Hash ] The versions.
13
+ def ssl_versions
14
+ {
15
+ :default =>0,
16
+ :tlsv1 => 1,
17
+ :sslv2 => 2,
18
+ :sslv3 => 3
19
+ }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -63,7 +63,9 @@ module Ethon
63
63
  left = body.bytesize - @request_body_read
64
64
  size = left if size > left
65
65
  if size > 0
66
- stream.write_string(body.byteslice(@request_body_read, size), size)
66
+ stream.write_string(
67
+ body.respond_to?(:byteslice) ? body.byteslice(@request_body_read, size) : body[@request_body_read, size], size
68
+ )
67
69
  @request_body_read += size
68
70
  end
69
71
  size