ethon 0.5.12 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +11 -0
  5. data/CHANGELOG.md +5 -0
  6. data/Gemfile +1 -1
  7. data/Guardfile +9 -0
  8. data/ethon.gemspec +26 -0
  9. data/lib/ethon/curl.rb +0 -12
  10. data/lib/ethon/curls/constants.rb +6 -22
  11. data/lib/ethon/curls/functions.rb +38 -41
  12. data/lib/ethon/curls/infos.rb +19 -0
  13. data/lib/ethon/curls/options.rb +416 -219
  14. data/lib/ethon/curls/settings.rb +1 -0
  15. data/lib/ethon/easy.rb +12 -18
  16. data/lib/ethon/easy/callbacks.rb +40 -6
  17. data/lib/ethon/easy/debug_info.rb +46 -0
  18. data/lib/ethon/easy/mirror.rb +39 -0
  19. data/lib/ethon/easy/options.rb +17 -1235
  20. data/lib/ethon/easy/queryable.rb +6 -8
  21. data/lib/ethon/easy/response_callbacks.rb +1 -1
  22. data/lib/ethon/version.rb +1 -1
  23. data/profile/benchmarks.rb +137 -0
  24. data/profile/memory_leaks.rb +113 -0
  25. data/profile/perf_spec_helper.rb +36 -0
  26. data/profile/support/memory_test_helpers.rb +75 -0
  27. data/profile/support/os_memory_leak_tracker.rb +47 -0
  28. data/profile/support/ruby_object_leak_tracker.rb +48 -0
  29. data/spec/ethon/curl_spec.rb +27 -0
  30. data/spec/ethon/easy/callbacks_spec.rb +31 -0
  31. data/spec/ethon/easy/debug_info_spec.rb +52 -0
  32. data/spec/ethon/easy/form_spec.rb +76 -0
  33. data/spec/ethon/easy/header_spec.rb +78 -0
  34. data/spec/ethon/easy/http/custom_spec.rb +176 -0
  35. data/spec/ethon/easy/http/delete_spec.rb +20 -0
  36. data/spec/ethon/easy/http/get_spec.rb +89 -0
  37. data/spec/ethon/easy/http/head_spec.rb +79 -0
  38. data/spec/ethon/easy/http/options_spec.rb +50 -0
  39. data/spec/ethon/easy/http/patch_spec.rb +50 -0
  40. data/spec/ethon/easy/http/post_spec.rb +220 -0
  41. data/spec/ethon/easy/http/put_spec.rb +124 -0
  42. data/spec/ethon/easy/http_spec.rb +44 -0
  43. data/spec/ethon/easy/informations_spec.rb +82 -0
  44. data/spec/ethon/easy/mirror_spec.rb +39 -0
  45. data/spec/ethon/easy/operations_spec.rb +251 -0
  46. data/spec/ethon/easy/options_spec.rb +135 -0
  47. data/spec/ethon/easy/queryable_spec.rb +188 -0
  48. data/spec/ethon/easy/response_callbacks_spec.rb +50 -0
  49. data/spec/ethon/easy/util_spec.rb +27 -0
  50. data/spec/ethon/easy_spec.rb +105 -0
  51. data/spec/ethon/libc_spec.rb +13 -0
  52. data/spec/ethon/loggable_spec.rb +21 -0
  53. data/spec/ethon/multi/operations_spec.rb +297 -0
  54. data/spec/ethon/multi/options_spec.rb +70 -0
  55. data/spec/ethon/multi/stack_spec.rb +79 -0
  56. data/spec/ethon/multi_spec.rb +21 -0
  57. data/spec/spec_helper.rb +27 -0
  58. data/spec/support/localhost_server.rb +94 -0
  59. data/spec/support/server.rb +114 -0
  60. metadata +91 -31
  61. data/lib/ethon/curls/auth_types.rb +0 -25
  62. data/lib/ethon/curls/http_versions.rb +0 -22
  63. data/lib/ethon/curls/postredir.rb +0 -15
  64. data/lib/ethon/curls/protocols.rb +0 -36
  65. data/lib/ethon/curls/proxy_types.rb +0 -25
  66. data/lib/ethon/curls/ssl_versions.rb +0 -23
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2FhY2MzYTUzMTllNTk2ZTY4YWY4Y2ViOTA4OTg4ZTgxMTNhNzE2Mg==
5
+ data.tar.gz: !binary |-
6
+ OTI4MGQyMWFiZmVlOTRkY2FlODFmZWVlMDIyMmMwYWZmNWI0NmE1Zg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NDU2OTVmMmNlNjhhMjg3OTEzOWVkZjMyODBjMWMxYjg1NTI0OWIzZTA2ODBh
10
+ MjA4MjQ1NzQyMWY5MzJhNmRkYzQzNjdhNWJiNWMyZTk2NzcxZTU4ZDI1Mjdj
11
+ ZGZjYzYxMWU2ZWE0YzBiM2NkODVjNGQzYjFhMDQ1YThhMzYyMDY=
12
+ data.tar.gz: !binary |-
13
+ ZDcyNmY0MWZjYWMzNmM2Njk0Nzk1YTE4ZjY0ZDhjOWZlMzI1NzVhYTFkOGE1
14
+ OGU0Mzc1ODc0OGQzNTEwNzNmYWEwNGU1MmFjZGQ4ZDNhZTMxOTIxYzMxMjc3
15
+ MmZiYWIwMzU0NWJiN2ExNjhjMDhlNjMwZDM2NDBhZmI3ZDRjNzI=
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ .DS_Store
5
+ .yardoc
6
+ doc
7
+ coverage
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --tty
2
+ --color
3
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ script: "bundle exec rake"
2
+ bundler_args: --without perf
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - jruby-head
8
+ - jruby-18mode
9
+ - jruby-19mode
10
+ - rbx-18mode
11
+ - rbx-19mode
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.5.12...master)
6
6
 
7
+ Bugfixes:
8
+
9
+ * URL-encode nullbytes in parameters instead of escaping them to `\\0`.
10
+ ([Tasos Laskos](https://github.com/zapotek)
11
+
7
12
  ## 0.5.12
8
13
 
9
14
  [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.5.11...v0.5.12)
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gem "rake"
6
6
  group :development, :test do
7
7
  gem "rspec", "~> 2.11"
8
8
 
9
- gem "sinatra", git: "https://github.com/sinatra/sinatra.git"
9
+ gem "sinatra", :git => "https://github.com/sinatra/sinatra.git"
10
10
  gem "json"
11
11
 
12
12
  unless ENV["CI"]
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # vim:set filetype=ruby:
2
+ guard(
3
+ "rspec",
4
+ :all_after_pass => false,
5
+ :cli => "--fail-fast --tty --format documentation --colour") do
6
+
7
+ watch(%r{^spec/.+_spec\.rb$})
8
+ watch(%r{^lib/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" }
9
+ end
data/ethon.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $:.unshift lib unless $:.include?(lib)
4
+
5
+ require 'ethon/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "ethon"
9
+ s.version = Ethon::VERSION
10
+ s.platform = Gem::Platform::RUBY
11
+ s.authors = ["Hans Hasselberg"]
12
+ s.email = ["me@hans.io"]
13
+ s.homepage = "https://github.com/typhoeus/ethon"
14
+ s.summary = "Libcurl wrapper."
15
+ s.description = "Very lightweight libcurl wrapper."
16
+
17
+ s.required_rubygems_version = ">= 1.3.6"
18
+ s.rubyforge_project = '[none]'
19
+
20
+ s.add_dependency('ffi', ['>= 1.3.0'])
21
+ s.add_dependency('mime-types', ['~> 1.18'])
22
+
23
+ s.files = `git ls-files`.split("\n")
24
+ s.test_files = `git ls-files -- spec/*`.split("\n")
25
+ s.require_path = 'lib'
26
+ end
data/lib/ethon/curl.rb CHANGED
@@ -1,13 +1,7 @@
1
1
  require 'ethon/curls/codes'
2
2
  require 'ethon/curls/options'
3
- require 'ethon/curls/http_versions'
4
3
  require 'ethon/curls/infos'
5
4
  require 'ethon/curls/form_options'
6
- require 'ethon/curls/auth_types'
7
- require 'ethon/curls/postredir'
8
- require 'ethon/curls/protocols'
9
- require 'ethon/curls/proxy_types'
10
- require 'ethon/curls/ssl_versions'
11
5
  require 'ethon/curls/messages'
12
6
  require 'ethon/curls/functions'
13
7
 
@@ -20,15 +14,9 @@ module Ethon
20
14
  extend ::FFI::Library
21
15
  extend Ethon::Curls::Codes
22
16
  extend Ethon::Curls::Options
23
- extend Ethon::Curls::HttpVersions
24
17
  extend Ethon::Curls::Infos
25
18
  extend Ethon::Curls::FormOptions
26
- extend Ethon::Curls::AuthTypes
27
- extend Ethon::Curls::ProxyTypes
28
- extend Ethon::Curls::SslVersions
29
19
  extend Ethon::Curls::Messages
30
- extend Ethon::Curls::Protocols
31
- extend Ethon::Curls::Postredir
32
20
 
33
21
  # :nodoc:
34
22
  def self.windows?
@@ -18,11 +18,13 @@ module Ethon
18
18
  MultiCode = enum(:multi_code, multi_codes)
19
19
 
20
20
  # :nodoc:
21
- EasyOption = enum(:easy_option, easy_options.to_a.flatten)
21
+ EasyOption = enum(:easy_option, easy_options(:enum).to_a.flatten)
22
22
  # :nodoc:
23
- MultiOption = enum(:multi_option, multi_options.to_a.flatten)
24
- # :nodoc:
25
- OptionType = enum(option_types.to_a.flatten)
23
+ MultiOption = enum(:multi_option, multi_options(:enum).to_a.flatten)
24
+
25
+ # Used by curl_debug_callback when setting CURLOPT_DEBUGFUNCTION
26
+ # https://github.com/bagder/curl/blob/master/include/curl/curl.h#L378 for details
27
+ DebugInfoType = enum(:debug_info_type, debug_info_types)
26
28
 
27
29
  # :nodoc:
28
30
  InfoType = enum(info_types.to_a.flatten)
@@ -35,24 +37,6 @@ module Ethon
35
37
  # https://github.com/bagder/curl/blob/master/lib/formdata.h#L51 for details
36
38
  FormOption = enum(:form_option, form_options)
37
39
 
38
- # :nodoc:
39
- Auth = enum(auth_types.to_a.flatten)
40
-
41
- # :nodoc:
42
- Postredir = enum(postredir.to_a.flatten)
43
-
44
- # :nodoc:
45
- Protocols = enum(protocols.to_a.flatten)
46
-
47
- # :nodoc:
48
- Proxy = enum(proxy_types.to_a.flatten)
49
-
50
- # :nodoc:
51
- SSLVersion = enum(ssl_versions.to_a.flatten)
52
-
53
- # :nodoc:
54
- HTTPVersion = enum(http_versions.to_a.flatten)
55
-
56
40
  # :nodoc:
57
41
  MsgCode = enum(:msg_code, msg_codes)
58
42
  end
@@ -7,48 +7,45 @@ module Ethon
7
7
 
8
8
  # :nodoc:
9
9
  def self.extended(base)
10
- base.attach_function :global_init, :curl_global_init, [:long], :int
11
- base.attach_function :free, :curl_free, [:pointer], :void
12
-
13
- base.attach_function :easy_init, :curl_easy_init, [], :pointer
14
- base.attach_function :easy_cleanup, :curl_easy_cleanup, [:pointer], :void
15
- base.attach_function :easy_getinfo, :curl_easy_getinfo, [:pointer, :info, :pointer], :easy_code
16
- base.attach_function :easy_setopt, :curl_easy_setopt, [:pointer, :easy_option, :pointer], :easy_code
17
- base.attach_function :easy_setopt_ffipointer, :curl_easy_setopt, [:pointer, :easy_option, :pointer], :easy_code
18
- base.attach_function :easy_setopt_string, :curl_easy_setopt, [:pointer, :easy_option, :string], :easy_code
19
- base.attach_function :easy_setopt_long, :curl_easy_setopt, [:pointer, :easy_option, :long], :easy_code
20
- base.attach_function :easy_setopt_fixnum, :curl_easy_setopt, [:pointer, :easy_option, :long], :easy_code
21
- base.attach_function :easy_setopt_callback, :curl_easy_setopt, [:pointer, :easy_option, :callback], :easy_code
22
- base.attach_function :easy_setopt_proc, :curl_easy_setopt, [:pointer, :easy_option, :callback], :easy_code
10
+ base.attach_function :global_init, :curl_global_init, [:long], :int
11
+ base.attach_function :free, :curl_free, [:pointer], :void
12
+
13
+ base.attach_function :easy_init, :curl_easy_init, [], :pointer
14
+ base.attach_function :easy_cleanup, :curl_easy_cleanup, [:pointer], :void
15
+ base.attach_function :easy_getinfo, :curl_easy_getinfo, [:pointer, :info, :pointer], :easy_code
16
+ base.attach_function :easy_setopt_ffipointer, :curl_easy_setopt, [:pointer, :easy_option, :pointer], :easy_code
17
+ base.attach_function :easy_setopt_string, :curl_easy_setopt, [:pointer, :easy_option, :string], :easy_code
18
+ base.attach_function :easy_setopt_long, :curl_easy_setopt, [:pointer, :easy_option, :long], :easy_code
19
+ base.attach_function :easy_setopt_callback, :curl_easy_setopt, [:pointer, :easy_option, :callback], :easy_code
20
+ base.attach_function :easy_setopt_debug_callback, :curl_easy_setopt, [:pointer, :easy_option, :debug_callback], :easy_code
21
+ base.attach_function :easy_setopt_off_t, :curl_easy_setopt, [:pointer, :easy_option, :int64], :easy_code
23
22
  base.instance_variable_set(:@blocking, true)
24
- base.attach_function :easy_perform, :curl_easy_perform, [:pointer], :easy_code
25
- base.attach_function :easy_strerror, :curl_easy_strerror, [:int], :string
26
- base.attach_function :easy_escape, :curl_easy_escape, [:pointer, :pointer, :int], :pointer
27
- base.attach_function :easy_reset, :curl_easy_reset, [:pointer], :void
28
-
29
- base.attach_function :formadd, :curl_formadd, [:pointer, :pointer, :varargs], :int
30
- base.attach_function :formfree, :curl_formfree, [:pointer], :void
31
-
32
- base.attach_function :multi_init, :curl_multi_init, [], :pointer
33
- base.attach_function :multi_cleanup, :curl_multi_cleanup, [:pointer], :void
34
- base.attach_function :multi_add_handle, :curl_multi_add_handle, [:pointer, :pointer], :multi_code
35
- base.attach_function :multi_remove_handle, :curl_multi_remove_handle, [:pointer, :pointer], :multi_code
36
- base.attach_function :multi_info_read, :curl_multi_info_read, [:pointer, :pointer], Curl::Msg.ptr
37
- base.attach_function :multi_perform, :curl_multi_perform, [:pointer, :pointer], :multi_code
38
- base.attach_function :multi_timeout, :curl_multi_timeout, [:pointer, :pointer], :multi_code
39
- base.attach_function :multi_fdset, :curl_multi_fdset, [:pointer, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::FDSet.ptr, :pointer], :multi_code
40
- base.attach_function :multi_strerror, :curl_multi_strerror, [:int], :string
41
- base.attach_function :multi_setopt, :curl_multi_setopt, [:pointer, :multi_option, :pointer], :multi_code
42
- base.attach_function :multi_setopt_ffipointer,:curl_multi_setopt, [:pointer, :multi_option, :pointer], :multi_code
43
- base.attach_function :multi_setopt_string, :curl_multi_setopt, [:pointer, :multi_option, :string], :multi_code
44
- base.attach_function :multi_setopt_long, :curl_multi_setopt, [:pointer, :multi_option, :long], :multi_code
45
- base.attach_function :multi_setopt_fixnum, :curl_multi_setopt, [:pointer, :multi_option, :long], :multi_code
46
- base.attach_function :multi_setopt_callback, :curl_multi_setopt, [:pointer, :multi_option, :callback], :multi_code
47
- base.attach_function :multi_setopt_proc, :curl_multi_setopt, [:pointer, :multi_option, :callback], :multi_code
48
-
49
- base.attach_function :version, :curl_version, [], :string
50
- base.attach_function :slist_append, :curl_slist_append, [:pointer, :string], :pointer
51
- base.attach_function :slist_free_all, :curl_slist_free_all, [:pointer], :void
23
+ base.attach_function :easy_perform, :curl_easy_perform, [:pointer], :easy_code
24
+ base.attach_function :easy_strerror, :curl_easy_strerror, [:int], :string
25
+ base.attach_function :easy_escape, :curl_easy_escape, [:pointer, :pointer, :int], :pointer
26
+ base.attach_function :easy_reset, :curl_easy_reset, [:pointer], :void
27
+
28
+ base.attach_function :formadd, :curl_formadd, [:pointer, :pointer, :varargs], :int
29
+ base.attach_function :formfree, :curl_formfree, [:pointer], :void
30
+
31
+ base.attach_function :multi_init, :curl_multi_init, [], :pointer
32
+ base.attach_function :multi_cleanup, :curl_multi_cleanup, [:pointer], :void
33
+ base.attach_function :multi_add_handle, :curl_multi_add_handle, [:pointer, :pointer], :multi_code
34
+ base.attach_function :multi_remove_handle, :curl_multi_remove_handle, [:pointer, :pointer], :multi_code
35
+ base.attach_function :multi_info_read, :curl_multi_info_read, [:pointer, :pointer], Curl::Msg.ptr
36
+ base.attach_function :multi_perform, :curl_multi_perform, [:pointer, :pointer], :multi_code
37
+ base.attach_function :multi_timeout, :curl_multi_timeout, [:pointer, :pointer], :multi_code
38
+ base.attach_function :multi_fdset, :curl_multi_fdset, [:pointer, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::FDSet.ptr, :pointer], :multi_code
39
+ base.attach_function :multi_strerror, :curl_multi_strerror, [:int], :string
40
+ base.attach_function :multi_setopt_ffipointer, :curl_multi_setopt, [:pointer, :multi_option, :pointer], :multi_code
41
+ base.attach_function :multi_setopt_string, :curl_multi_setopt, [:pointer, :multi_option, :string], :multi_code
42
+ base.attach_function :multi_setopt_long, :curl_multi_setopt, [:pointer, :multi_option, :long], :multi_code
43
+ base.attach_function :multi_setopt_callback, :curl_multi_setopt, [:pointer, :multi_option, :callback], :multi_code
44
+ base.attach_function :multi_setopt_off_t, :curl_multi_setopt, [:pointer, :multi_option, :int64], :multi_code
45
+
46
+ base.attach_function :version, :curl_version, [], :string
47
+ base.attach_function :slist_append, :curl_slist_append, [:pointer, :string], :pointer
48
+ base.attach_function :slist_free_all, :curl_slist_free_all, [:pointer], :void
52
49
  base.instance_variable_set(:@blocking, true)
53
50
 
54
51
  if Curl.windows?
@@ -20,6 +20,25 @@ module Ethon
20
20
  }
21
21
  end
22
22
 
23
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTDEBUGFUNCTION
24
+ # https://github.com/bagder/curl/blob/master/include/curl/curl.h#L378
25
+ #
26
+ # @example Return debug info types.
27
+ # Ethon::Curl.debug_info_types
28
+ #
29
+ # @return [ Hash ] The info types available to curl_debug_callback.
30
+ def debug_info_types
31
+ [
32
+ :text, 0,
33
+ :header_in,
34
+ :header_out,
35
+ :data_in,
36
+ :data_out,
37
+ :ssl_data_in,
38
+ :ssl_data_out
39
+ ]
40
+ end
41
+
23
42
  # Return Info details, refer
24
43
  # https://github.com/bagder/curl/blob/master/src/tool_writeout.c#L66 for details
25
44
  #
@@ -7,233 +7,430 @@ module Ethon
7
7
 
8
8
  # Sets appropriate option for easy, depending on value type.
9
9
  def set_option(option, value, handle, type = :easy)
10
- return unless value
10
+ raise NameError, "Ethon::Curls::Options unknown type #{type}." unless respond_to?("#{type.to_s.downcase}_options")
11
+ opthash=send("#{type.to_s.downcase}_options")
12
+ raise Errors::InvalidOption.new(option) unless opthash.include?(option)
13
+
14
+ case opthash[option][:type]
15
+ when :none
16
+ return if value.nil?
17
+ value=1
18
+ func=:long
19
+ when :int
20
+ return if value.nil?
21
+ func=:long
22
+ value=value.to_i
23
+ when :bool
24
+ return if value.nil?
25
+ func=:long
26
+ value=(value&&value!=0) ? 1 : 0
27
+ when :time
28
+ return if value.nil?
29
+ func=:long
30
+ value=value.to_i
31
+ when :enum
32
+ return if value.nil?
33
+ func=:long
34
+ value=opthash[option][:opts][value] if value.is_a? Symbol
35
+ value=value.to_i
36
+ when :bitmask
37
+ return if value.nil?
38
+ func=:long
39
+ value=opthash[option][:opts][value] if value.is_a? Symbol
40
+ value=value.inject(0) { |res,v| res|opthash[option][:opts][v] } if value.is_a? Array
41
+ value=value.to_i
42
+ when :string
43
+ func=:string
44
+ value=value.to_s unless value.nil?
45
+ when :string_escape_null
46
+ func=:string
47
+ value=Util.escape_zero_byte(value) unless value.nil?
48
+ when :ffipointer
49
+ func=:ffipointer
50
+ raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? FFI::Pointer
51
+ when :curl_slist
52
+ func=:ffipointer
53
+ raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? FFI::Pointer
54
+ when :buffer
55
+ raise NotImplementedError, "Ethon::Curls::Options option #{option} buffer type not implemented."
56
+ when :dontuse_object
57
+ raise NotImplementedError, "Ethon::Curls::Options option #{option} type not implemented."
58
+ when :cbdata
59
+ raise NotImplementedError, "Ethon::Curls::Options option #{option} callback data type not implemented. Use Ruby closures."
60
+ when :callback
61
+ func=:callback
62
+ raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc
63
+ when :debug_callback
64
+ func=:debug_callback
65
+ raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc
66
+ when :off_t
67
+ return if value.nil?
68
+ func=:off_t
69
+ value=value.to_i
70
+ end
11
71
 
12
- name = "#{type}_setopt_#{value.class.to_s.downcase.delete(':')}"
13
- send(name, handle, option, value)
72
+ if func==:long or func==:off_t then
73
+ bits=FFI.type_size(:long)*8 if func==:long
74
+ bits=FFI.type_size(:int64)*8 if func==:off_t
75
+ tv=((value<0) ? value.abs-1 : value)
76
+ raise Errors::InvalidValue.new(option,value) unless tv<(1<<bits)
77
+ end
78
+
79
+ send("#{type}_setopt_#{func}", handle, opthash[option][:opt], value)
14
80
  end
81
+
82
+ OPTION_TYPE_BASE = {
83
+ :long => 0,
84
+ :objectpoint => 10000,
85
+ :functionpoint => 20000,
86
+ :off_t => 30000
87
+ }
88
+ OPTION_TYPE_MAP = {
89
+ :none => :long,
90
+ :int => :long,
91
+ :bool => :long,
92
+ :time => :long,
93
+ :enum => :long, # Two ways to specify values (as opts parameter):
94
+ # * Array of symbols, these will number sequentially
95
+ # starting at 0. Skip elements with nil. (see :netrc)
96
+ # * Hash of :symbol => enum_value (See :proxytype)
97
+ :bitmask => :long, # Three ways to specify values (as opts parameter):
98
+ # * Hash of :symbol => bitmask_value or Array.
99
+ # An Array can be an array of already defined
100
+ # Symbols, which represents a bitwise or of those
101
+ # symbols. (See :httpauth)
102
+ # * Array of symbols, these will number the bits
103
+ # sequentially (i.e. 0, 1, 2, 4, etc.). Skip
104
+ # elements with nil. The last element can be a
105
+ # Hash, which will be interpreted as above.
106
+ # (See :protocols)
107
+ # :all defaults to all bits set
108
+ :string => :objectpoint,
109
+ :string_escape_null => :objectpoint,
110
+ :ffipointer => :objectpoint, # FFI::Pointer
111
+ :curl_slist => :objectpoint,
112
+ :buffer => :objectpoint, # A memory buffer of size defined in the options
113
+ :dontuse_object => :objectpoint, # An object we don't support (e.g. FILE*)
114
+ :cbdata => :objectpoint,
115
+ :callback => :functionpoint,
116
+ :debug_callback => :functionpoint,
117
+ :off_t => :off_t,
118
+ }
15
119
 
16
- # :nodoc:
17
- def option_types
18
- {
19
- :long => 0,
20
- :object_point => 10000,
21
- :function_point => 20000,
22
- :off_t => 30000
23
- }
120
+ def self.option(ftype,name,type,num,opts=nil)
121
+ case type
122
+ when :enum
123
+ if opts.is_a? Array then
124
+ opts=Hash[opts.each_with_index.to_a]
125
+ elsif not opts.is_a? Hash then
126
+ raise TypeError, "Ethon::Curls::Options #{ftype} #{name} Expected opts to be an Array or a Hash."
127
+ end
128
+
129
+ when :bitmask
130
+ if opts.is_a? Array then
131
+ if opts.last.is_a? Hash then
132
+ hopts=opts.pop
133
+ else
134
+ hopts={}
135
+ end
136
+ opts.each_with_index do |v,i|
137
+ next if v.nil?
138
+ if i==0 then
139
+ hopts[v]=0
140
+ else
141
+ hopts[v]=1<<(i-1)
142
+ end
143
+ end
144
+ opts=hopts
145
+ elsif not opts.is_a? Hash then
146
+ raise TypeError, "Ethon::Curls::Options #{ftype} #{name} Expected opts to be an Array or a Hash."
147
+ end
148
+ opts[:all]=-1 unless opts.include? :all
149
+ opts.each do |k,v|
150
+ if v.is_a? Array then
151
+ opts[k]=v.map { |b| opts[b] }.inject :|
152
+ end
153
+ end
154
+
155
+ when :buffer
156
+ raise TypeError, "Ethon::Curls::Options #{ftype} #{name} Expected opts to be an Array or a Hash." unless opts.is_a? Integer
157
+
158
+ else
159
+ raise ArgumentError, "Ethon::Curls::Options #{ftype} #{name} Expected no opts." unless opts.nil?
160
+ end
161
+
162
+ opthash=const_get("#{ftype.to_s.upcase}_OPTIONS")
163
+ opthash[name]={:type=>type, :opt=>OPTION_TYPE_BASE[OPTION_TYPE_MAP[type]]+num, :opts=>opts}
24
164
  end
25
165
 
26
- # Curl multi options, refer
27
- # https://github.com/bagder/curl/blob/master/include/curl/multi.h
28
- def multi_options
29
- {
30
- :socketfunction => option_types[:function_point] + 1,
31
- :socketdata => option_types[:object_point] + 2,
32
- :pipelining => option_types[:long] + 3,
33
- :timerfunction => option_types[:function_point] + 4,
34
- :timerdata => option_types[:object_point] + 5,
35
- :maxconnects => option_types[:long] + 6
36
- }
166
+ def self.option_alias(ftype,name,*aliases)
167
+ opthash=const_get("#{ftype.to_s.upcase}_OPTIONS")
168
+ aliases.each { |a| opthash[a]=opthash[name] }
37
169
  end
38
170
 
39
- # Curl easy options, refer
40
- # https://github.com/bagder/curl/blob/master/include/curl/curl.h
41
- def easy_options
42
- {
43
- :file => option_types[:object_point] + 1,
44
- :writedata => option_types[:object_point] + 1,
45
- :url => option_types[:object_point] + 2,
46
- :port => option_types[:long] + 3,
47
- :proxy => option_types[:object_point] + 4,
48
- :userpwd => option_types[:object_point] + 5,
49
- :proxyuserpwd => option_types[:object_point] + 6,
50
- :range => option_types[:object_point] + 7,
51
- :infile => option_types[:object_point] + 9,
52
- :readdata => option_types[:object_point] + 9,
53
- :errorbuffer => option_types[:object_point] + 10,
54
- :writefunction => option_types[:function_point] + 11,
55
- :readfunction => option_types[:function_point] + 12,
56
- :timeout => option_types[:long] + 13,
57
- :infilesize => option_types[:long] + 14,
58
- :postfields => option_types[:object_point] + 15,
59
- :referer => option_types[:object_point] + 16,
60
- :ftpport => option_types[:object_point] + 17,
61
- :useragent => option_types[:object_point] + 18,
62
- :low_speed_time => option_types[:long] + 20,
63
- :resume_from => option_types[:long] + 21,
64
- :cookie => option_types[:object_point] + 22,
65
- :httpheader => option_types[:object_point] + 23,
66
- :httppost => option_types[:object_point] + 24,
67
- :sslcert => option_types[:object_point] + 25,
68
- :keypasswd => option_types[:object_point] + 26,
69
- :crlf => option_types[:long] + 27,
70
- :quote => option_types[:object_point] + 28,
71
- :writeheader => option_types[:object_point] + 29,
72
- :headerdata => option_types[:object_point] + 29,
73
- :cookiefile => option_types[:object_point] + 31,
74
- :sslversion => option_types[:long] + 32,
75
- :timecondition => option_types[:long] + 33,
76
- :timevalue => option_types[:long] + 34,
77
- :customrequest => option_types[:object_point] + 36,
78
- :stderr => option_types[:object_point] + 37,
79
- :postquote => option_types[:object_point] + 39,
80
- :writeinfo => option_types[:object_point] + 40,
81
- :verbose => option_types[:long] + 41,
82
- :header => option_types[:long] + 42,
83
- :noprogress => option_types[:long] + 43,
84
- :nobody => option_types[:long] + 44,
85
- :failonerror => option_types[:long] + 45,
86
- :upload => option_types[:long] + 46,
87
- :post => option_types[:long] + 47,
88
- :ftplistonly => option_types[:long] + 48,
89
- :ftpappend => option_types[:long] + 50,
90
- :netrc => option_types[:long] + 51,
91
- :followlocation => option_types[:long] + 52,
92
- :transfertext => option_types[:long] + 53,
93
- :put => option_types[:long] + 54,
94
- :progressfunction => option_types[:function_point] + 56,
95
- :progressdata => option_types[:object_point] + 57,
96
- :autoreferer => option_types[:long] + 58,
97
- :proxyport => option_types[:long] + 59,
98
- :postfieldsize => option_types[:long] + 60,
99
- :httpproxytunnel => option_types[:long] + 61,
100
- :interface => option_types[:object_point] + 62,
101
- :ssl_verifypeer => option_types[:long] + 64,
102
- :cainfo => option_types[:object_point] + 65,
103
- :maxredirs => option_types[:long] + 68,
104
- :filetime => option_types[:long] + 69,
105
- :telnetoptions => option_types[:object_point] + 70,
106
- :maxconnects => option_types[:long] + 71,
107
- :closepolicy => option_types[:long] + 72,
108
- :fresh_connect => option_types[:long] + 74,
109
- :forbid_reuse => option_types[:long] + 75,
110
- :random_file => option_types[:object_point] + 76,
111
- :egdsocket => option_types[:object_point] + 77,
112
- :connecttimeout => option_types[:long] + 78,
113
- :headerfunction => option_types[:function_point] + 79,
114
- :httpget => option_types[:long] + 80,
115
- :ssl_verifyhost => option_types[:long] + 81,
116
- :cookiejar => option_types[:object_point] + 82,
117
- :ssl_cipher_list => option_types[:object_point] + 83,
118
- :http_version => option_types[:long] + 84,
119
- :ftp_use_epsv => option_types[:long] + 85,
120
- :sslcerttype => option_types[:object_point] + 86,
121
- :sslkey => option_types[:object_point] + 87,
122
- :sslkeytype => option_types[:object_point] + 88,
123
- :sslengine => option_types[:object_point] + 89,
124
- :sslengine_default => option_types[:long] + 90,
125
- :dns_use_global_cache => option_types[:long] + 91,
126
- :dns_cache_timeout => option_types[:long] + 92,
127
- :prequote => option_types[:object_point] + 93,
128
- :debugfunction => option_types[:function_point] + 94,
129
- :debugdata => option_types[:object_point] + 95,
130
- :cookiesession => option_types[:long] + 96,
131
- :capath => option_types[:object_point] + 97,
132
- :buffersize => option_types[:long] + 98,
133
- :nosignal => option_types[:long] + 99,
134
- :share => option_types[:object_point] + 100,
135
- :proxytype => option_types[:long] + 101,
136
- :accept_encoding => option_types[:object_point] + 102,
137
- :private => option_types[:object_point] + 103,
138
- :unrestricted_auth => option_types[:long] + 105,
139
- :ftp_use_eprt => option_types[:long] + 106,
140
- :httpauth => option_types[:long] + 107,
141
- :ssl_ctx_function => option_types[:function_point] + 108,
142
- :ssl_ctx_data => option_types[:object_point] + 109,
143
- :ftp_create_missing_dirs => option_types[:long] + 110,
144
- :proxyauth => option_types[:long] + 111,
145
- :ipresolve => option_types[:long] + 113,
146
- :maxfilesize => option_types[:long] + 114,
147
- :infilesize_large => option_types[:off_t] + 115,
148
- :resume_from_large => option_types[:off_t] + 116,
149
- :maxfilesize_large => option_types[:off_t] + 117,
150
- :netrc_file => option_types[:object_point] + 118,
151
- :ftp_ssl => option_types[:long] + 119,
152
- :postfieldsize_large => option_types[:off_t] + 120,
153
- :tcp_nodelay => option_types[:long] + 121,
154
- :ftpsslauth => option_types[:long] + 129,
155
- :ioctlfunction => option_types[:function_point] + 130,
156
- :ioctldata => option_types[:object_point] + 131,
157
- :ftp_account => option_types[:object_point] + 134,
158
- :cookielist => option_types[:object_point] + 135,
159
- :ignore_content_length => option_types[:long] + 136,
160
- :ftp_skip_pasv_ip => option_types[:long] + 137,
161
- :ftp_filemethod => option_types[:long] + 138,
162
- :localport => option_types[:long] + 139,
163
- :localportrange => option_types[:long] + 140,
164
- :connect_only => option_types[:long] + 141,
165
- :conv_from_network_function => option_types[:function_point] + 142,
166
- :conv_to_network_function => option_types[:function_point] + 143,
167
- :max_send_speed_large => option_types[:off_t] + 145,
168
- :max_recv_speed_large => option_types[:off_t] + 146,
169
- :ftp_alternative_to_user => option_types[:object_point] + 147,
170
- :sockoptfunction => option_types[:function_point] + 148,
171
- :sockoptdata => option_types[:object_point] + 149,
172
- :ssl_sessionid_cache => option_types[:long] + 150,
173
- :ssh_auth_types => option_types[:long] + 151,
174
- :ssh_public_keyfile => option_types[:object_point] + 152,
175
- :ssh_private_keyfile => option_types[:object_point] + 153,
176
- :ftp_ssl_ccc => option_types[:long] + 154,
177
- :timeout_ms => option_types[:long] + 155,
178
- :connecttimeout_ms => option_types[:long] + 156,
179
- :http_transfer_decoding => option_types[:long] + 157,
180
- :http_content_decoding => option_types[:long] + 158,
181
- :postredir => option_types[:long] + 161,
182
- :copypostfields => option_types[:object_point] + 165,
183
- :proxy_transfer_mode => option_types[:long] + 166,
184
- :seekfunction => option_types[:function_point] + 167,
185
- :seekdata => option_types[:object_point] + 168,
186
- :crlfile => option_types[:object_point] + 169,
187
- :issuercert => option_types[:object_point] + 170,
188
- :address_scope => option_types[:long] + 171,
189
- :certinfo => option_types[:long] + 172,
190
- :username => option_types[:object_point] + 173,
191
- :password => option_types[:object_point] + 174,
192
- :proxyusername => option_types[:object_point] + 175,
193
- :proxypassword => option_types[:object_point] + 176,
194
- :noproxy => option_types[:object_point] + 177,
195
- :tftp_blksize => option_types[:long] + 178,
196
- :socks5_gssapi_service => option_types[:object_point] + 179,
197
- :socks5_gssapi_nec => option_types[:long] + 180,
198
- :protocols => option_types[:long] + 181,
199
- :redir_protocols => option_types[:long] + 182,
200
- :ssh_knownhosts => option_types[:object_point] + 183,
201
- :ssh_keyfunction => option_types[:function_point] + 184,
202
- :ssh_keydata => option_types[:object_point] + 185,
203
- :mail_from => option_types[:object_point] + 186,
204
- :mail_rcpt => option_types[:object_point] + 187,
205
- :ftp_use_pret => option_types[:long] + 188,
206
- :rtsp_request => option_types[:long] + 189,
207
- :rtsp_session_id => option_types[:object_point] + 190,
208
- :rtsp_stream_uri => option_types[:object_point] + 191,
209
- :rtsp_transport => option_types[:object_point] + 192,
210
- :rtsp_client_cseq => option_types[:long] + 193,
211
- :rtsp_server_cseq => option_types[:long] + 194,
212
- :interleavedata => option_types[:object_point] + 195,
213
- :interleavefunction => option_types[:function_point] + 196,
214
- :wildcardmatch => option_types[:long] + 197,
215
- :chunk_bgn_function => option_types[:function_point] + 198,
216
- :chunk_end_function => option_types[:function_point] + 199,
217
- :fnmatch_function => option_types[:function_point] + 200,
218
- :chunk_data => option_types[:object_point] + 201,
219
- :fnmatch_data => option_types[:object_point] + 202,
220
- :resolve => option_types[:object_point] + 203,
221
- :tlsauth_username => option_types[:object_point] + 204,
222
- :tlsauth_password => option_types[:object_point] + 205,
223
- :tlsauth_type => option_types[:object_point] + 206,
224
- :transfer_encoding => option_types[:long] + 207,
225
- :closesocketfunction => option_types[:function_point] + 208,
226
- :closesocketdata => option_types[:object_point] + 209,
227
- :gssapi_delegation => option_types[:long] + 210,
228
- :dns_servers => option_types[:object_point] + 211,
229
- :accepttimeout_ms => option_types[:long] + 212,
230
- :tcp_keepalive => option_types[:long] + 213,
231
- :tcp_keepidle => option_types[:long] + 214,
232
- :tcp_keepintvl => option_types[:long] + 215,
233
- :ssl_options => option_types[:long] + 216,
234
- :mail_auth => option_types[:object_point] + 217
235
- }
171
+ def self.option_type(type)
172
+ cname="#{type.to_s.upcase}_OPTIONS"
173
+ c=const_set(cname,{})
174
+ eval %Q<
175
+ def #{type.to_s.downcase}_options(rt=nil)
176
+ return #{cname}.map { |k,v| [k,v[:opt]] } if rt==:enum
177
+ #{cname}
178
+ end
179
+ >
236
180
  end
181
+
182
+ # Curl multi options, refer
183
+ # Defined @ https://github.com/bagder/curl/blob/master/include/curl/multi.h
184
+ # Documentation @ http://curl.haxx.se/libcurl/c/curl_multi_setopt.html
185
+ option_type :multi
186
+
187
+ option :multi, :socketfunction, :callback, 1
188
+ option :multi, :socketdata, :cbdata, 2
189
+ option :multi, :pipelining, :bool, 3
190
+ option :multi, :timerfunction, :callback, 4
191
+ option :multi, :timerdata, :cbdata, 5
192
+ option :multi, :maxconnects, :int, 6
193
+ option :multi, :max_host_connections, :int, 7
194
+ option :multi, :max_pipeline_length, :int, 8
195
+ option :multi, :content_length_penalty_size, :off_t, 9
196
+ option :multi, :chunk_length_penalty_size, :off_t, 10
197
+ option :multi, :pipelining_site_bl, :dontuse_object, 11
198
+ option :multi, :pipelining_server_bl, :dontuse_object, 12
199
+ option :multi, :max_total_connections, :int, 3
200
+
201
+ # Curl easy options
202
+ # Defined @ https://github.com/bagder/curl/blob/master/include/curl/curl.h
203
+ # Documentation @ http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
204
+ ## BEHAVIOR OPTIONS
205
+ option_type :easy
206
+
207
+ option :easy, :verbose, :bool, 41
208
+ option :easy, :header, :bool, 42
209
+ option :easy, :noprogress, :bool, 43
210
+ option :easy, :nosignal, :bool, 99
211
+ option :easy, :wildcardmatch, :bool, 197
212
+ ## CALLBACK OPTIONS
213
+ option :easy, :writefunction, :callback, 11
214
+ option :easy, :file, :cbdata, 1
215
+ option_alias :easy, :file, :writedata
216
+ option :easy, :readfunction, :callback, 12
217
+ option :easy, :infile, :cbdata, 9
218
+ option_alias :easy, :infile, :readdata
219
+ option :easy, :ioctlfunction, :callback, 130
220
+ option :easy, :ioctldata, :cbdata, 131
221
+ option :easy, :seekfunction, :callback, 167
222
+ option :easy, :seekdata, :cbdata, 168
223
+ option :easy, :sockoptfunction, :callback, 148
224
+ option :easy, :sockoptdata, :cbdata, 149
225
+ option :easy, :opensocketfunction, :callback, 163
226
+ option :easy, :opensocketdata, :cbdata, 164
227
+ option :easy, :closesocketfunction, :callback, 208
228
+ option :easy, :closesocketdata, :cbdata, 209
229
+ option :easy, :progressfunction, :callback, 56
230
+ option :easy, :progressdata, :cbdata, 57
231
+ option :easy, :headerfunction, :callback, 79
232
+ option :easy, :writeheader, :cbdata, 29
233
+ option_alias :easy, :writeheader, :headerdata
234
+ option :easy, :debugfunction, :debug_callback, 94
235
+ option :easy, :debugdata, :cbdata, 95
236
+ option :easy, :ssl_ctx_function, :callback, 108
237
+ option :easy, :ssl_ctx_data, :cbdata, 109
238
+ option :easy, :conv_to_network_function, :callback, 143
239
+ option :easy, :conv_from_network_function, :callback, 142
240
+ option :easy, :conv_from_utf8_function, :callback, 144
241
+ option :easy, :interleavefunction, :callback, 196
242
+ option :easy, :interleavedata, :cbdata, 195
243
+ option :easy, :chunk_bgn_function, :callback, 198
244
+ option :easy, :chunk_end_function, :callback, 199
245
+ option :easy, :chunk_data, :cbdata, 201
246
+ option :easy, :fnmatch_function, :callback, 200
247
+ option :easy, :fnmatch_data, :cbdata, 202
248
+ ## ERROR OPTIONS
249
+ option :easy, :errorbuffer, :buffer, 10, 256
250
+ option :easy, :stderr, :dontuse_object, 37
251
+ option :easy, :failonerror, :bool, 45
252
+ ## NETWORK OPTIONS
253
+ option :easy, :url, :string, 2
254
+ option :easy, :protocols, :bitmask, 181, [nil, :http, :https, :ftp, :ftps, :scp, :sftp, :telnet, :ldap, :ldaps, :dict, :file, :tftp, :imap, :imaps, :pop3, :pop3s, :smtp, :smtps, :rtsp, :rtmp, :rtmpt, :rtmpe, :rtmpte, :rtmps, :rtmpts, :gopher]
255
+ option :easy, :redir_protocols, :bitmask, 182, [nil, :http, :https, :ftp, :ftps, :scp, :sftp, :telnet, :ldap, :ldaps, :dict, :file, :tftp, :imap, :imaps, :pop3, :pop3s, :smtp, :smtps, :rtsp, :rtmp, :rtmpt, :rtmpe, :rtmpte, :rtmps, :rtmpts, :gopher]
256
+ option :easy, :proxy, :string, 4
257
+ option :easy, :proxyport, :int, 59
258
+ option :easy, :proxytype, :enum, 101, [:http, :http_1_0, nil, nil, :socks4, :socks5, :socks4a, :socks5_hostname]
259
+ option :easy, :noproxy, :string, 177
260
+ option :easy, :httpproxytunnel, :bool, 61
261
+ option :easy, :socks5_gssapi_service, :string, 179
262
+ option :easy, :socks5_gssapi_nec, :bool, 180
263
+ option :easy, :interface, :string, 62
264
+ option :easy, :localport, :int, 139
265
+ option :easy, :localportrange, :int, 140
266
+ option :easy, :dns_cache_timeout, :int, 92
267
+ option :easy, :dns_use_global_cache, :bool, 91 # Obsolete
268
+ option :easy, :buffersize, :int, 98
269
+ option :easy, :port, :int, 3
270
+ option :easy, :tcp_nodelay, :bool, 121
271
+ option :easy, :address_scope, :int, 171
272
+ option :easy, :tcp_keepalive, :bool, 213
273
+ option :easy, :tcp_keepidle, :int, 214
274
+ option :easy, :tcp_keepintvl, :int, 215
275
+ ## NAMES and PASSWORDS OPTIONS (Authentication)
276
+ option :easy, :netrc, :enum, 51, [:ignored, :optional, :required]
277
+ option :easy, :netrc_file, :string, 118
278
+ option :easy, :userpwd, :string, 5
279
+ option :easy, :proxyuserpwd, :string, 6
280
+ option :easy, :username, :string, 173
281
+ option :easy, :password, :string, 174
282
+ option :easy, :proxyusername, :string, 175
283
+ option :easy, :proxypassword, :string, 176
284
+ option :easy, :httpauth, :bitmask, 107, [:none, :basic, :digest, :gssnegotiate, :ntlm, :digest_ie, :ntlm_wb, {:only => 1<<31, :any => ~0x10, :anysafe => ~0x11, :auto => 0x1f}]
285
+ option :easy, :tlsauth_type, :enum, 206, [:none, :srp]
286
+ option :easy, :tlsauth_username, :string, 204
287
+ option :easy, :tlsauth_password, :string, 205
288
+ option :easy, :proxyauth, :bitmask, 111, [:none, :basic, :digest, :gssnegotiate, :ntlm, :digest_ie, :ntlm_wb, {:only => 1<<31, :any => ~0x10, :anysafe => ~0x11, :auto => 0x1f}]
289
+ option :easy, :sasl_ir, :bool, 218
290
+ ## HTTP OPTIONS
291
+ option :easy, :autoreferer, :bool, 58
292
+ option :easy, :accept_encoding, :string, 102
293
+ option_alias :easy, :accept_encoding, :encoding
294
+ option :easy, :transfer_encoding, :bool, 207
295
+ option :easy, :followlocation, :bool, 52
296
+ option :easy, :unrestricted_auth, :bool, 105
297
+ option :easy, :maxredirs, :int, 68
298
+ option :easy, :postredir, :bitmask, 161, [:get_all, :post_301, :post_302, :post_303, {:post_all => [:post_301, :post_302, :post_303]}]
299
+ option_alias :easy, :postredir, :post301
300
+ option :easy, :put, :bool, 54
301
+ option :easy, :post, :bool, 47
302
+ option :easy, :postfields, :string, 15
303
+ option :easy, :postfieldsize, :int, 60
304
+ option :easy, :postfieldsize_large, :off_t, 120
305
+ option :easy, :copypostfields, :string, 165
306
+ option :easy, :httppost, :ffipointer, 24
307
+ option :easy, :referer, :string, 16
308
+ option :easy, :useragent, :string, 18
309
+ option :easy, :httpheader, :curl_slist, 23
310
+ option :easy, :http200aliases, :curl_slist, 104
311
+ option :easy, :cookie, :string, 22
312
+ option :easy, :cookiefile, :string, 31
313
+ option :easy, :cookiejar, :string, 82
314
+ option :easy, :cookiesession, :bool, 96
315
+ option :easy, :cookielist, :string, 135
316
+ option :easy, :httpget, :bool, 80
317
+ option :easy, :http_version, :enum, 84, [:none, :httpv1_0, :httpv1_1]
318
+ option :easy, :ignore_content_length, :bool, 136
319
+ option :easy, :http_content_decoding, :bool, 158
320
+ option :easy, :http_transfer_decoding, :bool, 157
321
+ ## SMTP OPTIONS
322
+ option :easy, :mail_from, :string, 186
323
+ option :easy, :mail_rcpt, :curl_slist, 187
324
+ option :easy, :mail_auth, :string, 217
325
+ ## TFTP OPTIONS
326
+ option :easy, :tftp_blksize, :int, 178
327
+ ## FTP OPTIONS
328
+ option :easy, :ftpport, :string, 17
329
+ option :easy, :quote, :curl_slist, 28
330
+ option :easy, :postquote, :curl_slist, 39
331
+ option :easy, :prequote, :curl_slist, 93
332
+ option :easy, :dirlistonly, :bool, 48
333
+ option_alias :easy, :dirlistonly, :ftplistonly
334
+ option :easy, :append, :bool, 50
335
+ option_alias :easy, :append, :ftpappend
336
+ option :easy, :ftp_use_eprt, :bool, 106
337
+ option :easy, :ftp_use_epsv, :bool, 85
338
+ option :easy, :ftp_use_pret, :bool, 188
339
+ option :easy, :ftp_create_missing_dirs, :bool, 110
340
+ option :easy, :ftp_response_timeout, :int, 112
341
+ option_alias :easy, :ftp_response_timeout, :server_response_timeout
342
+ option :easy, :ftp_alternative_to_user, :string, 147
343
+ option :easy, :ftp_skip_pasv_ip, :bool, 137
344
+ option :easy, :ftpsslauth, :enum, 129, [:default, :ssl, :tls]
345
+ option :easy, :ftp_ssl_ccc, :enum, 154, [:none, :passive, :active]
346
+ option :easy, :ftp_account, :string, 134
347
+ option :easy, :ftp_filemethod, :enum, 138, [:default, :multicwd, :nocwd, :singlecwd]
348
+ ## RTSP OPTIONS
349
+ option :easy, :rtsp_request, :enum, 189, [:none, :options, :describe, :announce, :setup, :play, :pause, :teardown, :get_parameter, :set_parameter, :record, :receive]
350
+ option :easy, :rtsp_session_id, :string, 190
351
+ option :easy, :rtsp_stream_uri, :string, 191
352
+ option :easy, :rtsp_transport, :string, 192
353
+ option_alias :easy, :httpheader, :rtspheader
354
+ option :easy, :rtsp_client_cseq, :int, 193
355
+ option :easy, :rtsp_server_cseq, :int, 194
356
+ ## PROTOCOL OPTIONS
357
+ option :easy, :transfertext, :bool, 53
358
+ option :easy, :proxy_transfer_mode, :bool, 166
359
+ option :easy, :crlf, :bool, 27
360
+ option :easy, :range, :string, 7
361
+ option :easy, :resume_from, :int, 21
362
+ option :easy, :resume_from_large, :off_t, 116
363
+ option :easy, :customrequest, :string, 36
364
+ option :easy, :filetime, :bool, 69
365
+ option :easy, :nobody, :bool, 44
366
+ option :easy, :infilesize, :int, 14
367
+ option :easy, :infilesize_large, :off_t, 115
368
+ option :easy, :upload, :bool, 46
369
+ option :easy, :maxfilesize, :int, 114
370
+ option :easy, :maxfilesize_large, :off_t, 117
371
+ option :easy, :timecondition, :enum, 33, [:none, :ifmodsince, :ifunmodsince, :lastmod]
372
+ option :easy, :timevalue, :time, 34
373
+ ## CONNECTION OPTIONS
374
+ option :easy, :timeout, :int, 13
375
+ option :easy, :timeout_ms, :int, 155
376
+ option :easy, :low_speed_limit, :int, 19
377
+ option :easy, :low_speed_time, :int, 20
378
+ option :easy, :max_send_speed_large, :off_t, 145
379
+ option :easy, :max_recv_speed_large, :off_t, 146
380
+ option :easy, :maxconnects, :int, 71
381
+ option :easy, :fresh_connect, :bool, 74
382
+ option :easy, :forbid_reuse, :bool, 75
383
+ option :easy, :connecttimeout, :int, 78
384
+ option :easy, :connecttimeout_ms, :int, 156
385
+ option :easy, :ipresolve, :enum, 113, [:whatever, :v4, :v6]
386
+ option :easy, :connect_only, :bool, 141
387
+ option :easy, :use_ssl, :enum, 119, [:none, :try, :control, :all]
388
+ option_alias :easy, :use_ssl, :ftp_ssl
389
+ option :easy, :resolve, :curl_slist, 203
390
+ option :easy, :dns_servers, :string, 211
391
+ option :easy, :accepttimeout_ms, :int, 212
392
+ ## SSL and SECURITY OPTIONS
393
+ option :easy, :sslcert, :string, 25
394
+ option :easy, :sslcerttype, :string, 86
395
+ option :easy, :sslkey, :string, 87
396
+ option :easy, :sslkeytype, :string, 88
397
+ option :easy, :keypasswd, :string, 26
398
+ option_alias :easy, :keypasswd, :sslcertpasswd
399
+ option_alias :easy, :keypasswd, :sslkeypasswd
400
+ option :easy, :sslengine, :string, 89
401
+ option :easy, :sslengine_default, :none, 90
402
+ option :easy, :sslversion, :enum, 32, [:default, :tlsv1, :sslv2, :sslv3]
403
+ option :easy, :ssl_verifypeer, :bool, 64
404
+ option :easy, :cainfo, :string, 65
405
+ option :easy, :issuercert, :string, 170
406
+ option :easy, :capath, :string, 97
407
+ option :easy, :crlfile, :string, 169
408
+ option :easy, :ssl_verifyhost, :int, 81
409
+ option :easy, :certinfo, :bool, 172
410
+ option :easy, :random_file, :string, 76
411
+ option :easy, :egdsocket, :string, 77
412
+ option :easy, :ssl_cipher_list, :string, 83
413
+ option :easy, :ssl_sessionid_cache, :bool, 150
414
+ option :easy, :ssl_options, :bitmask, 216, [nil, :allow_beast]
415
+ option :easy, :krblevel, :string, 63
416
+ option_alias :easy, :krblevel, :krb4level
417
+ option :easy, :gssapi_delegation, :bitmask, 210, [:none, :policy_flag, :flag]
418
+ ## SSH OPTIONS
419
+ option :easy, :ssh_auth_types, :bitmask, 151, [:none, :publickey, :password, :host, :keyboard, :agent, {:any => [:all], :default => [:any]}]
420
+ option :easy, :ssh_host_public_key_md5, :string, 162
421
+ option :easy, :ssh_public_keyfile, :string, 152
422
+ option :easy, :ssh_private_keyfile, :string, 153
423
+ option :easy, :ssh_knownhosts, :string, 183
424
+ option :easy, :ssh_keyfunction, :callback, 184
425
+ option :easy, :khstat, :enum, -1, [:fine_add_to_file, :fine, :reject, :defer] # Kludge to make this enum available... Access via CurL::EASY_OPTIONS[:khstat][:opt]
426
+ option :easy, :ssh_keydata, :cbdata, 185
427
+ ## OTHER OPTIONS
428
+ option :easy, :private, :cbdata, 103
429
+ option :easy, :share, :dontuse_object, 100
430
+ option :easy, :new_file_perms, :int, 159
431
+ option :easy, :new_directory_perms, :int, 160
432
+ ## TELNET OPTIONS
433
+ option :easy, :telnetoptions, :curl_slist, 70
237
434
  end
238
435
  end
239
436
  end