ethon 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -2,7 +2,17 @@
2
2
 
3
3
  ## Master
4
4
 
5
- [Full Changelog](http://github.com/typhoeus/ethon/compare/v0.5.3...master)
5
+ [Full Changelog](http://github.com/typhoeus/ethon/compare/v0.5.4...master)
6
+
7
+ ## 0.5.4
8
+
9
+ [Full Changelog](http://github.com/typhoeus/ethon/compare/v0.5.3...v0.5.4)
10
+
11
+ Enhancements:
12
+
13
+ * Use Libc#getdtablesize to get the FDSet size.
14
+ * New libcurl option accept_encoding.
15
+ * Documentation updates.
6
16
 
7
17
  ## 0.5.3
8
18
 
@@ -17,15 +17,14 @@ module Ethon
17
17
 
18
18
  # :nodoc:
19
19
  class FDSet < ::FFI::Struct
20
- # XXX how does this work on non-windows? how can curl know the new size...
21
- FD_SETSIZE = ::Ethon::Libc.getdtablesize
22
-
23
20
  if Curl.windows?
24
21
  layout :fd_count, :u_int,
25
22
  :fd_array, [:u_int, 64] # 2048 FDs
26
23
 
27
24
  def clear; self[:fd_count] = 0; end
28
25
  else
26
+ # FD Set size.
27
+ FD_SETSIZE = ::Ethon::Libc.getdtablesize
29
28
  layout :fds_bits, [:long, FD_SETSIZE / ::FFI::Type::LONG.size]
30
29
 
31
30
  # :nodoc:
@@ -133,7 +133,7 @@ module Ethon
133
133
  :nosignal => option_types[:long] + 99,
134
134
  :share => option_types[:object_point] + 100,
135
135
  :proxytype => option_types[:long] + 101,
136
- :encoding => option_types[:object_point] + 102,
136
+ :accept_encoding => option_types[:object_point] + 102,
137
137
  :private => option_types[:object_point] + 103,
138
138
  :unrestricted_auth => option_types[:long] + 105,
139
139
  :ftp_use_eprt => option_types[:long] + 106,
data/lib/ethon/easy.rb CHANGED
@@ -193,7 +193,6 @@ module Ethon
193
193
  # * :obsolete: These error codes will never be returned. They were used in an old
194
194
  # libcurl version and are currently unused.
195
195
  #
196
- #
197
196
  # @see http://curl.haxx.se/libcurl/c/libcurl-errors.html
198
197
  attr_accessor :return_code
199
198
 
@@ -219,591 +218,19 @@ module Ethon
219
218
 
220
219
  # Initialize a new Easy.
221
220
  # It initializes curl, if not already done and applies the provided options.
221
+ # Look into {Ethon::Easy::Options Options} to see what you can provide in the
222
+ # options hash.
222
223
  #
223
224
  # @example Create a new Easy.
224
225
  # Easy.new(url: "www.google.de")
225
226
  #
226
227
  # @param [ Hash ] options The options to set.
227
- #
228
- # @option options :cainfo [String] Pass a char * to a zero terminated
229
- # string naming a file holding one or more certificates to verify
230
- # the peer with. This makes sense only when used in combination with
231
- # the CURLOPT_SSL_VERIFYPEER option. If CURLOPT_SSL_VERIFYPEER is
232
- # zero, CURLOPT_CAINFO need not even indicate an accessible file.
233
- # This option is by default set to the system path where libcurl's
234
- # cacert bundle is assumed to be stored, as established at build time.
235
- # When built against NSS, this is the directory that the NSS certificate
236
- # database resides in.
237
- # @option options :capath [String]
238
- # Pass a char * to a zero terminated string naming a directory holding
239
- # multiple CA certificates to verify the peer with. If libcurl is built
240
- # against OpenSSL, the certificate directory must be prepared using the
241
- # openssl c_rehash utility. This makes sense only when used in
242
- # combination with the CURLOPT_SSL_VERIFYPEER option. If
243
- # CURLOPT_SSL_VERIFYPEER is zero, CURLOPT_CAPATH need not even indicate
244
- # an accessible path. The CURLOPT_CAPATH function apparently does not
245
- # work in Windows due to some limitation in openssl. This option is
246
- # OpenSSL-specific and does nothing if libcurl is built to use GnuTLS.
247
- # NSS-powered libcurl provides the option only for backward
248
- # compatibility.
249
- # @option options :connecttimeout [Integer]
250
- # Pass a long. It should contain the maximum time in seconds that you
251
- # allow the connection to the server to take. This only limits the
252
- # connection phase, once it has connected, this option is of no more
253
- # use. Set to zero to switch to the default built-in connection timeout
254
- # \- 300 seconds. See also the CURLOPT_TIMEOUT option.
255
- # In unix-like systems, this might cause signals to be used unless
256
- # CURLOPT_NOSIGNAL is set.
257
- # @option options :connecttimeout_ms [Integer]
258
- # Like CURLOPT_CONNECTTIMEOUT but takes the number of milliseconds
259
- # instead. If libcurl is built to use the standard system name
260
- # resolver, that portion of the connect will still use full-second
261
- # resolution for timeouts with a minimum timeout allowed of one second.
262
- # (Added in 7.16.2)
263
- # @option options :copypostfields [String]
264
- # Pass a char * as parameter, which should be the full data to post in
265
- # a HTTP POST operation. It behaves as the CURLOPT_POSTFIELDS option,
266
- # but the original data are copied by the library, allowing the
267
- # application to overwrite the original data after setting this option.
268
- # Because data are copied, care must be taken when using this option in
269
- # conjunction with CURLOPT_POSTFIELDSIZE or
270
- # CURLOPT_POSTFIELDSIZE_LARGE: If the size has not been set prior to
271
- # CURLOPT_COPYPOSTFIELDS, the data are assumed to be a NUL-terminated
272
- # string; else the stored size informs the library about the data byte
273
- # count to copy. In any case, the size must not be changed after
274
- # CURLOPT_COPYPOSTFIELDS, unless another CURLOPT_POSTFIELDS or
275
- # CURLOPT_COPYPOSTFIELDS option is issued. (Added in 7.17.1)
276
- # @option options :customrequest [String]
277
- # Pass a pointer to a zero terminated string as parameter. It can be
278
- # used to specify the request instead of GET or HEAD when performing
279
- # HTTP based requests, instead of LIST and NLST when performing FTP
280
- # directory listings and instead of LIST and RETR when issuing POP3
281
- # based commands. This is particularly useful, for example, for
282
- # performing a HTTP DELETE request or a POP3 DELE command.
283
- # Please don't perform this at will, on HTTP based requests, by making
284
- # sure your server supports the command you are sending first.
285
- # When you change the request method by setting CURLOPT_CUSTOMREQUEST
286
- # to something, you don't actually change how libcurl behaves or acts
287
- # in regards to the particular request method, it will only change the
288
- # actual string sent in the request.
289
- # For example:
290
- # With the HTTP protocol when you tell libcurl to do a HEAD request,
291
- # but then specify a GET though a custom request libcurl will still act
292
- # as if it sent a HEAD. To switch to a proper HEAD use CURLOPT_NOBODY,
293
- # to switch to a proper POST use CURLOPT_POST or CURLOPT_POSTFIELDS and
294
- # to switch to a proper GET use CURLOPT_HTTPGET.
295
- # With the POP3 protocol when you tell libcurl to use a custom request
296
- # it will behave like a LIST or RETR command was sent where it expects
297
- # data to be returned by the server. As such CURLOPT_NOBODY should be
298
- # used when specifying commands such as DELE and NOOP for example.
299
- # Restore to the internal default by setting this to NULL.
300
- # Many people have wrongly used this option to replace the entire
301
- # request with their own, including multiple headers and POST contents.
302
- # While that might work in many cases, it will cause libcurl to send
303
- # invalid requests and it could possibly confuse the remote server
304
- # badly. Use CURLOPT_POST and CURLOPT_POSTFIELDS to set POST data. Use
305
- # CURLOPT_HTTPHEADER to replace or extend the set of headers sent by
306
- # libcurl. Use CURLOPT_HTTP_VERSION to change HTTP version.
307
- # (Support for POP3 added in 7.26.0)
308
- # @option options :dns_cache_timeout [Integer]
309
- # Pass a long, this sets the timeout in seconds. Name resolves will be
310
- # kept in memory for this number of seconds. Set to zero to completely
311
- # disable caching, or set to -1 to make the cached entries remain
312
- # forever. By default, libcurl caches this info for 60 seconds.
313
- # The name resolve functions of various libc implementations don't
314
- # re-read name server information unless explicitly told so (for
315
- # example, by calling res_init(3)). This may cause libcurl to keep
316
- # using the older server even if DHCP has updated the server info, and
317
- # this may look like a DNS cache issue to the casual libcurl-app user.
318
- # @option options :followlocation [Boolean]
319
- # A parameter set to 1 tells the library to follow any Location: header
320
- # that the server sends as part of a HTTP header.
321
- # This means that the library will re-send the same request on the new
322
- # location and follow new Location: headers all the way until no more
323
- # such headers are returned. CURLOPT_MAXREDIRS can be used to limit the
324
- # number of redirects libcurl will follow.
325
- # Since 7.19.4, libcurl can limit what protocols it will automatically
326
- # follow. The accepted protocols are set with CURLOPT_REDIR_PROTOCOLS
327
- # and it excludes the FILE protocol by default.
328
- # @option options :forbid_reuse [Boolean]
329
- # Pass a long. Set to 1 to make the next transfer explicitly close the
330
- # connection when done. Normally, libcurl keeps all connections alive
331
- # when done with one transfer in case a succeeding one follows that can
332
- # re-use them. This option should be used with caution and only if you
333
- # understand what it does. Set to 0 to have libcurl keep the connection
334
- # open for possible later re-use (default behavior).
335
- # @option options :httpauth [String]
336
- # Pass a long as parameter, which is set to a bitmask, to tell libcurl
337
- # which authentication method(s) you want it to use. The available bits
338
- # are listed below. If more than one bit is set, libcurl will first
339
- # query the site to see which authentication methods it supports and
340
- # then pick the best one you allow it to use. For some methods, this
341
- # will induce an extra network round-trip. Set the actual name and
342
- # password with the CURLOPT_USERPWD option or with the CURLOPT_USERNAME
343
- # and the CURLOPT_PASSWORD options. (Added in 7.10.6)
344
- # @option options :httpget [Boolean]
345
- # Pass a long. If the long is 1, this forces the HTTP request to get
346
- # back to GET. Usable if a POST, HEAD, PUT, or a custom request has
347
- # been used previously using the same curl handle.
348
- # When setting CURLOPT_HTTPGET to 1, it will automatically set
349
- # CURLOPT_NOBODY to 0 (since 7.14.1).
350
- # @option options :httppost [String]
351
- # Tells libcurl you want a multipart/formdata HTTP POST to be made and
352
- # you instruct what data to pass on to the server. Pass a pointer to a
353
- # linked list of curl_httppost structs as parameter. The easiest way to
354
- # create such a list, is to use curl_formadd(3) as documented. The data
355
- # in this list must remain intact until you close this curl handle
356
- # again with curl_easy_cleanup(3).
357
- # Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue"
358
- # header. You can disable this header with CURLOPT_HTTPHEADER as usual.
359
- # When setting CURLOPT_HTTPPOST, it will automatically set
360
- # CURLOPT_NOBODY to 0 (since 7.14.1).
361
- # @option options :infilesize [Integer]
362
- # When uploading a file to a remote site, this option should be used to
363
- # tell libcurl what the expected size of the infile is. This value
364
- # should be passed as a long. See also CURLOPT_INFILESIZE_LARGE.
365
- # For uploading using SCP, this option or CURLOPT_INFILESIZE_LARGE is
366
- # mandatory.
367
- # When sending emails using SMTP, this command can be used to specify
368
- # the optional SIZE parameter for the MAIL FROM command. (Added in
369
- # 7.23.0)
370
- # This option does not limit how much data libcurl will actually send,
371
- # as that is controlled entirely by what the read callback returns.
372
- # @option options :interface [String]
373
- # Pass a char * as parameter. This sets the interface name to use as
374
- # outgoing network interface. The name can be an interface name, an IP
375
- # address, or a host name.
376
- # Starting with 7.24.0: If the parameter starts with "if!" then it is
377
- # treated as only as interface name and no attempt will ever be named
378
- # to do treat it as an IP address or to do name resolution on it. If
379
- # the parameter starts with "host!" it is treated as either an IP
380
- # address or a hostname. Hostnames are resolved synchronously. Using
381
- # the if! format is highly recommended when using the multi interfaces
382
- # to avoid allowing the code to block. If "if!" is specified but the
383
- # parameter does not match an existing interface,
384
- # CURLE_INTERFACE_FAILED is returned.
385
- # @option options :keypasswd [String]
386
- # Pass a pointer to a zero terminated string as parameter. It will be
387
- # used as the password required to use the CURLOPT_SSLKEY or
388
- # CURLOPT_SSH_PRIVATE_KEYFILE private key. You never needed a pass
389
- # phrase to load a certificate but you need one to load your private key.
390
- # (This option was known as CURLOPT_SSLKEYPASSWD up to 7.16.4 and
391
- # CURLOPT_SSLCERTPASSWD up to 7.9.2)
392
- # @option options :maxredirs [Integer]
393
- # Pass a long. The set number will be the redirection limit. If that
394
- # many redirections have been followed, the next redirect will cause an
395
- # error (CURLE_TOO_MANY_REDIRECTS). This option only makes sense if the
396
- # CURLOPT_FOLLOWLOCATION is used at the same time. Added in 7.15.1:
397
- # Setting the limit to 0 will make libcurl refuse any redirect. Set it
398
- # to -1 for an infinite number of redirects (which is the default)
399
- # @option options :nobody [Boolean]
400
- # A parameter set to 1 tells the library to not include the body-part
401
- # in the output. This is only relevant for protocols that have separate
402
- # header and body parts. On HTTP(S) servers, this will make libcurl do
403
- # a HEAD request.
404
- # To change request to GET, you should use CURLOPT_HTTPGET. Change
405
- # request to POST with CURLOPT_POST etc.
406
- # @option options :nosignal [Boolean]
407
- # Pass a long. If it is 1, libcurl will not use any functions that
408
- # install signal handlers or any functions that cause signals to be
409
- # sent to the process. This option is mainly here to allow
410
- # multi-threaded unix applications to still set/use all timeout options
411
- # etc, without risking getting signals. (Added in 7.10)
412
- # If this option is set and libcurl has been built with the standard
413
- # name resolver, timeouts will not occur while the name resolve takes
414
- # place. Consider building libcurl with c-ares support to enable
415
- # asynchronous DNS lookups, which enables nice timeouts for name
416
- # resolves without signals.
417
- # Setting CURLOPT_NOSIGNAL to 1 makes libcurl NOT ask the system to
418
- # ignore SIGPIPE signals, which otherwise are sent by the system when
419
- # trying to send data to a socket which is closed in the other end.
420
- # libcurl makes an effort to never cause such SIGPIPEs to trigger, but
421
- # some operating systems have no way to avoid them and even on those
422
- # that have there are some corner cases when they may still happen,
423
- # contrary to our desire. In addition, using CURLAUTH_NTLM_WB
424
- # authentication could cause a SIGCHLD signal to be raised.
425
- # @option options :postfieldsize [Integer]
426
- # If you want to post data to the server without letting libcurl do a
427
- # strlen() to measure the data size, this option must be used. When
428
- # this option is used you can post fully binary data, which otherwise
429
- # is likely to fail. If this size is set to -1, the library will use
430
- # strlen() to get the size.
431
- # @option options :proxy [String]
432
- # Set HTTP proxy to use. The parameter should be a char * to a zero
433
- # terminated string holding the host name or dotted IP address. To
434
- # specify port number in this string, append :[port] to the end of the
435
- # host name. The proxy string may be prefixed with [protocol]:// since
436
- # any such prefix will be ignored. The proxy's port number may
437
- # optionally be specified with the separate option. If not specified,
438
- # libcurl will default to using port 1080 for proxies.
439
- # CURLOPT_PROXYPORT.
440
- # When you tell the library to use a HTTP proxy, libcurl will
441
- # transparently convert operations to HTTP even if you specify an FTP
442
- # URL etc. This may have an impact on what other features of the
443
- # library you can use, such as CURLOPT_QUOTE and similar FTP specifics
444
- # that don't work unless you tunnel through the HTTP proxy. Such
445
- # tunneling is activated with CURLOPT_HTTPPROXYTUNNEL.
446
- # libcurl respects the environment variables http_proxy, ftp_proxy,
447
- # all_proxy etc, if any of those are set. The CURLOPT_PROXY option does
448
- # however override any possibly set environment variables.
449
- # Setting the proxy string to "" (an empty string) will explicitly
450
- # disable the use of a proxy, even if there is an environment variable
451
- # set for it.
452
- # Since 7.14.1, the proxy host string given in environment variables
453
- # can be specified the exact same way as the proxy can be set with
454
- # CURLOPT_PROXY, include protocol prefix (http://) and embedded user +
455
- # password.
456
- # Since 7.21.7, the proxy string may be specified with a protocol://
457
- # prefix to specify alternative proxy protocols. Use socks4://,
458
- # socks4a://, socks5:// or socks5h:// (the last one to enable socks5
459
- # and asking the proxy to do the resolving, also known as
460
- # CURLPROXY_SOCKS5_HOSTNAME type) to request the specific SOCKS version
461
- # to be used. No protocol specified, http:// and all others will be
462
- # treated as HTTP proxies.
463
- # @option options :proxyauth [String]
464
- # Pass a long as parameter, which is set to a bitmask, to tell libcurl
465
- # which authentication method(s) you want it to use for your proxy
466
- # authentication. If more than one bit is set, libcurl will first query
467
- # the site to see what authentication methods it supports and then pick
468
- # the best one you allow it to use. For some methods, this will induce
469
- # an extra network round-trip. Set the actual name and password with
470
- # the CURLOPT_PROXYUSERPWD option. The bitmask can be constructed by
471
- # or'ing together the bits listed above for the CURLOPT_HTTPAUTH
472
- # option. As of this writing, only Basic, Digest and NTLM work. (Added
473
- # in 7.10.7)
474
- # @option options :proxytype [String]
475
- # Pass a long with this option to set type of the proxy. Available
476
- # options for this are CURLPROXY_HTTP, CURLPROXY_HTTP_1_0 (added in
477
- # 7.19.4), CURLPROXY_SOCKS4 (added in 7.10), CURLPROXY_SOCKS5,
478
- # CURLPROXY_SOCKS4A (added in 7.18.0) and CURLPROXY_SOCKS5_HOSTNAME
479
- # (added in 7.18.0). The HTTP type is default. (Added in 7.10)
480
- # If you set CURLOPT_PROXYTYPE to CURLPROXY_HTTP_1_0, it will only
481
- # affect how libcurl speaks to a proxy when CONNECT is used. The HTTP
482
- # version used for "regular" HTTP requests is instead controlled with
483
- # CURLOPT_HTTP_VERSION.
484
- # @option options :proxyport [Integer]
485
- # Pass a long with this option to set the proxy port to connect to
486
- # unless it is specified in the proxy string CURLOPT_PROXY.
487
- # @option options :proxyuserpwd [String]
488
- # Pass a char * as parameter, which should be [user name]:[password]
489
- # to use for the connection to the HTTP proxy. Use CURLOPT_PROXYAUTH
490
- # to decide the authentication method.
491
- # @option options :readdata [String]
492
- # Data pointer to pass to the file read function. If you use the
493
- # CURLOPT_READFUNCTION option, this is the pointer you'll get as input.
494
- # If you don't specify a read callback but instead rely on the default
495
- # internal read function, this data must be a valid readable FILE *.
496
- # If you're using libcurl as a win32 DLL, you MUST use a
497
- # CURLOPT_READFUNCTION if you set this option.
498
- # This option was also known by the older name CURLOPT_INFILE,
499
- # the name CURLOPT_READDATA was introduced in 7.9.7.
500
- # @option options :readfunction [String]
501
- # Pass a pointer to a function that matches the following prototype:
502
- # size_t function( void *ptr, size_t size, size_t nmemb, void
503
- # *userdata); This function gets called by libcurl as soon as it needs
504
- # to read data in order to send it to the peer. The data area pointed
505
- # at by the pointer ptr may be filled with at most size multiplied with
506
- # nmemb number of bytes. Your function must return the actual number of
507
- # bytes that you stored in that memory area. Returning 0 will signal
508
- # end-of-file to the library and cause it to stop the current transfer.
509
- # If you stop the current transfer by returning 0 "pre-maturely" (i.e
510
- # before the server expected it, like when you've said you will upload
511
- # N bytes and you upload less than N bytes), you may experience that
512
- # the server "hangs" waiting for the rest of the data that won't come.
513
- # The read callback may return CURL_READFUNC_ABORT to stop the current
514
- # operation immediately, resulting in a CURLE_ABORTED_BY_CALLBACK error
515
- # code from the transfer (Added in 7.12.1)
516
- # From 7.18.0, the function can return CURL_READFUNC_PAUSE which then
517
- # will cause reading from this connection to become paused. See
518
- # curl_easy_pause(3) for further details.
519
- # Bugs: when doing TFTP uploads, you must return the exact amount of
520
- # data that the callback wants, or it will be considered the final
521
- # packet by the server end and the transfer will end there.
522
- # If you set this callback pointer to NULL, or don't set it at all, the
523
- # default internal read function will be used. It is doing an fread()
524
- # on the FILE * userdata set with CURLOPT_READDATA.
525
- # @option options :ssl_verifyhost [Integer]
526
- # Pass a long as parameter.
527
- # This option determines whether libcurl verifies that the server cert
528
- # is for the server it is known as.
529
- # When negotiating a SSL connection, the server sends a certificate
530
- # indicating its identity.
531
- # When CURLOPT_SSL_VERIFYHOST is 2, that certificate must indicate that
532
- # the server is the server to which you meant to connect, or the
533
- # connection fails.
534
- # Curl considers the server the intended one when the Common Name field
535
- # or a Subject Alternate Name field in the certificate matches the host
536
- # name in the URL to which you told Curl to connect.
537
- # When the value is 1, the certificate must contain a Common Name
538
- # field, but it doesn't matter what name it says. (This is not
539
- # ordinarily a useful setting).
540
- # When the value is 0, the connection succeeds regardless of the names
541
- # in the certificate.
542
- # The default value for this option is 2.
543
- # This option controls checking the server's certificate's claimed
544
- # identity. The server could be lying. To control lying, see
545
- # CURLOPT_SSL_VERIFYPEER. If libcurl is built against NSS and
546
- # CURLOPT_SSL_VERIFYPEER is zero, CURLOPT_SSL_VERIFYHOST is ignored.
547
- # @option options :ssl_verifypeer [Boolean]
548
- # Pass a long as parameter. By default, curl assumes a value of 1.
549
- # This option determines whether curl verifies the authenticity of the
550
- # peer's certificate. A value of 1 means curl verifies; 0 (zero) means
551
- # it doesn't.
552
- # When negotiating a SSL connection, the server sends a certificate
553
- # indicating its identity. Curl verifies whether the certificate is
554
- # authentic, i.e. that you can trust that the server is who the
555
- # certificate says it is. This trust is based on a chain of digital
556
- # signatures, rooted in certification authority (CA) certificates you
557
- # supply. curl uses a default bundle of CA certificates (the path for
558
- # that is determined at build time) and you can specify alternate
559
- # certificates with the CURLOPT_CAINFO option or the CURLOPT_CAPATH
560
- # option.
561
- # When CURLOPT_SSL_VERIFYPEER is nonzero, and the verification fails to
562
- # prove that the certificate is authentic, the connection fails. When
563
- # the option is zero, the peer certificate verification succeeds
564
- # regardless.
565
- # Authenticating the certificate is not by itself very useful. You
566
- # typically want to ensure that the server, as authentically identified
567
- # by its certificate, is the server you mean to be talking to. Use
568
- # CURLOPT_SSL_VERIFYHOST to control that. The check that the host name
569
- # in the certificate is valid for the host name you're connecting to is
570
- # done independently of the CURLOPT_SSL_VERIFYPEER option.
571
- # @option options :sslcert [String]
572
- # Pass a pointer to a zero terminated string as parameter. The string
573
- # should be the file name of your certificate. The default format is
574
- # "PEM" and can be changed with CURLOPT_SSLCERTTYPE.
575
- # With NSS this can also be the nickname of the certificate you wish to
576
- # authenticate with. If you want to use a file from the current
577
- # directory, please precede it with "./" prefix, in order to avoid
578
- # confusion with a nickname.
579
- # @option options :sslcerttype [String]
580
- # Pass a pointer to a zero terminated string as parameter. The string
581
- # should be the format of your certificate. Supported formats are "PEM"
582
- # and "DER". (Added in 7.9.3)
583
- # @option options :sslkey [String]
584
- # Pass a pointer to a zero terminated string as parameter. The string
585
- # should be the file name of your private key. The default format is
586
- # "PEM" and can be changed with CURLOPT_SSLKEYTYPE.
587
- # @option options :sslkeytype [String]
588
- # Pass a pointer to a zero terminated string as parameter. The string
589
- # should be the format of your private key. Supported formats are
590
- # "PEM", "DER" and "ENG".
591
- # The format "ENG" enables you to load the private key from a crypto
592
- # engine. In this case CURLOPT_SSLKEY is used as an identifier passed
593
- # to the engine. You have to set the crypto engine with
594
- # CURLOPT_SSLENGINE. "DER" format key file currently does not work
595
- # because of a bug in OpenSSL.
596
- # @option options :sslversion [String]
597
- # Pass a long as parameter to control what version of SSL/TLS to
598
- # attempt to use. The available options are:
599
- # @option options :timeout [Integer]
600
- # Pass a long as parameter containing the maximum time in seconds that
601
- # you allow the libcurl transfer operation to take. Normally, name
602
- # lookups can take a considerable time and limiting operations to less
603
- # than a few minutes risk aborting perfectly normal operations. This
604
- # option will cause curl to use the SIGALRM to enable time-outing
605
- # system calls.
606
- # In unix-like systems, this might cause signals to be used unless
607
- # CURLOPT_NOSIGNAL is set.
608
- # Default timeout is 0 (zero) which means it never times out.
609
- # @option options :timeout_ms [Integer]
610
- # Like CURLOPT_TIMEOUT but takes number of milliseconds instead. If
611
- # libcurl is built to use the standard system name resolver, that
612
- # portion of the transfer will still use full-second resolution for
613
- # timeouts with a minimum timeout allowed of one second. (Added in
614
- # 7.16.2)
615
- # @option options :upload [Boolean]
616
- # A parameter set to 1 tells the library to prepare for an upload. The
617
- # CURLOPT_READDATA and CURLOPT_INFILESIZE or CURLOPT_INFILESIZE_LARGE
618
- # options are also interesting for uploads. If the protocol is HTTP,
619
- # uploading means using the PUT request unless you tell libcurl
620
- # otherwise.
621
- # Using PUT with HTTP 1.1 implies the use of a "Expect: 100-continue"
622
- # header. You can disable this header with CURLOPT_HTTPHEADER as usual.
623
- # If you use PUT to a HTTP 1.1 server, you can upload data without
624
- # knowing the size before starting the transfer if you use chunked
625
- # encoding. You enable this by adding a header like "Transfer-Encoding:
626
- # chunked" with CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked
627
- # transfer, you must specify the size.
628
- # @option options :url [String]
629
- # Pass in a pointer to the actual URL to deal with. The parameter
630
- # should be a char * to a zero terminated string which must be
631
- # URL-encoded in the following format:
632
- # scheme://host:port/path
633
- # For a greater explanation of the format please see RFC 3986.
634
- # If the given URL lacks the scheme, or protocol, part ("http://" or
635
- # "ftp://" etc), libcurl will attempt to resolve which protocol to use
636
- # based on the given host mame. If the protocol is not supported,
637
- # libcurl will return (CURLE_UNSUPPORTED_PROTOCOL) when you call
638
- # curl_easy_perform(3) or curl_multi_perform(3). Use
639
- # curl_version_info(3) for detailed information on which protocols are
640
- # supported.
641
- # The host part of the URL contains the address of the server that you
642
- # want to connect to. This can be the fully qualified domain name of
643
- # the server, the local network name of the machine on your network or
644
- # the IP address of the server or machine represented by either an IPv4
645
- # or IPv6 address. For example:
646
- # http://www.example.com/
647
- # http://hostname/
648
- # http://192.168.0.1/
649
- # http://[2001:1890:1112:1::20]/
650
- # It is also possible to specify the user name and password as part of
651
- # the host, for some protocols, when connecting to servers that require
652
- # authentication.
653
- # For example the following types of authentication support this:
654
- # http://user:password@www.example.com
655
- # ftp://user:password@ftp.example.com
656
- # pop3://user:password@mail.example.com
657
- # The port is optional and when not specified libcurl will use the
658
- # default port based on the determined or specified protocol: 80 for
659
- # HTTP, 21 for FTP and 25 for SMTP, etc. The following examples show
660
- # how to specify the port:
661
- # http://www.example.com:8080/ - This will connect to a web server
662
- # using port 8080 rather than 80.
663
- # smtp://mail.example.com:587/ - This will connect to a SMTP server on
664
- # the alternative mail port.
665
- # The path part of the URL is protocol specific and whilst some
666
- # examples are given below this list is not conclusive:
667
- # HTTP
668
- # The path part of a HTTP request specifies the file to retrieve and
669
- # from what directory. If the directory is not specified then the web
670
- # server's root directory is used. If the file is omitted then the
671
- # default document will be retrieved for either the directory specified
672
- # or the root directory. The exact resource returned for each URL is
673
- # entirely dependent on the server's configuration.
674
- # http://www.example.com - This gets the main page from the web server.
675
- # http://www.example.com/index.html - This returns the main page by
676
- # explicitly requesting it.
677
- # http://www.example.com/contactus/ - This returns the default document
678
- # from the contactus directory.
679
- # FTP
680
- # The path part of an FTP request specifies the file to retrieve and
681
- # from what directory. If the file part is omitted then libcurl
682
- # downloads the directory listing for the directory specified. If the
683
- # directory is omitted then the directory listing for the root / home
684
- # directory will be returned.
685
- # ftp://ftp.example.com - This retrieves the directory listing for the
686
- # root directory.
687
- # ftp://ftp.example.com/readme.txt - This downloads the file readme.txt
688
- # from the root directory.
689
- # ftp://ftp.example.com/libcurl/readme.txt - This downloads readme.txt
690
- # from the libcurl directory.
691
- # ftp://user:password@ftp.example.com/readme.txt - This retrieves the
692
- # readme.txt file from the user's home directory. When a username and
693
- # password is specified, everything that is specified in the path part
694
- # is relative to the user's home directory. To retrieve files from the
695
- # root directory or a directory underneath the root directory then the
696
- # absolute path must be specified by prepending an additional forward
697
- # slash to the beginning of the path.
698
- # ftp://user:password@ftp.example.com//readme.txt - This retrieves the
699
- # readme.txt from the root directory when logging in as a specified
700
- # user.
701
- # SMTP
702
- # The path part of a SMTP request specifies the host name to present
703
- # during communication with the mail server. If the path is omitted
704
- # then libcurl will attempt to resolve the local computer's host name.
705
- # However, this may not return the fully qualified domain name that is
706
- # required by some mail servers and specifying this path allows you to
707
- # set an alternative name, such as your machine's fully qualified
708
- # domain name, which you might have obtained from an external function
709
- # such as gethostname or getaddrinfo.
710
- # smtp://mail.example.com - This connects to the mail server at
711
- # example.com and sends your local computer's host name in the HELO /
712
- # EHLO command.
713
- # smtp://mail.example.com/client.example.com - This will send
714
- # client.example.com in the HELO / EHLO command to the mail server at
715
- # example.com.
716
- # POP3
717
- # The path part of a POP3 request specifies the mailbox (message) to
718
- # retrieve. If the mailbox is not specified then a list of waiting
719
- # messages is returned instead.
720
- # pop3://user:password@mail.example.com - This lists the available
721
- # messages pop3://user:password@mail.example.com/1 - This retrieves the
722
- # first message
723
- # SCP
724
- # The path part of a SCP request specifies the file to retrieve and
725
- # from what directory. The file part may not be omitted. The file is
726
- # taken as an absolute path from the root directory on the server. To
727
- # specify a path relative to the user's home directory on the server,
728
- # prepend ~/ to the path portion. If the user name is not embedded in
729
- # the URL, it can be set with the CURLOPT_USERPWD or CURLOPT_USERNAME
730
- # option.
731
- # scp://user@example.com/etc/issue - This specifies the file /etc/issue
732
- # scp://example.com/~/my-file - This specifies the file my-file in the
733
- # user's home directory on the server
734
- # SFTP
735
- # The path part of a SFTP request specifies the file to retrieve and
736
- # from what directory. If the file part is omitted then libcurl
737
- # downloads the directory listing for the directory specified. If the
738
- # path ends in a / then a directory listing is returned instead of a
739
- # file. If the path is omitted entirely then the directory listing for
740
- # the root / home directory will be returned. If the user name is not
741
- # embedded in the URL, it can be set with the CURLOPT_USERPWD or
742
- # CURLOPT_USERNAME option.
743
- # sftp://user:password@example.com/etc/issue - This specifies the file
744
- # /etc/issue
745
- # sftp://user@example.com/~/my-file - This specifies the file my-file
746
- # in the user's home directory
747
- # sftp://ssh.example.com/~/Documents/ - This requests a directory
748
- # listing of the Documents directory under the user's home directory
749
- # LDAP
750
- # The path part of a LDAP request can be used to specify the:
751
- # Distinguished Name, Attributes, Scope, Filter and Extension for a
752
- # LDAP search. Each field is separated by a question mark and when that
753
- # field is not required an empty string with the question mark
754
- # separator should be included.
755
- # ldap://ldap.example.com/o=My%20Organisation - This will perform a
756
- # LDAP search with the DN as My Organisation.
757
- # ldap://ldap.example.com/o=My%20Organisation?postalAddress - This will
758
- # perform the same search but will only return postalAddress attributes.
759
- # ldap://ldap.example.com/?rootDomainNamingContext - This specifies an
760
- # empty DN and requests information about the rootDomainNamingContext
761
- # attribute for an Active Directory server.
762
- # For more information about the individual components of a LDAP URL
763
- # please see RFC 4516.
764
- # NOTES
765
- # Starting with version 7.20.0, the fragment part of the URI will not
766
- # be sent as part of the path, which was previously the case.
767
- # CURLOPT_URL is the only option that must be set before
768
- # curl_easy_perform(3) is called.
769
- # CURLOPT_PROTOCOLS can be used to limit what protocols libcurl will
770
- # use for this transfer, independent of what libcurl has been compiled
771
- # to support. That may be useful if you accept the URL from an external
772
- # source and want to limit the accessibility.
773
- # @option options :useragent [String]
774
- # Pass a pointer to a zero terminated string as parameter. It will be
775
- # used to set the User-Agent: header in the http request sent to the
776
- # remote server. This can be used to fool servers or scripts. You can
777
- # also set any custom header with CURLOPT_HTTPHEADER.
778
- # @option options :userpwd [String]
779
- # Pass a char * as parameter, which should be [user name]:[password] to
780
- # use for the connection. Use CURLOPT_HTTPAUTH to decide the
781
- # authentication method.
782
- # When using NTLM, you can set the domain by prepending it to the user
783
- # name and separating the domain and name with a forward (/) or
784
- # backward slash (\). Like this: "domain/user:password" or
785
- # "domain\user:password". Some HTTP servers (on Windows) support this
786
- # style even for Basic authentication.
787
- # When using HTTP and CURLOPT_FOLLOWLOCATION, libcurl might perform
788
- # several requests to possibly different hosts. libcurl will only send
789
- # this user and password information to hosts using the initial host
790
- # name (unless CURLOPT_UNRESTRICTED_AUTH is set), so if libcurl follows
791
- # locations to other hosts it will not send the user and password to
792
- # those. This is enforced to prevent accidental information leakage.
793
- # @option options :verbose [Boolean]
794
- # Set the parameter to 1 to get the library to display a lot of verbose
795
- # information about its operations. Very useful for libcurl and/or
796
- # protocol debugging and understanding. The verbose information will be
797
- # sent to stderr, or the stream set with CURLOPT_STDERR.
798
- # You hardly ever want this set in production use, you will almost
799
- # always want this when you debug/report problems. Another neat option
800
- # for debugging is the CURLOPT_DEBUGFUNCTION.
228
+ # @option options :headers [ Hash ] Request headers.
801
229
  #
802
230
  # @return [ Easy ] A new Easy.
803
231
  #
232
+ # @see Ethon::Easy::Options
804
233
  # @see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
805
- #
806
- # @api public
807
234
  def initialize(options = {})
808
235
  Curl.init
809
236
  ObjectSpace.define_finalizer(self, self.class.finalizer(self))
@@ -821,8 +248,6 @@ module Ethon
821
248
  # @raise InvalidOption
822
249
  #
823
250
  # @see initialize
824
- #
825
- # @api private
826
251
  def set_attributes(options)
827
252
  options.each_pair do |key, value|
828
253
  unless respond_to?("#{key}=")