ethon 0.9.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +41 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +20 -1
  5. data/Gemfile +14 -4
  6. data/Guardfile +1 -0
  7. data/README.md +4 -1
  8. data/Rakefile +1 -0
  9. data/ethon.gemspec +2 -1
  10. data/lib/ethon.rb +2 -0
  11. data/lib/ethon/curl.rb +1 -0
  12. data/lib/ethon/curls/classes.rb +2 -1
  13. data/lib/ethon/curls/codes.rb +1 -1
  14. data/lib/ethon/curls/constants.rb +1 -0
  15. data/lib/ethon/curls/form_options.rb +1 -0
  16. data/lib/ethon/curls/functions.rb +4 -12
  17. data/lib/ethon/curls/infos.rb +4 -3
  18. data/lib/ethon/curls/messages.rb +1 -0
  19. data/lib/ethon/curls/options.rb +35 -23
  20. data/lib/ethon/curls/settings.rb +2 -0
  21. data/lib/ethon/easy.rb +3 -1
  22. data/lib/ethon/easy/callbacks.rb +25 -3
  23. data/lib/ethon/easy/debug_info.rb +1 -0
  24. data/lib/ethon/easy/features.rb +1 -0
  25. data/lib/ethon/easy/form.rb +7 -4
  26. data/lib/ethon/easy/header.rb +1 -0
  27. data/lib/ethon/easy/http.rb +1 -0
  28. data/lib/ethon/easy/http/actionable.rb +2 -1
  29. data/lib/ethon/easy/http/custom.rb +1 -0
  30. data/lib/ethon/easy/http/delete.rb +1 -0
  31. data/lib/ethon/easy/http/get.rb +1 -0
  32. data/lib/ethon/easy/http/head.rb +1 -0
  33. data/lib/ethon/easy/http/options.rb +1 -0
  34. data/lib/ethon/easy/http/patch.rb +1 -0
  35. data/lib/ethon/easy/http/post.rb +1 -0
  36. data/lib/ethon/easy/http/postable.rb +1 -0
  37. data/lib/ethon/easy/http/put.rb +1 -0
  38. data/lib/ethon/easy/http/putable.rb +1 -0
  39. data/lib/ethon/easy/informations.rb +1 -0
  40. data/lib/ethon/easy/mirror.rb +1 -0
  41. data/lib/ethon/easy/operations.rb +16 -1
  42. data/lib/ethon/easy/options.rb +11 -2
  43. data/lib/ethon/easy/params.rb +1 -0
  44. data/lib/ethon/easy/queryable.rb +4 -1
  45. data/lib/ethon/easy/response_callbacks.rb +27 -0
  46. data/lib/ethon/easy/util.rb +1 -0
  47. data/lib/ethon/errors.rb +1 -0
  48. data/lib/ethon/errors/ethon_error.rb +1 -0
  49. data/lib/ethon/errors/global_init.rb +1 -0
  50. data/lib/ethon/errors/invalid_option.rb +1 -0
  51. data/lib/ethon/errors/invalid_value.rb +1 -0
  52. data/lib/ethon/errors/multi_add.rb +1 -0
  53. data/lib/ethon/errors/multi_fdset.rb +1 -0
  54. data/lib/ethon/errors/multi_remove.rb +1 -0
  55. data/lib/ethon/errors/multi_timeout.rb +1 -0
  56. data/lib/ethon/errors/select.rb +1 -0
  57. data/lib/ethon/libc.rb +16 -1
  58. data/lib/ethon/loggable.rb +1 -0
  59. data/lib/ethon/multi.rb +1 -0
  60. data/lib/ethon/multi/operations.rb +1 -0
  61. data/lib/ethon/multi/options.rb +2 -1
  62. data/lib/ethon/multi/stack.rb +1 -0
  63. data/lib/ethon/version.rb +2 -1
  64. data/profile/benchmarks.rb +1 -0
  65. data/profile/memory_leaks.rb +1 -0
  66. data/profile/perf_spec_helper.rb +1 -0
  67. data/profile/support/memory_test_helpers.rb +1 -0
  68. data/profile/support/os_memory_leak_tracker.rb +1 -0
  69. data/profile/support/ruby_object_leak_tracker.rb +1 -0
  70. data/spec/ethon/curl_spec.rb +1 -0
  71. data/spec/ethon/easy/callbacks_spec.rb +8 -1
  72. data/spec/ethon/easy/debug_info_spec.rb +2 -0
  73. data/spec/ethon/easy/features_spec.rb +1 -0
  74. data/spec/ethon/easy/form_spec.rb +28 -0
  75. data/spec/ethon/easy/header_spec.rb +1 -0
  76. data/spec/ethon/easy/http/custom_spec.rb +1 -0
  77. data/spec/ethon/easy/http/delete_spec.rb +1 -0
  78. data/spec/ethon/easy/http/get_spec.rb +1 -0
  79. data/spec/ethon/easy/http/head_spec.rb +1 -0
  80. data/spec/ethon/easy/http/options_spec.rb +1 -0
  81. data/spec/ethon/easy/http/patch_spec.rb +1 -0
  82. data/spec/ethon/easy/http/post_spec.rb +1 -0
  83. data/spec/ethon/easy/http/put_spec.rb +1 -0
  84. data/spec/ethon/easy/http_spec.rb +1 -0
  85. data/spec/ethon/easy/informations_spec.rb +1 -0
  86. data/spec/ethon/easy/mirror_spec.rb +1 -0
  87. data/spec/ethon/easy/operations_spec.rb +1 -0
  88. data/spec/ethon/easy/options_spec.rb +31 -1
  89. data/spec/ethon/easy/queryable_spec.rb +14 -3
  90. data/spec/ethon/easy/response_callbacks_spec.rb +58 -1
  91. data/spec/ethon/easy/util_spec.rb +1 -0
  92. data/spec/ethon/easy_spec.rb +8 -2
  93. data/spec/ethon/libc_spec.rb +4 -3
  94. data/spec/ethon/loggable_spec.rb +1 -0
  95. data/spec/ethon/multi/operations_spec.rb +1 -0
  96. data/spec/ethon/multi/options_spec.rb +1 -0
  97. data/spec/ethon/multi/stack_spec.rb +1 -0
  98. data/spec/ethon/multi_spec.rb +1 -0
  99. data/spec/spec_helper.rb +1 -0
  100. data/spec/support/localhost_server.rb +2 -1
  101. data/spec/support/server.rb +1 -0
  102. metadata +6 -7
  103. data/.travis.yml +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b5b8550d86c3b12a213c5f44bc47575cc155b57f
4
- data.tar.gz: 9c23490c1d3184612dea6e1e88a293a7444f65a6
2
+ SHA256:
3
+ metadata.gz: 558abec878f87a7e13113e513faf1dc5970cfcc12d3b0a8d4faaec50e847e1c9
4
+ data.tar.gz: 979dbda54e8b12f1a93fee6bb16db05c1960719f44c7d2152e5d9aaddd783d4e
5
5
  SHA512:
6
- metadata.gz: 8dfc9939d7232e54526cd3aebcda6a8c058d0620efcd50204e6e9d9b19c40484a4ee117a1b64761f5bdefd130ea0842a169dc5ddb108f6b73ddb325748db5e74
7
- data.tar.gz: 4abc8b70ff4da5bce7edf2e7ea75c22bab080ea68f211618bc350bad55ab8df1ad7e1dd8f304dcdb85a21499b524f7ff40d064e7a42ad7175b1b787f7e0a576a
6
+ metadata.gz: 63339cb7a38df43138df7fb52c88d8764d7b1f04bea134781338a676a6a567e8850b9ef24f5db1268a126f9d43b31f6d0ecc6b1441bd8bb6ef7572e7d2c366bd
7
+ data.tar.gz: f516c95eb23a3dd70d4ee25e76bd100d2cb5d2cf38fd8d626c584c2b71e9307084b0d07598d01c595447c5b241b50a58259aca7da29cdc65db404ebf9fb622f7
@@ -0,0 +1,41 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ${{ matrix.os }}-latest
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ os: [ubuntu, macos]
23
+ ruby-version: [2.5, 2.6, 2.7, 3.0, head, debug, truffleruby, truffleruby-head]
24
+ continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
25
+ steps:
26
+ - uses: actions/checkout@v2
27
+ - name: Install libcurl header
28
+ run: |
29
+ if ${{ matrix.os == 'macos' }}
30
+ then
31
+ brew install curl
32
+ else
33
+ sudo apt install -y libcurl4-openssl-dev
34
+ fi
35
+ - name: Set up Ruby
36
+ uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: ${{ matrix.ruby-version }}
39
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
40
+ - name: Run tests
41
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ Gemfile.lock
5
5
  .yardoc
6
6
  doc
7
7
  coverage
8
+ .idea
data/CHANGELOG.md CHANGED
@@ -2,7 +2,26 @@
2
2
 
3
3
  ## Master
4
4
 
5
- [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.9.1...master)
5
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.12.0...master)
6
+
7
+ ## 0.12.0
8
+
9
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.11.0...v0.12.0)
10
+
11
+ - Removed deprecated `CURLE_SSL_CACERT` pinned in curl v7.62.0 ([@arku](https://github.com/arku) in [#158](https://github.com/typhoeus/ethon/pull/158))
12
+
13
+
14
+ ## 0.11.0
15
+
16
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.10.1...v0.11.0)
17
+
18
+ ## 0.10.1
19
+
20
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.10.0...v0.10.1)
21
+
22
+ ## 0.10.0
23
+
24
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.9.1...v0.10.0)
6
25
 
7
26
  ## 0.9.1
8
27
 
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source "https://rubygems.org"
2
3
  gemspec
3
4
 
@@ -18,11 +19,20 @@ group :development, :test do
18
19
  gem "json"
19
20
  end
20
21
 
21
- gem "mime-types", "~> 1.18"
22
+ if Gem.ruby_version >= Gem::Version.new("2.0.0")
23
+ gem "mime-types", "~> 1.18"
24
+ end
25
+
26
+ if Gem.ruby_version >= Gem::Version.new("2.2.0")
27
+ gem "mustermann"
28
+ elsif Gem.ruby_version >= Gem::Version.new("2.1.0")
29
+ gem "mustermann", "0.4.0"
30
+ elsif Gem.ruby_version >= Gem::Version.new("2.0.0")
31
+ gem "mustermann", "0.3.1"
32
+ end
22
33
 
23
- unless ENV["CI"]
24
- gem "guard-rspec", "~> 0.7"
25
- gem "rb-fsevent", "~> 0.9.1"
34
+ if Gem.ruby_version >= Gem::Version.new("3.0.0")
35
+ gem "webrick"
26
36
  end
27
37
  end
28
38
 
data/Guardfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # vim:set filetype=ruby:
2
3
  guard(
3
4
  "rspec",
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Ethon [![Build Status](https://secure.travis-ci.org/typhoeus/ethon.png?branch=master)](http://travis-ci.org/typhoeus/ethon) [![Gem Version](https://badge.fury.io/rb/ethon.png)](http://badge.fury.io/rb/ethon)
1
+ [![Gem Version](https://badge.fury.io/rb/ethon.svg)](https://badge.fury.io/rb/ethon)
2
+ [![Build Status](https://github.com/typhoeus/ethon/workflows/Ruby/badge.svg)](https://github.com/typhoeus/ethon/actions/workflows/ruby.yml)
3
+
4
+ # Ethon
2
5
 
3
6
  In Greek mythology, Ethon, the son of Typhoeus and Echidna, is a gigantic eagle. So much for the history.
4
7
  In the modern world, Ethon is a very basic libcurl wrapper using ffi.
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler"
2
3
  Bundler.setup
3
4
 
data/ethon.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  lib = File.expand_path('../lib/', __FILE__)
3
4
  $:.unshift lib unless $:.include?(lib)
4
5
 
@@ -17,7 +18,7 @@ Gem::Specification.new do |s|
17
18
  s.required_rubygems_version = ">= 1.3.6"
18
19
  s.license = 'MIT'
19
20
 
20
- s.add_dependency('ffi', ['>= 1.3.0'])
21
+ s.add_dependency('ffi', ['>= 1.15.0'])
21
22
 
22
23
  s.files = `git ls-files`.split("\n")
23
24
  s.test_files = `git ls-files -- spec/*`.split("\n")
data/lib/ethon.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  require 'logger'
2
3
  require 'ffi'
4
+ require 'ffi/tools/const_generator'
3
5
  require 'thread'
4
6
  begin
5
7
  require 'mime/types/columnar'
data/lib/ethon/curl.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon/curls/codes'
2
3
  require 'ethon/curls/options'
3
4
  require 'ethon/curls/infos'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curl
3
4
  # :nodoc:
@@ -32,7 +33,7 @@ module Ethon
32
33
  def clear; self[:fd_count] = 0; end
33
34
  else
34
35
  # FD Set size.
35
- FD_SETSIZE = ::Ethon::Libc.getdtablesize
36
+ FD_SETSIZE = ::Ethon::Libc.sysconf(:open_max)
36
37
  layout :fds_bits, [:long, FD_SETSIZE / ::FFI::Type::LONG.size]
37
38
 
38
39
  # :nodoc:
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curls # :nodoc:
3
4
 
@@ -69,7 +70,6 @@ module Ethon
69
70
  :obsolete57,
70
71
  :ssl_certproblem,
71
72
  :ssl_cipher,
72
- :ssl_cacert,
73
73
  :bad_content_encoding,
74
74
  :ldap_invalid_url,
75
75
  :filesize_exceeded,
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curl
3
4
  # :nodoc:
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curls
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curls
3
4
 
@@ -13,13 +14,8 @@ module Ethon
13
14
 
14
15
  base.attach_function :easy_init, :curl_easy_init, [], :pointer
15
16
  base.attach_function :easy_cleanup, :curl_easy_cleanup, [:pointer], :void
16
- base.attach_function :easy_getinfo, :curl_easy_getinfo, [:pointer, :info, :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_callback, :curl_easy_setopt, [:pointer, :easy_option, :callback], :easy_code
21
- base.attach_function :easy_setopt_debug_callback, :curl_easy_setopt, [:pointer, :easy_option, :debug_callback], :easy_code
22
- base.attach_function :easy_setopt_off_t, :curl_easy_setopt, [:pointer, :easy_option, :int64], :easy_code
17
+ base.attach_function :easy_getinfo, :curl_easy_getinfo, [:pointer, :info, :varargs], :easy_code
18
+ base.attach_function :easy_setopt, :curl_easy_setopt, [:pointer, :easy_option, :varargs], :easy_code
23
19
  base.instance_variable_set(:@blocking, true)
24
20
  base.attach_function :easy_perform, :curl_easy_perform, [:pointer], :easy_code
25
21
  base.attach_function :easy_strerror, :curl_easy_strerror, [:easy_code], :string
@@ -39,11 +35,7 @@ module Ethon
39
35
  base.attach_function :multi_timeout, :curl_multi_timeout, [:pointer, :pointer], :multi_code
40
36
  base.attach_function :multi_fdset, :curl_multi_fdset, [:pointer, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::FDSet.ptr, :pointer], :multi_code
41
37
  base.attach_function :multi_strerror, :curl_multi_strerror, [:int], :string
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_callback, :curl_multi_setopt, [:pointer, :multi_option, :callback], :multi_code
46
- base.attach_function :multi_setopt_off_t, :curl_multi_setopt, [:pointer, :multi_option, :int64], :multi_code
38
+ base.attach_function :multi_setopt, :curl_multi_setopt, [:pointer, :multi_option, :varargs], :multi_code
47
39
 
48
40
  base.attach_function :version, :curl_version, [], :string
49
41
  base.attach_function :version_info, :curl_version_info, [], Curl::VersionInfoData.ptr
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curls
3
4
 
@@ -106,7 +107,7 @@ module Ethon
106
107
  def get_info_string(option, handle)
107
108
  string_ptr = ::FFI::MemoryPointer.new(:pointer)
108
109
 
109
- if easy_getinfo(handle, option, string_ptr) == :ok
110
+ if easy_getinfo(handle, option, :pointer, string_ptr) == :ok
110
111
  ptr=string_ptr.read_pointer
111
112
  ptr.null? ? nil : ptr.read_string
112
113
  end
@@ -124,7 +125,7 @@ module Ethon
124
125
  def get_info_long(option, handle)
125
126
  long_ptr = ::FFI::MemoryPointer.new(:long)
126
127
 
127
- if easy_getinfo(handle, option, long_ptr) == :ok
128
+ if easy_getinfo(handle, option, :pointer, long_ptr) == :ok
128
129
  long_ptr.read_long
129
130
  end
130
131
  end
@@ -141,7 +142,7 @@ module Ethon
141
142
  def get_info_double(option, handle)
142
143
  double_ptr = ::FFI::MemoryPointer.new(:double)
143
144
 
144
- if easy_getinfo(handle, option, double_ptr) == :ok
145
+ if easy_getinfo(handle, option, :pointer, double_ptr) == :ok
145
146
  double_ptr.read_double
146
147
  end
147
148
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curls
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curls
3
4
 
@@ -7,8 +8,7 @@ module Ethon
7
8
 
8
9
  OPTION_STRINGS = { :easy => 'easy_options', :multi => 'multi_options' }.freeze
9
10
  FOPTION_STRINGS = { :easy => 'EASY_OPTIONS', :multi => 'MULTI_OPTIONS' }.freeze
10
- FTYPES = [:long, :string, :ffipointer, :callback, :debug_callback, :off_t]
11
- FUNCS = Hash[*[:easy, :multi].zip([:easy, :multi].map { |t| Hash[*FTYPES.zip(FTYPES.map { |ft| "#{t}_setopt_#{ft}" }).flatten] }).flatten]
11
+ FUNCS = { :easy => 'easy_setopt', :multi => 'multi_setopt' }.freeze
12
12
  # Sets appropriate option for easy, depending on value type.
13
13
  def set_option(option, value, handle, type = :easy)
14
14
  type = type.to_sym unless type.is_a?(Symbol)
@@ -20,22 +20,22 @@ module Ethon
20
20
  when :none
21
21
  return if value.nil?
22
22
  value=1
23
- func=:long
23
+ va_type=:long
24
24
  when :int
25
25
  return if value.nil?
26
- func=:long
26
+ va_type=:long
27
27
  value=value.to_i
28
28
  when :bool
29
29
  return if value.nil?
30
- func=:long
30
+ va_type=:long
31
31
  value=(value&&value!=0) ? 1 : 0
32
32
  when :time
33
33
  return if value.nil?
34
- func=:long
34
+ va_type=:long
35
35
  value=value.to_i
36
36
  when :enum
37
37
  return if value.nil?
38
- func=:long
38
+ va_type=:long
39
39
  value = case value
40
40
  when Symbol
41
41
  opthash[option][:opts][value]
@@ -46,7 +46,7 @@ module Ethon
46
46
  end.to_i
47
47
  when :bitmask
48
48
  return if value.nil?
49
- func=:long
49
+ va_type=:long
50
50
  value = case value
51
51
  when Symbol
52
52
  opthash[option][:opts][value]
@@ -56,22 +56,22 @@ module Ethon
56
56
  value
57
57
  end.to_i
58
58
  when :string
59
- func=:string
59
+ va_type=:string
60
60
  value=value.to_s unless value.nil?
61
61
  when :string_as_pointer
62
- func = :ffipointer
62
+ va_type = :pointer
63
63
  s = ''
64
64
  s = value.to_s unless value.nil?
65
65
  value = FFI::MemoryPointer.new(:char, s.bytesize)
66
66
  value.put_bytes(0, s)
67
67
  when :string_escape_null
68
- func=:string
68
+ va_type=:string
69
69
  value=Util.escape_zero_byte(value) unless value.nil?
70
70
  when :ffipointer
71
- func=:ffipointer
71
+ va_type=:pointer
72
72
  raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? FFI::Pointer
73
73
  when :curl_slist
74
- func=:ffipointer
74
+ va_type=:pointer
75
75
  raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? FFI::Pointer
76
76
  when :buffer
77
77
  raise NotImplementedError, "Ethon::Curls::Options option #{option} buffer type not implemented."
@@ -80,24 +80,26 @@ module Ethon
80
80
  when :cbdata
81
81
  raise NotImplementedError, "Ethon::Curls::Options option #{option} callback data type not implemented. Use Ruby closures."
82
82
  when :callback
83
- func=:callback
83
+ va_type=:callback
84
84
  raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc
85
85
  when :debug_callback
86
- func=:debug_callback
86
+ va_type=:debug_callback
87
+ raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc
88
+ when :progress_callback
89
+ va_type=:progress_callback
87
90
  raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc
88
91
  when :off_t
89
92
  return if value.nil?
90
- func=:off_t
93
+ va_type=:int64
91
94
  value=value.to_i
92
95
  end
93
96
 
94
- if func==:long or func==:off_t then
95
- bits=FFI.type_size(:long)*8 if func==:long
96
- bits=FFI.type_size(:int64)*8 if func==:off_t
97
+ if va_type==:long or va_type==:int64 then
98
+ bits=FFI.type_size(va_type)*8
97
99
  tv=((value<0) ? value.abs-1 : value)
98
100
  raise Errors::InvalidValue.new(option,value) unless tv<(1<<bits)
99
101
  end
100
- send(FUNCS[type][func], handle, opthash[option][:opt], value)
102
+ send(FUNCS[type], handle, opthash[option][:opt], va_type, value)
101
103
  end
102
104
 
103
105
  OPTION_TYPE_BASE = {
@@ -136,6 +138,7 @@ module Ethon
136
138
  :cbdata => :objectpoint,
137
139
  :callback => :functionpoint,
138
140
  :debug_callback => :functionpoint,
141
+ :progress_callback => :functionpoint,
139
142
  :off_t => :off_t,
140
143
  }
141
144
 
@@ -207,7 +210,7 @@ module Ethon
207
210
 
208
211
  option :multi, :socketfunction, :callback, 1
209
212
  option :multi, :socketdata, :cbdata, 2
210
- option :multi, :pipelining, :bool, 3
213
+ option :multi, :pipelining, :int, 3
211
214
  option :multi, :timerfunction, :callback, 4
212
215
  option :multi, :timerdata, :cbdata, 5
213
216
  option :multi, :maxconnects, :int, 6
@@ -247,7 +250,8 @@ module Ethon
247
250
  option :easy, :opensocketdata, :cbdata, 164
248
251
  option :easy, :closesocketfunction, :callback, 208
249
252
  option :easy, :closesocketdata, :cbdata, 209
250
- option :easy, :progressfunction, :callback, 56
253
+ option :easy, :path_as_is, :bool, 234
254
+ option :easy, :progressfunction, :progress_callback, 56
251
255
  option :easy, :progressdata, :cbdata, 57
252
256
  option :easy, :headerfunction, :callback, 79
253
257
  option :easy, :writeheader, :cbdata, 29
@@ -266,6 +270,8 @@ module Ethon
266
270
  option :easy, :chunk_data, :cbdata, 201
267
271
  option :easy, :fnmatch_function, :callback, 200
268
272
  option :easy, :fnmatch_data, :cbdata, 202
273
+ option :easy, :xferinfofunction, :progress_callback, 219
274
+ option :easy, :xferinfodata, :cbdata, 57
269
275
  ## ERROR OPTIONS
270
276
  option :easy, :errorbuffer, :buffer, 10, 256
271
277
  option :easy, :stderr, :dontuse_object, 37
@@ -286,6 +292,9 @@ module Ethon
286
292
  option :easy, :localportrange, :int, 140
287
293
  option :easy, :dns_cache_timeout, :int, 92
288
294
  option :easy, :dns_use_global_cache, :bool, 91 # Obsolete
295
+ option :easy, :dns_interface, :string, 221
296
+ option :easy, :dns_local_ip4, :string, 222
297
+ option :easy, :dns_shuffle_addresses, :bool, 275
289
298
  option :easy, :buffersize, :int, 98
290
299
  option :easy, :port, :int, 3
291
300
  option :easy, :tcp_nodelay, :bool, 121
@@ -335,7 +344,7 @@ module Ethon
335
344
  option :easy, :cookiesession, :bool, 96
336
345
  option :easy, :cookielist, :string, 135
337
346
  option :easy, :httpget, :bool, 80
338
- option :easy, :http_version, :enum, 84, [:none, :httpv1_0, :httpv1_1]
347
+ option :easy, :http_version, :enum, 84, [:none, :httpv1_0, :httpv1_1, :httpv2_0]
339
348
  option :easy, :ignore_content_length, :bool, 136
340
349
  option :easy, :http_content_decoding, :bool, 158
341
350
  option :easy, :http_transfer_decoding, :bool, 157
@@ -411,6 +420,7 @@ module Ethon
411
420
  option :easy, :dns_servers, :string, 211
412
421
  option :easy, :accepttimeout_ms, :int, 212
413
422
  option :easy, :unix_socket_path, :string, 231
423
+ option :easy, :pipewait, :bool, 237
414
424
  option_alias :easy, :unix_socket_path, :unix_socket
415
425
  ## SSL and SECURITY OPTIONS
416
426
  option :easy, :sslcert, :string, 25
@@ -438,6 +448,8 @@ module Ethon
438
448
  option :easy, :krblevel, :string, 63
439
449
  option_alias :easy, :krblevel, :krb4level
440
450
  option :easy, :gssapi_delegation, :bitmask, 210, [:none, :policy_flag, :flag]
451
+ option :easy, :pinnedpublickey, :string, 230
452
+ option_alias :easy, :pinnedpublickey, :pinned_public_key
441
453
  ## SSH OPTIONS
442
454
  option :easy, :ssh_auth_types, :bitmask, 151, [:none, :publickey, :password, :host, :keyboard, :agent, {:any => [:all], :default => [:any]}]
443
455
  option :easy, :ssh_host_public_key_md5, :string, 162