ethon 0.4.2 → 0.4.3
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.
- data/CHANGELOG.md +19 -2
- data/Gemfile +20 -1
- data/README.md +29 -34
- data/lib/ethon/curls/constants.rb +3 -1
- data/lib/ethon/curls/functions.rb +36 -29
- data/lib/ethon/curls/options.rb +211 -145
- data/lib/ethon/easy.rb +747 -102
- data/lib/ethon/{easies → easy}/callbacks.rb +1 -1
- data/lib/ethon/{easies → easy}/form.rb +6 -6
- data/lib/ethon/{easies → easy}/header.rb +1 -1
- data/lib/ethon/{easies → easy}/http.rb +16 -10
- data/lib/ethon/{easies → easy}/http/actionable.rb +3 -3
- data/lib/ethon/{easies → easy}/http/delete.rb +3 -3
- data/lib/ethon/{easies → easy}/http/get.rb +3 -3
- data/lib/ethon/{easies → easy}/http/head.rb +3 -3
- data/lib/ethon/{easies → easy}/http/options.rb +3 -3
- data/lib/ethon/{easies → easy}/http/patch.rb +3 -3
- data/lib/ethon/{easies → easy}/http/post.rb +3 -3
- data/lib/ethon/{easies → easy}/http/postable.rb +1 -1
- data/lib/ethon/{easies → easy}/http/put.rb +3 -3
- data/lib/ethon/{easies → easy}/http/putable.rb +1 -1
- data/lib/ethon/{easies → easy}/informations.rb +1 -1
- data/lib/ethon/{easies → easy}/operations.rb +11 -1
- data/lib/ethon/{easies → easy}/options.rb +6 -6
- data/lib/ethon/{easies → easy}/params.rb +5 -5
- data/lib/ethon/{easies → easy}/queryable.rb +1 -1
- data/lib/ethon/{easies → easy}/response_callbacks.rb +1 -1
- data/lib/ethon/{easies → easy}/util.rb +1 -1
- data/lib/ethon/multi.rb +23 -12
- data/lib/ethon/{multies → multi}/operations.rb +13 -1
- data/lib/ethon/multi/options.rb +86 -0
- data/lib/ethon/{multies → multi}/stack.rb +1 -1
- data/lib/ethon/version.rb +1 -1
- metadata +28 -171
data/lib/ethon/easy.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require 'ethon/
|
2
|
-
require 'ethon/
|
3
|
-
require 'ethon/
|
4
|
-
require 'ethon/
|
5
|
-
require 'ethon/
|
6
|
-
require 'ethon/
|
7
|
-
require 'ethon/
|
8
|
-
require 'ethon/
|
9
|
-
require 'ethon/
|
10
|
-
require 'ethon/
|
1
|
+
require 'ethon/easy/informations'
|
2
|
+
require 'ethon/easy/callbacks'
|
3
|
+
require 'ethon/easy/options'
|
4
|
+
require 'ethon/easy/header'
|
5
|
+
require 'ethon/easy/util'
|
6
|
+
require 'ethon/easy/params'
|
7
|
+
require 'ethon/easy/form'
|
8
|
+
require 'ethon/easy/http'
|
9
|
+
require 'ethon/easy/operations'
|
10
|
+
require 'ethon/easy/response_callbacks'
|
11
11
|
|
12
12
|
module Ethon
|
13
13
|
|
@@ -32,14 +32,171 @@ module Ethon
|
|
32
32
|
#
|
33
33
|
# @see initialize
|
34
34
|
class Easy
|
35
|
-
include Ethon::
|
36
|
-
include Ethon::
|
37
|
-
include Ethon::
|
38
|
-
include Ethon::
|
39
|
-
include Ethon::
|
40
|
-
include Ethon::
|
41
|
-
include Ethon::
|
35
|
+
include Ethon::Easy::Informations
|
36
|
+
include Ethon::Easy::Callbacks
|
37
|
+
include Ethon::Easy::Options
|
38
|
+
include Ethon::Easy::Header
|
39
|
+
include Ethon::Easy::Http
|
40
|
+
include Ethon::Easy::Operations
|
41
|
+
include Ethon::Easy::ResponseCallbacks
|
42
42
|
|
43
|
+
# Returns the curl return code.
|
44
|
+
#
|
45
|
+
# @return [ Symbol ] The return code.
|
46
|
+
# * :ok: All fine. Proceed as usual.
|
47
|
+
# * :unsupported_protocol: The URL you passed to libcurl used a
|
48
|
+
# protocol that this libcurl does not support. The support
|
49
|
+
# might be a compile-time option that you didn't use, it can
|
50
|
+
# be a misspelled protocol string or just a protocol
|
51
|
+
# libcurl has no code for.
|
52
|
+
# * :failed_init: Very early initialization code failed. This
|
53
|
+
# is likely to be an internal error or problem, or a
|
54
|
+
# resource problem where something fundamental couldn't
|
55
|
+
# get done at init time.
|
56
|
+
# * :url_malformat: The URL was not properly formatted.
|
57
|
+
# * :not_built_in: A requested feature, protocol or option
|
58
|
+
# was not found built-in in this libcurl due to a build-time
|
59
|
+
# decision. This means that a feature or option was not enabled
|
60
|
+
# or explicitly disabled when libcurl was built and in
|
61
|
+
# order to get it to function you have to get a rebuilt libcurl.
|
62
|
+
# * :couldnt_resolve_proxy: Couldn't resolve proxy. The given
|
63
|
+
# proxy host could not be resolved.
|
64
|
+
# * :couldnt_resolve_host: Couldn't resolve host. The given remote
|
65
|
+
# host was not resolved.
|
66
|
+
# * :couldnt_connect: Failed to connect() to host or proxy.
|
67
|
+
# * :ftp_weird_server_reply: After connecting to a FTP server,
|
68
|
+
# libcurl expects to get a certain reply back. This error
|
69
|
+
# code implies that it got a strange or bad reply. The given
|
70
|
+
# remote server is probably not an OK FTP server.
|
71
|
+
# * :remote_access_denied: We were denied access to the resource
|
72
|
+
# given in the URL. For FTP, this occurs while trying to
|
73
|
+
# change to the remote directory.
|
74
|
+
# * :ftp_accept_failed: While waiting for the server to connect
|
75
|
+
# back when an active FTP session is used, an error code was
|
76
|
+
# sent over the control connection or similar.
|
77
|
+
# * :ftp_weird_pass_reply: After having sent the FTP password to
|
78
|
+
# the server, libcurl expects a proper reply. This error code
|
79
|
+
# indicates that an unexpected code was returned.
|
80
|
+
# * :ftp_accept_timeout: During an active FTP session while
|
81
|
+
# waiting for the server to connect, the CURLOPT_ACCEPTTIMOUT_MS
|
82
|
+
# (or the internal default) timeout expired.
|
83
|
+
# * :ftp_weird_pasv_reply: libcurl failed to get a sensible result
|
84
|
+
# back from the server as a response to either a PASV or a
|
85
|
+
# EPSV command. The server is flawed.
|
86
|
+
# * :ftp_weird_227_format: FTP servers return a 227-line as a response
|
87
|
+
# to a PASV command. If libcurl fails to parse that line,
|
88
|
+
# this return code is passed back.
|
89
|
+
# * :ftp_cant_get_host: An internal failure to lookup the host used
|
90
|
+
# for the new connection.
|
91
|
+
# * :ftp_couldnt_set_type: Received an error when trying to set
|
92
|
+
# the transfer mode to binary or ASCII.
|
93
|
+
# * :partial_file: A file transfer was shorter or larger than
|
94
|
+
# expected. This happens when the server first reports an expected
|
95
|
+
# transfer size, and then delivers data that doesn't match the
|
96
|
+
# previously given size.
|
97
|
+
# * :ftp_couldnt_retr_file: This was either a weird reply to a
|
98
|
+
# 'RETR' command or a zero byte transfer complete.
|
99
|
+
# * :quote_error: When sending custom "QUOTE" commands to the
|
100
|
+
# remote server, one of the commands returned an error code that
|
101
|
+
# was 400 or higher (for FTP) or otherwise indicated unsuccessful
|
102
|
+
# completion of the command.
|
103
|
+
# * :http_returned_error: This is returned if CURLOPT_FAILONERROR is
|
104
|
+
# set TRUE and the HTTP server returns an error code that is >= 400.
|
105
|
+
# * :write_error: An error occurred when writing received data to a
|
106
|
+
# local file, or an error was returned to libcurl from a write callback.
|
107
|
+
# * :upload_failed: Failed starting the upload. For FTP, the server
|
108
|
+
# typically denied the STOR command. The error buffer usually
|
109
|
+
# contains the server's explanation for this.
|
110
|
+
# * :read_error: There was a problem reading a local file or an error
|
111
|
+
# returned by the read callback.
|
112
|
+
# * :out_of_memory: A memory allocation request failed. This is serious
|
113
|
+
# badness and things are severely screwed up if this ever occurs.
|
114
|
+
# * :operation_timedout: Operation timeout. The specified time-out
|
115
|
+
# period was reached according to the conditions.
|
116
|
+
# * :ftp_port_failed: The FTP PORT command returned error. This mostly
|
117
|
+
# happens when you haven't specified a good enough address for
|
118
|
+
# libcurl to use. See CURLOPT_FTPPORT.
|
119
|
+
# * :ftp_couldnt_use_rest: The FTP REST command returned error. This
|
120
|
+
# should never happen if the server is sane.
|
121
|
+
# * :range_error: The server does not support or accept range requests.
|
122
|
+
# * :http_post_error: This is an odd error that mainly occurs due to
|
123
|
+
# internal confusion.
|
124
|
+
# * :ssl_connect_error: A problem occurred somewhere in the SSL/TLS
|
125
|
+
# handshake. You really want the error buffer and read the message
|
126
|
+
# there as it pinpoints the problem slightly more. Could be
|
127
|
+
# certificates (file formats, paths, permissions), passwords, and others.
|
128
|
+
# * :bad_download_resume: The download could not be resumed because
|
129
|
+
# the specified offset was out of the file boundary.
|
130
|
+
# * :file_couldnt_read_file: A file given with FILE:// couldn't be
|
131
|
+
# opened. Most likely because the file path doesn't identify an
|
132
|
+
# existing file. Did you check file permissions?
|
133
|
+
# * :ldap_cannot_bind: LDAP cannot bind. LDAP bind operation failed.
|
134
|
+
# * :ldap_search_failed: LDAP search failed.
|
135
|
+
# * :function_not_found: Function not found. A required zlib function was not found.
|
136
|
+
# * :aborted_by_callback: Aborted by callback. A callback returned
|
137
|
+
# "abort" to libcurl.
|
138
|
+
# * :bad_function_argument: Internal error. A function was called with
|
139
|
+
# a bad parameter.
|
140
|
+
# * :interface_failed: Interface error. A specified outgoing interface
|
141
|
+
# could not be used. Set which interface to use for outgoing
|
142
|
+
# connections' source IP address with CURLOPT_INTERFACE.
|
143
|
+
# * :too_many_redirects: Too many redirects. When following redirects,
|
144
|
+
# libcurl hit the maximum amount. Set your limit with CURLOPT_MAXREDIRS.
|
145
|
+
# * :unknown_option: An option passed to libcurl is not recognized/known.
|
146
|
+
# Refer to the appropriate documentation. This is most likely a
|
147
|
+
# problem in the program that uses libcurl. The error buffer might
|
148
|
+
# contain more specific information about which exact option it concerns.
|
149
|
+
# * :telnet_option_syntax: A telnet option string was Illegally formatted.
|
150
|
+
# * :peer_failed_verification: The remote server's SSL certificate or
|
151
|
+
# SSH md5 fingerprint was deemed not OK.
|
152
|
+
# * :got_nothing: Nothing was returned from the server, and under the
|
153
|
+
# circumstances, getting nothing is considered an error.
|
154
|
+
# * :ssl_engine_notfound: The specified crypto engine wasn't found.
|
155
|
+
# * :ssl_engine_setfailed: Failed setting the selected SSL crypto engine as default!
|
156
|
+
# * :send_error: Failed sending network data.
|
157
|
+
# * :recv_error: Failure with receiving network data.
|
158
|
+
# * :ssl_certproblem: problem with the local client certificate.
|
159
|
+
# * :ssl_cipher: Couldn't use specified cipher.
|
160
|
+
# * :ssl_cacert: Peer certificate cannot be authenticated with known CA certificates.
|
161
|
+
# * :bad_content_encoding: Unrecognized transfer encoding.
|
162
|
+
# * :ldap_invalid_url: Invalid LDAP URL.
|
163
|
+
# * :filesize_exceeded: Maximum file size exceeded.
|
164
|
+
# * :use_ssl_failed: Requested FTP SSL level failed.
|
165
|
+
# * :send_fail_rewind: When doing a send operation curl had to rewind the data to
|
166
|
+
# retransmit, but the rewinding operation failed.
|
167
|
+
# * :ssl_engine_initfailed: Initiating the SSL Engine failed.
|
168
|
+
# * :login_denied: The remote server denied curl to login
|
169
|
+
# * :tftp_notfound: File not found on TFTP server.
|
170
|
+
# * :tftp_perm: Permission problem on TFTP server.
|
171
|
+
# * :remote_disk_full: Out of disk space on the server.
|
172
|
+
# * :tftp_illegal: Illegal TFTP operation.
|
173
|
+
# * :tftp_unknownid: Unknown TFTP transfer ID.
|
174
|
+
# * :remote_file_exists: File already exists and will not be overwritten.
|
175
|
+
# * :tftp_nosuchuser: This error should never be returned by a properly
|
176
|
+
# functioning TFTP server.
|
177
|
+
# * :conv_failed: Character conversion failed.
|
178
|
+
# * :conv_reqd: Caller must register conversion callbacks.
|
179
|
+
# * :ssl_cacert_badfile: Problem with reading the SSL CA cert (path? access rights?):
|
180
|
+
# * :remote_file_not_found: The resource referenced in the URL does not exist.
|
181
|
+
# * :ssh: An unspecified error occurred during the SSH session.
|
182
|
+
# * :ssl_shutdown_failed: Failed to shut down the SSL connection.
|
183
|
+
# * :again: Socket is not ready for send/recv wait till it's ready and try again.
|
184
|
+
# This return code is only returned from curl_easy_recv(3) and curl_easy_send(3)
|
185
|
+
# * :ssl_crl_badfile: Failed to load CRL file
|
186
|
+
# * :ssl_issuer_error: Issuer check failed
|
187
|
+
# * :ftp_pret_failed: The FTP server does not understand the PRET command at
|
188
|
+
# all or does not support the given argument. Be careful when
|
189
|
+
# using CURLOPT_CUSTOMREQUEST, a custom LIST command will be sent with PRET CMD
|
190
|
+
# before PASV as well.
|
191
|
+
# * :rtsp_cseq_error: Mismatch of RTSP CSeq numbers.
|
192
|
+
# * :rtsp_session_error: Mismatch of RTSP Session Identifiers.
|
193
|
+
# * :ftp_bad_file_list: Unable to parse FTP file list (during FTP wildcard downloading).
|
194
|
+
# * :chunk_failed: Chunk callback reported error.
|
195
|
+
# * :obsolete: These error codes will never be returned. They were used in an old
|
196
|
+
# libcurl version and are currently unused.
|
197
|
+
#
|
198
|
+
#
|
199
|
+
# @see http://curl.haxx.se/libcurl/c/libcurl-errors.html
|
43
200
|
attr_accessor :return_code
|
44
201
|
|
45
202
|
class << self
|
@@ -66,82 +223,572 @@ module Ethon
|
|
66
223
|
#
|
67
224
|
# @param [ Hash ] options The options to set.
|
68
225
|
#
|
69
|
-
# @option options :cainfo [String]
|
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
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
# @option options :
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
226
|
+
# @option options :cainfo [String] Pass a char * to a zero terminated
|
227
|
+
# string naming a file holding one or more certificates to verify
|
228
|
+
# the peer with. This makes sense only when used in combination with
|
229
|
+
# the CURLOPT_SSL_VERIFYPEER option. If CURLOPT_SSL_VERIFYPEER is
|
230
|
+
# zero, CURLOPT_CAINFO need not even indicate an accessible file.
|
231
|
+
# This option is by default set to the system path where libcurl's
|
232
|
+
# cacert bundle is assumed to be stored, as established at build time.
|
233
|
+
# When built against NSS, this is the directory that the NSS certificate
|
234
|
+
# database resides in.
|
235
|
+
# @option options :capath [String]
|
236
|
+
# Pass a char * to a zero terminated string naming a directory holding
|
237
|
+
# multiple CA certificates to verify the peer with. If libcurl is built
|
238
|
+
# against OpenSSL, the certificate directory must be prepared using the
|
239
|
+
# openssl c_rehash utility. This makes sense only when used in
|
240
|
+
# combination with the CURLOPT_SSL_VERIFYPEER option. If
|
241
|
+
# CURLOPT_SSL_VERIFYPEER is zero, CURLOPT_CAPATH need not even indicate
|
242
|
+
# an accessible path. The CURLOPT_CAPATH function apparently does not
|
243
|
+
# work in Windows due to some limitation in openssl. This option is
|
244
|
+
# OpenSSL-specific and does nothing if libcurl is built to use GnuTLS.
|
245
|
+
# NSS-powered libcurl provides the option only for backward
|
246
|
+
# compatibility.
|
247
|
+
# @option options :connecttimeout [Integer]
|
248
|
+
# Pass a long. It should contain the maximum time in seconds that you
|
249
|
+
# allow the connection to the server to take. This only limits the
|
250
|
+
# connection phase, once it has connected, this option is of no more
|
251
|
+
# use. Set to zero to switch to the default built-in connection timeout
|
252
|
+
# \- 300 seconds. See also the CURLOPT_TIMEOUT option.
|
253
|
+
# In unix-like systems, this might cause signals to be used unless
|
254
|
+
# CURLOPT_NOSIGNAL is set.
|
255
|
+
# @option options :connecttimeout_ms [Integer]
|
256
|
+
# Like CURLOPT_CONNECTTIMEOUT but takes the number of milliseconds
|
257
|
+
# instead. If libcurl is built to use the standard system name
|
258
|
+
# resolver, that portion of the connect will still use full-second
|
259
|
+
# resolution for timeouts with a minimum timeout allowed of one second.
|
260
|
+
# (Added in 7.16.2)
|
261
|
+
# @option options :copypostfields [String]
|
262
|
+
# Pass a char * as parameter, which should be the full data to post in
|
263
|
+
# a HTTP POST operation. It behaves as the CURLOPT_POSTFIELDS option,
|
264
|
+
# but the original data are copied by the library, allowing the
|
265
|
+
# application to overwrite the original data after setting this option.
|
266
|
+
# Because data are copied, care must be taken when using this option in
|
267
|
+
# conjunction with CURLOPT_POSTFIELDSIZE or
|
268
|
+
# CURLOPT_POSTFIELDSIZE_LARGE: If the size has not been set prior to
|
269
|
+
# CURLOPT_COPYPOSTFIELDS, the data are assumed to be a NUL-terminated
|
270
|
+
# string; else the stored size informs the library about the data byte
|
271
|
+
# count to copy. In any case, the size must not be changed after
|
272
|
+
# CURLOPT_COPYPOSTFIELDS, unless another CURLOPT_POSTFIELDS or
|
273
|
+
# CURLOPT_COPYPOSTFIELDS option is issued. (Added in 7.17.1)
|
274
|
+
# @option options :customrequest [String]
|
275
|
+
# Pass a pointer to a zero terminated string as parameter. It can be
|
276
|
+
# used to specify the request instead of GET or HEAD when performing
|
277
|
+
# HTTP based requests, instead of LIST and NLST when performing FTP
|
278
|
+
# directory listings and instead of LIST and RETR when issuing POP3
|
279
|
+
# based commands. This is particularly useful, for example, for
|
280
|
+
# performing a HTTP DELETE request or a POP3 DELE command.
|
281
|
+
# Please don't perform this at will, on HTTP based requests, by making
|
282
|
+
# sure your server supports the command you are sending first.
|
283
|
+
# When you change the request method by setting CURLOPT_CUSTOMREQUEST
|
284
|
+
# to something, you don't actually change how libcurl behaves or acts
|
285
|
+
# in regards to the particular request method, it will only change the
|
286
|
+
# actual string sent in the request.
|
287
|
+
# For example:
|
288
|
+
# With the HTTP protocol when you tell libcurl to do a HEAD request,
|
289
|
+
# but then specify a GET though a custom request libcurl will still act
|
290
|
+
# as if it sent a HEAD. To switch to a proper HEAD use CURLOPT_NOBODY,
|
291
|
+
# to switch to a proper POST use CURLOPT_POST or CURLOPT_POSTFIELDS and
|
292
|
+
# to switch to a proper GET use CURLOPT_HTTPGET.
|
293
|
+
# With the POP3 protocol when you tell libcurl to use a custom request
|
294
|
+
# it will behave like a LIST or RETR command was sent where it expects
|
295
|
+
# data to be returned by the server. As such CURLOPT_NOBODY should be
|
296
|
+
# used when specifying commands such as DELE and NOOP for example.
|
297
|
+
# Restore to the internal default by setting this to NULL.
|
298
|
+
# Many people have wrongly used this option to replace the entire
|
299
|
+
# request with their own, including multiple headers and POST contents.
|
300
|
+
# While that might work in many cases, it will cause libcurl to send
|
301
|
+
# invalid requests and it could possibly confuse the remote server
|
302
|
+
# badly. Use CURLOPT_POST and CURLOPT_POSTFIELDS to set POST data. Use
|
303
|
+
# CURLOPT_HTTPHEADER to replace or extend the set of headers sent by
|
304
|
+
# libcurl. Use CURLOPT_HTTP_VERSION to change HTTP version.
|
305
|
+
# (Support for POP3 added in 7.26.0)
|
306
|
+
# @option options :dns_cache_timeout [Integer]
|
307
|
+
# Pass a long, this sets the timeout in seconds. Name resolves will be
|
308
|
+
# kept in memory for this number of seconds. Set to zero to completely
|
309
|
+
# disable caching, or set to -1 to make the cached entries remain
|
310
|
+
# forever. By default, libcurl caches this info for 60 seconds.
|
311
|
+
# The name resolve functions of various libc implementations don't
|
312
|
+
# re-read name server information unless explicitly told so (for
|
313
|
+
# example, by calling res_init(3)). This may cause libcurl to keep
|
314
|
+
# using the older server even if DHCP has updated the server info, and
|
315
|
+
# this may look like a DNS cache issue to the casual libcurl-app user.
|
316
|
+
# @option options :followlocation [Boolean]
|
317
|
+
# A parameter set to 1 tells the library to follow any Location: header
|
318
|
+
# that the server sends as part of a HTTP header.
|
319
|
+
# This means that the library will re-send the same request on the new
|
320
|
+
# location and follow new Location: headers all the way until no more
|
321
|
+
# such headers are returned. CURLOPT_MAXREDIRS can be used to limit the
|
322
|
+
# number of redirects libcurl will follow.
|
323
|
+
# Since 7.19.4, libcurl can limit what protocols it will automatically
|
324
|
+
# follow. The accepted protocols are set with CURLOPT_REDIR_PROTOCOLS
|
325
|
+
# and it excludes the FILE protocol by default.
|
326
|
+
# @option options :forbid_reuse [Boolean]
|
327
|
+
# Pass a long. Set to 1 to make the next transfer explicitly close the
|
328
|
+
# connection when done. Normally, libcurl keeps all connections alive
|
329
|
+
# when done with one transfer in case a succeeding one follows that can
|
330
|
+
# re-use them. This option should be used with caution and only if you
|
331
|
+
# understand what it does. Set to 0 to have libcurl keep the connection
|
332
|
+
# open for possible later re-use (default behavior).
|
333
|
+
# @option options :httpauth [String]
|
334
|
+
# Pass a long as parameter, which is set to a bitmask, to tell libcurl
|
335
|
+
# which authentication method(s) you want it to use. The available bits
|
336
|
+
# are listed below. If more than one bit is set, libcurl will first
|
337
|
+
# query the site to see which authentication methods it supports and
|
338
|
+
# then pick the best one you allow it to use. For some methods, this
|
339
|
+
# will induce an extra network round-trip. Set the actual name and
|
340
|
+
# password with the CURLOPT_USERPWD option or with the CURLOPT_USERNAME
|
341
|
+
# and the CURLOPT_PASSWORD options. (Added in 7.10.6)
|
342
|
+
# @option options :httpget [Boolean]
|
343
|
+
# Pass a long. If the long is 1, this forces the HTTP request to get
|
344
|
+
# back to GET. Usable if a POST, HEAD, PUT, or a custom request has
|
345
|
+
# been used previously using the same curl handle.
|
346
|
+
# When setting CURLOPT_HTTPGET to 1, it will automatically set
|
347
|
+
# CURLOPT_NOBODY to 0 (since 7.14.1).
|
348
|
+
# @option options :httppost [String]
|
349
|
+
# Tells libcurl you want a multipart/formdata HTTP POST to be made and
|
350
|
+
# you instruct what data to pass on to the server. Pass a pointer to a
|
351
|
+
# linked list of curl_httppost structs as parameter. The easiest way to
|
352
|
+
# create such a list, is to use curl_formadd(3) as documented. The data
|
353
|
+
# in this list must remain intact until you close this curl handle
|
354
|
+
# again with curl_easy_cleanup(3).
|
355
|
+
# Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue"
|
356
|
+
# header. You can disable this header with CURLOPT_HTTPHEADER as usual.
|
357
|
+
# When setting CURLOPT_HTTPPOST, it will automatically set
|
358
|
+
# CURLOPT_NOBODY to 0 (since 7.14.1).
|
359
|
+
# @option options :infilesize [Integer]
|
360
|
+
# When uploading a file to a remote site, this option should be used to
|
361
|
+
# tell libcurl what the expected size of the infile is. This value
|
362
|
+
# should be passed as a long. See also CURLOPT_INFILESIZE_LARGE.
|
363
|
+
# For uploading using SCP, this option or CURLOPT_INFILESIZE_LARGE is
|
364
|
+
# mandatory.
|
365
|
+
# When sending emails using SMTP, this command can be used to specify
|
366
|
+
# the optional SIZE parameter for the MAIL FROM command. (Added in
|
367
|
+
# 7.23.0)
|
368
|
+
# This option does not limit how much data libcurl will actually send,
|
369
|
+
# as that is controlled entirely by what the read callback returns.
|
370
|
+
# @option options :interface [String]
|
371
|
+
# Pass a char * as parameter. This sets the interface name to use as
|
372
|
+
# outgoing network interface. The name can be an interface name, an IP
|
373
|
+
# address, or a host name.
|
374
|
+
# Starting with 7.24.0: If the parameter starts with "if!" then it is
|
375
|
+
# treated as only as interface name and no attempt will ever be named
|
376
|
+
# to do treat it as an IP address or to do name resolution on it. If
|
377
|
+
# the parameter starts with "host!" it is treated as either an IP
|
378
|
+
# address or a hostname. Hostnames are resolved synchronously. Using
|
379
|
+
# the if! format is highly recommended when using the multi interfaces
|
380
|
+
# to avoid allowing the code to block. If "if!" is specified but the
|
381
|
+
# parameter does not match an existing interface,
|
382
|
+
# CURLE_INTERFACE_FAILED is returned.
|
383
|
+
# @option options :maxredirs [Integer]
|
384
|
+
# Pass a long. The set number will be the redirection limit. If that
|
385
|
+
# many redirections have been followed, the next redirect will cause an
|
386
|
+
# error (CURLE_TOO_MANY_REDIRECTS). This option only makes sense if the
|
387
|
+
# CURLOPT_FOLLOWLOCATION is used at the same time. Added in 7.15.1:
|
388
|
+
# Setting the limit to 0 will make libcurl refuse any redirect. Set it
|
389
|
+
# to -1 for an infinite number of redirects (which is the default)
|
390
|
+
# @option options :nobody [Boolean]
|
391
|
+
# A parameter set to 1 tells the library to not include the body-part
|
392
|
+
# in the output. This is only relevant for protocols that have separate
|
393
|
+
# header and body parts. On HTTP(S) servers, this will make libcurl do
|
394
|
+
# a HEAD request.
|
395
|
+
# To change request to GET, you should use CURLOPT_HTTPGET. Change
|
396
|
+
# request to POST with CURLOPT_POST etc.
|
397
|
+
# @option options :nosignal [Boolean]
|
398
|
+
# Pass a long. If it is 1, libcurl will not use any functions that
|
399
|
+
# install signal handlers or any functions that cause signals to be
|
400
|
+
# sent to the process. This option is mainly here to allow
|
401
|
+
# multi-threaded unix applications to still set/use all timeout options
|
402
|
+
# etc, without risking getting signals. (Added in 7.10)
|
403
|
+
# If this option is set and libcurl has been built with the standard
|
404
|
+
# name resolver, timeouts will not occur while the name resolve takes
|
405
|
+
# place. Consider building libcurl with c-ares support to enable
|
406
|
+
# asynchronous DNS lookups, which enables nice timeouts for name
|
407
|
+
# resolves without signals.
|
408
|
+
# Setting CURLOPT_NOSIGNAL to 1 makes libcurl NOT ask the system to
|
409
|
+
# ignore SIGPIPE signals, which otherwise are sent by the system when
|
410
|
+
# trying to send data to a socket which is closed in the other end.
|
411
|
+
# libcurl makes an effort to never cause such SIGPIPEs to trigger, but
|
412
|
+
# some operating systems have no way to avoid them and even on those
|
413
|
+
# that have there are some corner cases when they may still happen,
|
414
|
+
# contrary to our desire. In addition, using CURLAUTH_NTLM_WB
|
415
|
+
# authentication could cause a SIGCHLD signal to be raised.
|
416
|
+
# @option options :postfieldsize [Integer]
|
417
|
+
# If you want to post data to the server without letting libcurl do a
|
418
|
+
# strlen() to measure the data size, this option must be used. When
|
419
|
+
# this option is used you can post fully binary data, which otherwise
|
420
|
+
# is likely to fail. If this size is set to -1, the library will use
|
421
|
+
# strlen() to get the size.
|
422
|
+
# @option options :proxy [String]
|
423
|
+
# Set HTTP proxy to use. The parameter should be a char * to a zero
|
424
|
+
# terminated string holding the host name or dotted IP address. To
|
425
|
+
# specify port number in this string, append :[port] to the end of the
|
426
|
+
# host name. The proxy string may be prefixed with [protocol]:// since
|
427
|
+
# any such prefix will be ignored. The proxy's port number may
|
428
|
+
# optionally be specified with the separate option. If not specified,
|
429
|
+
# libcurl will default to using port 1080 for proxies.
|
430
|
+
# CURLOPT_PROXYPORT.
|
431
|
+
# When you tell the library to use a HTTP proxy, libcurl will
|
432
|
+
# transparently convert operations to HTTP even if you specify an FTP
|
433
|
+
# URL etc. This may have an impact on what other features of the
|
434
|
+
# library you can use, such as CURLOPT_QUOTE and similar FTP specifics
|
435
|
+
# that don't work unless you tunnel through the HTTP proxy. Such
|
436
|
+
# tunneling is activated with CURLOPT_HTTPPROXYTUNNEL.
|
437
|
+
# libcurl respects the environment variables http_proxy, ftp_proxy,
|
438
|
+
# all_proxy etc, if any of those are set. The CURLOPT_PROXY option does
|
439
|
+
# however override any possibly set environment variables.
|
440
|
+
# Setting the proxy string to "" (an empty string) will explicitly
|
441
|
+
# disable the use of a proxy, even if there is an environment variable
|
442
|
+
# set for it.
|
443
|
+
# Since 7.14.1, the proxy host string given in environment variables
|
444
|
+
# can be specified the exact same way as the proxy can be set with
|
445
|
+
# CURLOPT_PROXY, include protocol prefix (http://) and embedded user +
|
446
|
+
# password.
|
447
|
+
# Since 7.21.7, the proxy string may be specified with a protocol://
|
448
|
+
# prefix to specify alternative proxy protocols. Use socks4://,
|
449
|
+
# socks4a://, socks5:// or socks5h:// (the last one to enable socks5
|
450
|
+
# and asking the proxy to do the resolving, also known as
|
451
|
+
# CURLPROXY_SOCKS5_HOSTNAME type) to request the specific SOCKS version
|
452
|
+
# to be used. No protocol specified, http:// and all others will be
|
453
|
+
# treated as HTTP proxies.
|
454
|
+
# @option options :proxyauth [String]
|
455
|
+
# Pass a long as parameter, which is set to a bitmask, to tell libcurl
|
456
|
+
# which authentication method(s) you want it to use for your proxy
|
457
|
+
# authentication. If more than one bit is set, libcurl will first query
|
458
|
+
# the site to see what authentication methods it supports and then pick
|
459
|
+
# the best one you allow it to use. For some methods, this will induce
|
460
|
+
# an extra network round-trip. Set the actual name and password with
|
461
|
+
# the CURLOPT_PROXYUSERPWD option. The bitmask can be constructed by
|
462
|
+
# or'ing together the bits listed above for the CURLOPT_HTTPAUTH
|
463
|
+
# option. As of this writing, only Basic, Digest and NTLM work. (Added
|
464
|
+
# in 7.10.7)
|
465
|
+
# @option options :proxytype [String]
|
466
|
+
# Pass a long with this option to set type of the proxy. Available
|
467
|
+
# options for this are CURLPROXY_HTTP, CURLPROXY_HTTP_1_0 (added in
|
468
|
+
# 7.19.4), CURLPROXY_SOCKS4 (added in 7.10), CURLPROXY_SOCKS5,
|
469
|
+
# CURLPROXY_SOCKS4A (added in 7.18.0) and CURLPROXY_SOCKS5_HOSTNAME
|
470
|
+
# (added in 7.18.0). The HTTP type is default. (Added in 7.10)
|
471
|
+
# If you set CURLOPT_PROXYTYPE to CURLPROXY_HTTP_1_0, it will only
|
472
|
+
# affect how libcurl speaks to a proxy when CONNECT is used. The HTTP
|
473
|
+
# version used for "regular" HTTP requests is instead controlled with
|
474
|
+
# CURLOPT_HTTP_VERSION.
|
475
|
+
# @option options :proxyport [Integer]
|
476
|
+
# Pass a long with this option to set the proxy port to connect to
|
477
|
+
# unless it is specified in the proxy string CURLOPT_PROXY.
|
478
|
+
# @option options :readdata [String]
|
479
|
+
# Data pointer to pass to the file read function. If you use the
|
480
|
+
# CURLOPT_READFUNCTION option, this is the pointer you'll get as input.
|
481
|
+
# If you don't specify a read callback but instead rely on the default
|
482
|
+
# internal read function, this data must be a valid readable FILE *.
|
483
|
+
# If you're using libcurl as a win32 DLL, you MUST use a
|
484
|
+
# CURLOPT_READFUNCTION if you set this option.
|
485
|
+
# This option was also known by the older name CURLOPT_INFILE,
|
486
|
+
# the name CURLOPT_READDATA was introduced in 7.9.7.
|
487
|
+
# @option options :readfunction [String]
|
488
|
+
# Pass a pointer to a function that matches the following prototype:
|
489
|
+
# size_t function( void *ptr, size_t size, size_t nmemb, void
|
490
|
+
# *userdata); This function gets called by libcurl as soon as it needs
|
491
|
+
# to read data in order to send it to the peer. The data area pointed
|
492
|
+
# at by the pointer ptr may be filled with at most size multiplied with
|
493
|
+
# nmemb number of bytes. Your function must return the actual number of
|
494
|
+
# bytes that you stored in that memory area. Returning 0 will signal
|
495
|
+
# end-of-file to the library and cause it to stop the current transfer.
|
496
|
+
# If you stop the current transfer by returning 0 "pre-maturely" (i.e
|
497
|
+
# before the server expected it, like when you've said you will upload
|
498
|
+
# N bytes and you upload less than N bytes), you may experience that
|
499
|
+
# the server "hangs" waiting for the rest of the data that won't come.
|
500
|
+
# The read callback may return CURL_READFUNC_ABORT to stop the current
|
501
|
+
# operation immediately, resulting in a CURLE_ABORTED_BY_CALLBACK error
|
502
|
+
# code from the transfer (Added in 7.12.1)
|
503
|
+
# From 7.18.0, the function can return CURL_READFUNC_PAUSE which then
|
504
|
+
# will cause reading from this connection to become paused. See
|
505
|
+
# curl_easy_pause(3) for further details.
|
506
|
+
# Bugs: when doing TFTP uploads, you must return the exact amount of
|
507
|
+
# data that the callback wants, or it will be considered the final
|
508
|
+
# packet by the server end and the transfer will end there.
|
509
|
+
# If you set this callback pointer to NULL, or don't set it at all, the
|
510
|
+
# default internal read function will be used. It is doing an fread()
|
511
|
+
# on the FILE * userdata set with CURLOPT_READDATA.
|
512
|
+
# @option options :ssl_verifyhost [Integer]
|
513
|
+
# Pass a long as parameter.
|
514
|
+
# This option determines whether libcurl verifies that the server cert
|
515
|
+
# is for the server it is known as.
|
516
|
+
# When negotiating a SSL connection, the server sends a certificate
|
517
|
+
# indicating its identity.
|
518
|
+
# When CURLOPT_SSL_VERIFYHOST is 2, that certificate must indicate that
|
519
|
+
# the server is the server to which you meant to connect, or the
|
520
|
+
# connection fails.
|
521
|
+
# Curl considers the server the intended one when the Common Name field
|
522
|
+
# or a Subject Alternate Name field in the certificate matches the host
|
523
|
+
# name in the URL to which you told Curl to connect.
|
524
|
+
# When the value is 1, the certificate must contain a Common Name
|
525
|
+
# field, but it doesn't matter what name it says. (This is not
|
526
|
+
# ordinarily a useful setting).
|
527
|
+
# When the value is 0, the connection succeeds regardless of the names
|
528
|
+
# in the certificate.
|
529
|
+
# The default value for this option is 2.
|
530
|
+
# This option controls checking the server's certificate's claimed
|
531
|
+
# identity. The server could be lying. To control lying, see
|
532
|
+
# CURLOPT_SSL_VERIFYPEER. If libcurl is built against NSS and
|
533
|
+
# CURLOPT_SSL_VERIFYPEER is zero, CURLOPT_SSL_VERIFYHOST is ignored.
|
534
|
+
# @option options :ssl_verifypeer [Boolean]
|
535
|
+
# Pass a long as parameter. By default, curl assumes a value of 1.
|
536
|
+
# This option determines whether curl verifies the authenticity of the
|
537
|
+
# peer's certificate. A value of 1 means curl verifies; 0 (zero) means
|
538
|
+
# it doesn't.
|
539
|
+
# When negotiating a SSL connection, the server sends a certificate
|
540
|
+
# indicating its identity. Curl verifies whether the certificate is
|
541
|
+
# authentic, i.e. that you can trust that the server is who the
|
542
|
+
# certificate says it is. This trust is based on a chain of digital
|
543
|
+
# signatures, rooted in certification authority (CA) certificates you
|
544
|
+
# supply. curl uses a default bundle of CA certificates (the path for
|
545
|
+
# that is determined at build time) and you can specify alternate
|
546
|
+
# certificates with the CURLOPT_CAINFO option or the CURLOPT_CAPATH
|
547
|
+
# option.
|
548
|
+
# When CURLOPT_SSL_VERIFYPEER is nonzero, and the verification fails to
|
549
|
+
# prove that the certificate is authentic, the connection fails. When
|
550
|
+
# the option is zero, the peer certificate verification succeeds
|
551
|
+
# regardless.
|
552
|
+
# Authenticating the certificate is not by itself very useful. You
|
553
|
+
# typically want to ensure that the server, as authentically identified
|
554
|
+
# by its certificate, is the server you mean to be talking to. Use
|
555
|
+
# CURLOPT_SSL_VERIFYHOST to control that. The check that the host name
|
556
|
+
# in the certificate is valid for the host name you're connecting to is
|
557
|
+
# done independently of the CURLOPT_SSL_VERIFYPEER option.
|
558
|
+
# @option options :sslcert [String]
|
559
|
+
# Pass a pointer to a zero terminated string as parameter. The string
|
560
|
+
# should be the file name of your certificate. The default format is
|
561
|
+
# "PEM" and can be changed with CURLOPT_SSLCERTTYPE.
|
562
|
+
# With NSS this can also be the nickname of the certificate you wish to
|
563
|
+
# authenticate with. If you want to use a file from the current
|
564
|
+
# directory, please precede it with "./" prefix, in order to avoid
|
565
|
+
# confusion with a nickname.
|
566
|
+
# @option options :sslcerttype [String]
|
567
|
+
# Pass a pointer to a zero terminated string as parameter. The string
|
568
|
+
# should be the format of your certificate. Supported formats are "PEM"
|
569
|
+
# and "DER". (Added in 7.9.3)
|
570
|
+
# @option options :sslkey [String]
|
571
|
+
# Pass a pointer to a zero terminated string as parameter. The string
|
572
|
+
# should be the file name of your private key. The default format is
|
573
|
+
# "PEM" and can be changed with CURLOPT_SSLKEYTYPE.
|
574
|
+
# @option options :sslkeytype [String]
|
575
|
+
# Pass a pointer to a zero terminated string as parameter. The string
|
576
|
+
# should be the format of your private key. Supported formats are
|
577
|
+
# "PEM", "DER" and "ENG".
|
578
|
+
# The format "ENG" enables you to load the private key from a crypto
|
579
|
+
# engine. In this case CURLOPT_SSLKEY is used as an identifier passed
|
580
|
+
# to the engine. You have to set the crypto engine with
|
581
|
+
# CURLOPT_SSLENGINE. "DER" format key file currently does not work
|
582
|
+
# because of a bug in OpenSSL.
|
583
|
+
# @option options :sslversion [String]
|
584
|
+
# Pass a long as parameter to control what version of SSL/TLS to
|
585
|
+
# attempt to use. The available options are:
|
586
|
+
# @option options :timeout [Integer]
|
587
|
+
# Pass a long as parameter containing the maximum time in seconds that
|
588
|
+
# you allow the libcurl transfer operation to take. Normally, name
|
589
|
+
# lookups can take a considerable time and limiting operations to less
|
590
|
+
# than a few minutes risk aborting perfectly normal operations. This
|
591
|
+
# option will cause curl to use the SIGALRM to enable time-outing
|
592
|
+
# system calls.
|
593
|
+
# In unix-like systems, this might cause signals to be used unless
|
594
|
+
# CURLOPT_NOSIGNAL is set.
|
595
|
+
# Default timeout is 0 (zero) which means it never times out.
|
596
|
+
# @option options :timeout_ms [Integer]
|
597
|
+
# Like CURLOPT_TIMEOUT but takes number of milliseconds instead. If
|
598
|
+
# libcurl is built to use the standard system name resolver, that
|
599
|
+
# portion of the transfer will still use full-second resolution for
|
600
|
+
# timeouts with a minimum timeout allowed of one second. (Added in
|
601
|
+
# 7.16.2)
|
602
|
+
# @option options :upload [Boolean]
|
603
|
+
# A parameter set to 1 tells the library to prepare for an upload. The
|
604
|
+
# CURLOPT_READDATA and CURLOPT_INFILESIZE or CURLOPT_INFILESIZE_LARGE
|
605
|
+
# options are also interesting for uploads. If the protocol is HTTP,
|
606
|
+
# uploading means using the PUT request unless you tell libcurl
|
607
|
+
# otherwise.
|
608
|
+
# Using PUT with HTTP 1.1 implies the use of a "Expect: 100-continue"
|
609
|
+
# header. You can disable this header with CURLOPT_HTTPHEADER as usual.
|
610
|
+
# If you use PUT to a HTTP 1.1 server, you can upload data without
|
611
|
+
# knowing the size before starting the transfer if you use chunked
|
612
|
+
# encoding. You enable this by adding a header like "Transfer-Encoding:
|
613
|
+
# chunked" with CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked
|
614
|
+
# transfer, you must specify the size.
|
615
|
+
# @option options :url [String]
|
616
|
+
# Pass in a pointer to the actual URL to deal with. The parameter
|
617
|
+
# should be a char * to a zero terminated string which must be
|
618
|
+
# URL-encoded in the following format:
|
619
|
+
# scheme://host:port/path
|
620
|
+
# For a greater explanation of the format please see RFC 3986.
|
621
|
+
# If the given URL lacks the scheme, or protocol, part ("http://" or
|
622
|
+
# "ftp://" etc), libcurl will attempt to resolve which protocol to use
|
623
|
+
# based on the given host mame. If the protocol is not supported,
|
624
|
+
# libcurl will return (CURLE_UNSUPPORTED_PROTOCOL) when you call
|
625
|
+
# curl_easy_perform(3) or curl_multi_perform(3). Use
|
626
|
+
# curl_version_info(3) for detailed information on which protocols are
|
627
|
+
# supported.
|
628
|
+
# The host part of the URL contains the address of the server that you
|
629
|
+
# want to connect to. This can be the fully qualified domain name of
|
630
|
+
# the server, the local network name of the machine on your network or
|
631
|
+
# the IP address of the server or machine represented by either an IPv4
|
632
|
+
# or IPv6 address. For example:
|
633
|
+
# http://www.example.com/
|
634
|
+
# http://hostname/
|
635
|
+
# http://192.168.0.1/
|
636
|
+
# http://[2001:1890:1112:1::20]/
|
637
|
+
# It is also possible to specify the user name and password as part of
|
638
|
+
# the host, for some protocols, when connecting to servers that require
|
639
|
+
# authentication.
|
640
|
+
# For example the following types of authentication support this:
|
641
|
+
# http://user:password@www.example.com
|
642
|
+
# ftp://user:password@ftp.example.com
|
643
|
+
# pop3://user:password@mail.example.com
|
644
|
+
# The port is optional and when not specified libcurl will use the
|
645
|
+
# default port based on the determined or specified protocol: 80 for
|
646
|
+
# HTTP, 21 for FTP and 25 for SMTP, etc. The following examples show
|
647
|
+
# how to specify the port:
|
648
|
+
# http://www.example.com:8080/ - This will connect to a web server
|
649
|
+
# using port 8080 rather than 80.
|
650
|
+
# smtp://mail.example.com:587/ - This will connect to a SMTP server on
|
651
|
+
# the alternative mail port.
|
652
|
+
# The path part of the URL is protocol specific and whilst some
|
653
|
+
# examples are given below this list is not conclusive:
|
654
|
+
# HTTP
|
655
|
+
# The path part of a HTTP request specifies the file to retrieve and
|
656
|
+
# from what directory. If the directory is not specified then the web
|
657
|
+
# server's root directory is used. If the file is omitted then the
|
658
|
+
# default document will be retrieved for either the directory specified
|
659
|
+
# or the root directory. The exact resource returned for each URL is
|
660
|
+
# entirely dependent on the server's configuration.
|
661
|
+
# http://www.example.com - This gets the main page from the web server.
|
662
|
+
# http://www.example.com/index.html - This returns the main page by
|
663
|
+
# explicitly requesting it.
|
664
|
+
# http://www.example.com/contactus/ - This returns the default document
|
665
|
+
# from the contactus directory.
|
666
|
+
# FTP
|
667
|
+
# The path part of an FTP request specifies the file to retrieve and
|
668
|
+
# from what directory. If the file part is omitted then libcurl
|
669
|
+
# downloads the directory listing for the directory specified. If the
|
670
|
+
# directory is omitted then the directory listing for the root / home
|
671
|
+
# directory will be returned.
|
672
|
+
# ftp://ftp.example.com - This retrieves the directory listing for the
|
673
|
+
# root directory.
|
674
|
+
# ftp://ftp.example.com/readme.txt - This downloads the file readme.txt
|
675
|
+
# from the root directory.
|
676
|
+
# ftp://ftp.example.com/libcurl/readme.txt - This downloads readme.txt
|
677
|
+
# from the libcurl directory.
|
678
|
+
# ftp://user:password@ftp.example.com/readme.txt - This retrieves the
|
679
|
+
# readme.txt file from the user's home directory. When a username and
|
680
|
+
# password is specified, everything that is specified in the path part
|
681
|
+
# is relative to the user's home directory. To retrieve files from the
|
682
|
+
# root directory or a directory underneath the root directory then the
|
683
|
+
# absolute path must be specified by prepending an additional forward
|
684
|
+
# slash to the beginning of the path.
|
685
|
+
# ftp://user:password@ftp.example.com//readme.txt - This retrieves the
|
686
|
+
# readme.txt from the root directory when logging in as a specified
|
687
|
+
# user.
|
688
|
+
# SMTP
|
689
|
+
# The path part of a SMTP request specifies the host name to present
|
690
|
+
# during communication with the mail server. If the path is omitted
|
691
|
+
# then libcurl will attempt to resolve the local computer's host name.
|
692
|
+
# However, this may not return the fully qualified domain name that is
|
693
|
+
# required by some mail servers and specifying this path allows you to
|
694
|
+
# set an alternative name, such as your machine's fully qualified
|
695
|
+
# domain name, which you might have obtained from an external function
|
696
|
+
# such as gethostname or getaddrinfo.
|
697
|
+
# smtp://mail.example.com - This connects to the mail server at
|
698
|
+
# example.com and sends your local computer's host name in the HELO /
|
699
|
+
# EHLO command.
|
700
|
+
# smtp://mail.example.com/client.example.com - This will send
|
701
|
+
# client.example.com in the HELO / EHLO command to the mail server at
|
702
|
+
# example.com.
|
703
|
+
# POP3
|
704
|
+
# The path part of a POP3 request specifies the mailbox (message) to
|
705
|
+
# retrieve. If the mailbox is not specified then a list of waiting
|
706
|
+
# messages is returned instead.
|
707
|
+
# pop3://user:password@mail.example.com - This lists the available
|
708
|
+
# messages pop3://user:password@mail.example.com/1 - This retrieves the
|
709
|
+
# first message
|
710
|
+
# SCP
|
711
|
+
# The path part of a SCP request specifies the file to retrieve and
|
712
|
+
# from what directory. The file part may not be omitted. The file is
|
713
|
+
# taken as an absolute path from the root directory on the server. To
|
714
|
+
# specify a path relative to the user's home directory on the server,
|
715
|
+
# prepend ~/ to the path portion. If the user name is not embedded in
|
716
|
+
# the URL, it can be set with the CURLOPT_USERPWD or CURLOPT_USERNAME
|
717
|
+
# option.
|
718
|
+
# scp://user@example.com/etc/issue - This specifies the file /etc/issue
|
719
|
+
# scp://example.com/~/my-file - This specifies the file my-file in the
|
720
|
+
# user's home directory on the server
|
721
|
+
# SFTP
|
722
|
+
# The path part of a SFTP request specifies the file to retrieve and
|
723
|
+
# from what directory. If the file part is omitted then libcurl
|
724
|
+
# downloads the directory listing for the directory specified. If the
|
725
|
+
# path ends in a / then a directory listing is returned instead of a
|
726
|
+
# file. If the path is omitted entirely then the directory listing for
|
727
|
+
# the root / home directory will be returned. If the user name is not
|
728
|
+
# embedded in the URL, it can be set with the CURLOPT_USERPWD or
|
729
|
+
# CURLOPT_USERNAME option.
|
730
|
+
# sftp://user:password@example.com/etc/issue - This specifies the file
|
731
|
+
# /etc/issue
|
732
|
+
# sftp://user@example.com/~/my-file - This specifies the file my-file
|
733
|
+
# in the user's home directory
|
734
|
+
# sftp://ssh.example.com/~/Documents/ - This requests a directory
|
735
|
+
# listing of the Documents directory under the user's home directory
|
736
|
+
# LDAP
|
737
|
+
# The path part of a LDAP request can be used to specify the:
|
738
|
+
# Distinguished Name, Attributes, Scope, Filter and Extension for a
|
739
|
+
# LDAP search. Each field is separated by a question mark and when that
|
740
|
+
# field is not required an empty string with the question mark
|
741
|
+
# separator should be included.
|
742
|
+
# ldap://ldap.example.com/o=My%20Organisation - This will perform a
|
743
|
+
# LDAP search with the DN as My Organisation.
|
744
|
+
# ldap://ldap.example.com/o=My%20Organisation?postalAddress - This will
|
745
|
+
# perform the same search but will only return postalAddress attributes.
|
746
|
+
# ldap://ldap.example.com/?rootDomainNamingContext - This specifies an
|
747
|
+
# empty DN and requests information about the rootDomainNamingContext
|
748
|
+
# attribute for an Active Directory server.
|
749
|
+
# For more information about the individual components of a LDAP URL
|
750
|
+
# please see RFC 4516.
|
751
|
+
# NOTES
|
752
|
+
# Starting with version 7.20.0, the fragment part of the URI will not
|
753
|
+
# be sent as part of the path, which was previously the case.
|
754
|
+
# CURLOPT_URL is the only option that must be set before
|
755
|
+
# curl_easy_perform(3) is called.
|
756
|
+
# CURLOPT_PROTOCOLS can be used to limit what protocols libcurl will
|
757
|
+
# use for this transfer, independent of what libcurl has been compiled
|
758
|
+
# to support. That may be useful if you accept the URL from an external
|
759
|
+
# source and want to limit the accessibility.
|
760
|
+
# @option options :useragent [String]
|
761
|
+
# Pass a pointer to a zero terminated string as parameter. It will be
|
762
|
+
# used to set the User-Agent: header in the http request sent to the
|
763
|
+
# remote server. This can be used to fool servers or scripts. You can
|
764
|
+
# also set any custom header with CURLOPT_HTTPHEADER.
|
765
|
+
# @option options :userpwd [String]
|
766
|
+
# Pass a char * as parameter, which should be [user name]:[password] to
|
767
|
+
# use for the connection. Use CURLOPT_HTTPAUTH to decide the
|
768
|
+
# authentication method.
|
769
|
+
# When using NTLM, you can set the domain by prepending it to the user
|
770
|
+
# name and separating the domain and name with a forward (/) or
|
771
|
+
# backward slash (\). Like this: "domain/user:password" or
|
772
|
+
# "domain\user:password". Some HTTP servers (on Windows) support this
|
773
|
+
# style even for Basic authentication.
|
774
|
+
# When using HTTP and CURLOPT_FOLLOWLOCATION, libcurl might perform
|
775
|
+
# several requests to possibly different hosts. libcurl will only send
|
776
|
+
# this user and password information to hosts using the initial host
|
777
|
+
# name (unless CURLOPT_UNRESTRICTED_AUTH is set), so if libcurl follows
|
778
|
+
# locations to other hosts it will not send the user and password to
|
779
|
+
# those. This is enforced to prevent accidental information leakage.
|
780
|
+
# @option options :verbose [Boolean]
|
781
|
+
# Set the parameter to 1 to get the library to display a lot of verbose
|
782
|
+
# information about its operations. Very useful for libcurl and/or
|
783
|
+
# protocol debugging and understanding. The verbose information will be
|
784
|
+
# sent to stderr, or the stream set with CURLOPT_STDERR.
|
785
|
+
# You hardly ever want this set in production use, you will almost
|
786
|
+
# always want this when you debug/report problems. Another neat option
|
787
|
+
# for debugging is the CURLOPT_DEBUGFUNCTION.
|
143
788
|
#
|
144
789
|
# @return [ Easy ] A new Easy.
|
790
|
+
#
|
791
|
+
# @see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
|
145
792
|
def initialize(options = {})
|
146
793
|
Curl.init
|
147
794
|
ObjectSpace.define_finalizer(self, self.class.finalizer(self))
|
@@ -179,18 +826,16 @@ module Ethon
|
|
179
826
|
Curl.easy_reset(handle)
|
180
827
|
end
|
181
828
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
# Returns a pointer to the curl easy handle.
|
829
|
+
# Url escapes the value.
|
830
|
+
#
|
831
|
+
# @example Url escape.
|
832
|
+
# easy.escape(value)
|
187
833
|
#
|
188
|
-
# @
|
189
|
-
# easy.handle
|
834
|
+
# @param [ String ] value The value to escape.
|
190
835
|
#
|
191
|
-
# @return [
|
192
|
-
def
|
193
|
-
|
836
|
+
# @return [ String ] The escaped value.
|
837
|
+
def escape(value)
|
838
|
+
Curl.easy_escape(handle, value, 0)
|
194
839
|
end
|
195
840
|
|
196
841
|
# Returns the informations available through libcurl as
|
@@ -204,7 +849,7 @@ module Ethon
|
|
204
849
|
:response_header => response_header,
|
205
850
|
:response_body => response_body
|
206
851
|
}
|
207
|
-
|
852
|
+
Easy::Informations::AVAILABLE_INFORMATIONS.keys.each do |info|
|
208
853
|
@hash[info] = method(info).call
|
209
854
|
end
|
210
855
|
@hash
|