ethon 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +41 -0
  3. data/CHANGELOG.md +3 -0
  4. data/Gemfile +5 -0
  5. data/Guardfile +1 -0
  6. data/README.md +1 -1
  7. data/Rakefile +1 -0
  8. data/ethon.gemspec +2 -1
  9. data/lib/ethon.rb +2 -0
  10. data/lib/ethon/curl.rb +1 -0
  11. data/lib/ethon/curls/classes.rb +2 -1
  12. data/lib/ethon/curls/codes.rb +1 -1
  13. data/lib/ethon/curls/constants.rb +1 -0
  14. data/lib/ethon/curls/form_options.rb +1 -0
  15. data/lib/ethon/curls/functions.rb +4 -13
  16. data/lib/ethon/curls/infos.rb +4 -3
  17. data/lib/ethon/curls/messages.rb +1 -0
  18. data/lib/ethon/curls/options.rb +24 -21
  19. data/lib/ethon/curls/settings.rb +1 -0
  20. data/lib/ethon/easy.rb +1 -1
  21. data/lib/ethon/easy/callbacks.rb +4 -3
  22. data/lib/ethon/easy/debug_info.rb +1 -0
  23. data/lib/ethon/easy/features.rb +1 -0
  24. data/lib/ethon/easy/form.rb +1 -0
  25. data/lib/ethon/easy/header.rb +1 -0
  26. data/lib/ethon/easy/http.rb +1 -0
  27. data/lib/ethon/easy/http/actionable.rb +1 -0
  28. data/lib/ethon/easy/http/custom.rb +1 -0
  29. data/lib/ethon/easy/http/delete.rb +1 -0
  30. data/lib/ethon/easy/http/get.rb +1 -0
  31. data/lib/ethon/easy/http/head.rb +1 -0
  32. data/lib/ethon/easy/http/options.rb +1 -0
  33. data/lib/ethon/easy/http/patch.rb +1 -0
  34. data/lib/ethon/easy/http/post.rb +1 -0
  35. data/lib/ethon/easy/http/postable.rb +1 -0
  36. data/lib/ethon/easy/http/put.rb +1 -0
  37. data/lib/ethon/easy/http/putable.rb +1 -0
  38. data/lib/ethon/easy/informations.rb +1 -0
  39. data/lib/ethon/easy/mirror.rb +1 -0
  40. data/lib/ethon/easy/operations.rb +16 -1
  41. data/lib/ethon/easy/options.rb +1 -0
  42. data/lib/ethon/easy/params.rb +1 -0
  43. data/lib/ethon/easy/queryable.rb +1 -0
  44. data/lib/ethon/easy/response_callbacks.rb +1 -0
  45. data/lib/ethon/easy/util.rb +1 -0
  46. data/lib/ethon/errors.rb +1 -0
  47. data/lib/ethon/errors/ethon_error.rb +1 -0
  48. data/lib/ethon/errors/global_init.rb +1 -0
  49. data/lib/ethon/errors/invalid_option.rb +1 -0
  50. data/lib/ethon/errors/invalid_value.rb +1 -0
  51. data/lib/ethon/errors/multi_add.rb +1 -0
  52. data/lib/ethon/errors/multi_fdset.rb +1 -0
  53. data/lib/ethon/errors/multi_remove.rb +1 -0
  54. data/lib/ethon/errors/multi_timeout.rb +1 -0
  55. data/lib/ethon/errors/select.rb +1 -0
  56. data/lib/ethon/libc.rb +16 -1
  57. data/lib/ethon/loggable.rb +1 -0
  58. data/lib/ethon/multi.rb +1 -0
  59. data/lib/ethon/multi/operations.rb +1 -0
  60. data/lib/ethon/multi/options.rb +1 -0
  61. data/lib/ethon/multi/stack.rb +1 -0
  62. data/lib/ethon/version.rb +2 -1
  63. data/profile/benchmarks.rb +1 -0
  64. data/profile/memory_leaks.rb +1 -0
  65. data/profile/perf_spec_helper.rb +1 -0
  66. data/profile/support/memory_test_helpers.rb +1 -0
  67. data/profile/support/os_memory_leak_tracker.rb +1 -0
  68. data/profile/support/ruby_object_leak_tracker.rb +1 -0
  69. data/spec/ethon/curl_spec.rb +1 -0
  70. data/spec/ethon/easy/callbacks_spec.rb +1 -0
  71. data/spec/ethon/easy/debug_info_spec.rb +1 -0
  72. data/spec/ethon/easy/features_spec.rb +1 -0
  73. data/spec/ethon/easy/form_spec.rb +1 -0
  74. data/spec/ethon/easy/header_spec.rb +1 -0
  75. data/spec/ethon/easy/http/custom_spec.rb +1 -0
  76. data/spec/ethon/easy/http/delete_spec.rb +1 -0
  77. data/spec/ethon/easy/http/get_spec.rb +1 -0
  78. data/spec/ethon/easy/http/head_spec.rb +1 -0
  79. data/spec/ethon/easy/http/options_spec.rb +1 -0
  80. data/spec/ethon/easy/http/patch_spec.rb +1 -0
  81. data/spec/ethon/easy/http/post_spec.rb +1 -0
  82. data/spec/ethon/easy/http/put_spec.rb +1 -0
  83. data/spec/ethon/easy/http_spec.rb +1 -0
  84. data/spec/ethon/easy/informations_spec.rb +1 -0
  85. data/spec/ethon/easy/mirror_spec.rb +1 -0
  86. data/spec/ethon/easy/operations_spec.rb +1 -0
  87. data/spec/ethon/easy/options_spec.rb +2 -1
  88. data/spec/ethon/easy/queryable_spec.rb +1 -0
  89. data/spec/ethon/easy/response_callbacks_spec.rb +1 -0
  90. data/spec/ethon/easy/util_spec.rb +1 -0
  91. data/spec/ethon/easy_spec.rb +3 -2
  92. data/spec/ethon/libc_spec.rb +4 -3
  93. data/spec/ethon/loggable_spec.rb +1 -0
  94. data/spec/ethon/multi/operations_spec.rb +1 -0
  95. data/spec/ethon/multi/options_spec.rb +1 -0
  96. data/spec/ethon/multi/stack_spec.rb +1 -0
  97. data/spec/ethon/multi_spec.rb +1 -0
  98. data/spec/spec_helper.rb +1 -0
  99. data/spec/support/localhost_server.rb +2 -1
  100. data/spec/support/server.rb +1 -0
  101. metadata +6 -7
  102. data/.travis.yml +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d849b2843c88fd4277aac9caa8b9e50b93ec7d3cf7805c4eb3c06dcfb6ee9959
4
- data.tar.gz: 61b75662bc26c23ce525eb7b98ea2404308d3cd1c6912e92b7acbedabaf95944
3
+ metadata.gz: 558abec878f87a7e13113e513faf1dc5970cfcc12d3b0a8d4faaec50e847e1c9
4
+ data.tar.gz: 979dbda54e8b12f1a93fee6bb16db05c1960719f44c7d2152e5d9aaddd783d4e
5
5
  SHA512:
6
- metadata.gz: c586fb2b19fa35183ee81aaa685ddae7cbebbe55c80166dc20256f6d14181cfc15fe31f88b8951f474d05be77246201c24a8b27dc92a10c0ac177842f4d4c522
7
- data.tar.gz: ef4b60756f41c27873cc8c4e7d7ab1d140ec24b6940dedcafc2920d7d7fa5d11e06a437e39c38742b4ac2e7041ad89f1b49f68566b5b90063cbf581b0efc78b2
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/CHANGELOG.md CHANGED
@@ -8,6 +8,9 @@
8
8
 
9
9
  [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.11.0...v0.12.0)
10
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
+
11
14
  ## 0.11.0
12
15
 
13
16
  [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.10.1...v0.11.0)
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source "https://rubygems.org"
2
3
  gemspec
3
4
 
@@ -29,6 +30,10 @@ group :development, :test do
29
30
  elsif Gem.ruby_version >= Gem::Version.new("2.0.0")
30
31
  gem "mustermann", "0.3.1"
31
32
  end
33
+
34
+ if Gem.ruby_version >= Gem::Version.new("3.0.0")
35
+ gem "webrick"
36
+ end
32
37
  end
33
38
 
34
39
  group :perf do
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,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/ethon.svg)](https://badge.fury.io/rb/ethon)
2
- [![Build Status](https://travis-ci.org/typhoeus/ethon.svg?branch=master)](https://travis-ci.org/typhoeus/ethon)
2
+ [![Build Status](https://github.com/typhoeus/ethon/workflows/Ruby/badge.svg)](https://github.com/typhoeus/ethon/actions/workflows/ruby.yml)
3
3
 
4
4
  # Ethon
5
5
 
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,14 +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_progress_callback, :curl_easy_setopt, [:pointer, :easy_option, :progress_callback], :easy_code
23
- 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
24
19
  base.instance_variable_set(:@blocking, true)
25
20
  base.attach_function :easy_perform, :curl_easy_perform, [:pointer], :easy_code
26
21
  base.attach_function :easy_strerror, :curl_easy_strerror, [:easy_code], :string
@@ -40,11 +35,7 @@ module Ethon
40
35
  base.attach_function :multi_timeout, :curl_multi_timeout, [:pointer, :pointer], :multi_code
41
36
  base.attach_function :multi_fdset, :curl_multi_fdset, [:pointer, Curl::FDSet.ptr, Curl::FDSet.ptr, Curl::FDSet.ptr, :pointer], :multi_code
42
37
  base.attach_function :multi_strerror, :curl_multi_strerror, [:int], :string
43
- base.attach_function :multi_setopt_ffipointer, :curl_multi_setopt, [:pointer, :multi_option, :pointer], :multi_code
44
- base.attach_function :multi_setopt_string, :curl_multi_setopt, [:pointer, :multi_option, :string], :multi_code
45
- base.attach_function :multi_setopt_long, :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_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
48
39
 
49
40
  base.attach_function :version, :curl_version, [], :string
50
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, :progress_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,27 +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
87
  raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc
88
88
  when :progress_callback
89
- func=:progress_callback
89
+ va_type=:progress_callback
90
90
  raise Errors::InvalidValue.new(option,value) unless value.nil? or value.is_a? Proc
91
91
  when :off_t
92
92
  return if value.nil?
93
- func=:off_t
93
+ va_type=:int64
94
94
  value=value.to_i
95
95
  end
96
96
 
97
- if func==:long or func==:off_t then
98
- bits=FFI.type_size(:long)*8 if func==:long
99
- 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
100
99
  tv=((value<0) ? value.abs-1 : value)
101
100
  raise Errors::InvalidValue.new(option,value) unless tv<(1<<bits)
102
101
  end
103
- send(FUNCS[type][func], handle, opthash[option][:opt], value)
102
+ send(FUNCS[type], handle, opthash[option][:opt], va_type, value)
104
103
  end
105
104
 
106
105
  OPTION_TYPE_BASE = {
@@ -251,6 +250,7 @@ module Ethon
251
250
  option :easy, :opensocketdata, :cbdata, 164
252
251
  option :easy, :closesocketfunction, :callback, 208
253
252
  option :easy, :closesocketdata, :cbdata, 209
253
+ option :easy, :path_as_is, :bool, 234
254
254
  option :easy, :progressfunction, :progress_callback, 56
255
255
  option :easy, :progressdata, :cbdata, 57
256
256
  option :easy, :headerfunction, :callback, 79
@@ -294,6 +294,7 @@ module Ethon
294
294
  option :easy, :dns_use_global_cache, :bool, 91 # Obsolete
295
295
  option :easy, :dns_interface, :string, 221
296
296
  option :easy, :dns_local_ip4, :string, 222
297
+ option :easy, :dns_shuffle_addresses, :bool, 275
297
298
  option :easy, :buffersize, :int, 98
298
299
  option :easy, :port, :int, 3
299
300
  option :easy, :tcp_nodelay, :bool, 121
@@ -447,6 +448,8 @@ module Ethon
447
448
  option :easy, :krblevel, :string, 63
448
449
  option_alias :easy, :krblevel, :krb4level
449
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
450
453
  ## SSH OPTIONS
451
454
  option :easy, :ssh_auth_types, :bitmask, 151, [:none, :publickey, :password, :host, :keyboard, :agent, {:any => [:all], :default => [:any]}]
452
455
  option :easy, :ssh_host_public_key_md5, :string, 162
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Curl
3
4
  callback :callback, [:pointer, :size_t, :size_t, :pointer], :size_t
data/lib/ethon/easy.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon/easy/informations'
2
3
  require 'ethon/easy/features'
3
4
  require 'ethon/easy/callbacks'
@@ -159,7 +160,6 @@ module Ethon
159
160
  # * :recv_error: Failure with receiving network data.
160
161
  # * :ssl_certproblem: problem with the local client certificate.
161
162
  # * :ssl_cipher: Couldn't use specified cipher.
162
- # * :ssl_cacert: Peer certificate cannot be authenticated with known CA certificates.
163
163
  # * :bad_content_encoding: Unrecognized transfer encoding.
164
164
  # * :ldap_invalid_url: Invalid LDAP URL.
165
165
  # * :filesize_exceeded: Maximum file size exceeded.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
 
@@ -22,8 +23,8 @@ module Ethon
22
23
  Curl.set_option(:writefunction, body_write_callback, handle)
23
24
  Curl.set_option(:headerfunction, header_write_callback, handle)
24
25
  Curl.set_option(:debugfunction, debug_callback, handle)
25
- @response_body = ""
26
- @response_headers = ""
26
+ @response_body = String.new
27
+ @response_headers = String.new
27
28
  @headers_called = false
28
29
  @debug_info = Ethon::Easy::DebugInfo.new
29
30
  end
@@ -60,7 +61,7 @@ module Ethon
60
61
  # write the raw http request headers.
61
62
  #
62
63
  # @example Return the callback.
63
- # easy.body_write_callback
64
+ # easy.debug_callback
64
65
  #
65
66
  # @return [ Proc ] The callback.
66
67
  def debug_callback
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon/easy/util'
2
3
  require 'ethon/easy/queryable'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  # This module contains the logic around adding headers to libcurl.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon/easy/http/actionable'
2
3
  require 'ethon/easy/http/post'
3
4
  require 'ethon/easy/http/get'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon/easy/http/putable'
2
3
  require 'ethon/easy/http/postable'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  module Http
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  class Mirror
@@ -1,8 +1,23 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
  # This module contains the logic to prepare and perform
4
5
  # an easy.
5
6
  module Operations
7
+
8
+ class PointerHelper
9
+ class<<self
10
+ def synchronize( &block )
11
+ (@mutex ||= Mutex.new).synchronize( &block )
12
+ end
13
+
14
+ def release( pointer )
15
+ synchronize { Curl.easy_cleanup pointer }
16
+ end
17
+ end
18
+ synchronize{}
19
+ end
20
+
6
21
  # Returns a pointer to the curl easy handle.
7
22
  #
8
23
  # @example Return the handle.
@@ -10,7 +25,7 @@ module Ethon
10
25
  #
11
26
  # @return [ FFI::Pointer ] A pointer to the curl easy handle.
12
27
  def handle
13
- @handle ||= FFI::AutoPointer.new(Curl.easy_init, Curl.method(:easy_cleanup))
28
+ @handle ||= FFI::AutoPointer.new(Curl.easy_init, PointerHelper.method(:release) )
14
29
  end
15
30
 
16
31
  # Sets a pointer to the curl easy handle.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon/easy/util'
2
3
  require 'ethon/easy/queryable'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Easy # :nodoc:
3
4
 
data/lib/ethon/errors.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon/errors/ethon_error'
2
3
  require 'ethon/errors/global_init'
3
4
  require 'ethon/errors/multi_timeout'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  module Errors
3
4
 
data/lib/ethon/libc.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
 
3
4
  # FFI Wrapper module for Libc.
@@ -13,7 +14,21 @@ module Ethon
13
14
  end
14
15
 
15
16
  unless windows?
16
- attach_function :getdtablesize, [], :int
17
+ fcg = FFI::ConstGenerator.new do |gen|
18
+ gen.include 'unistd.h'
19
+ %w[
20
+ _SC_OPEN_MAX
21
+ ].each do |const|
22
+ ruby_name = const.sub(/^_SC_/, '').downcase.to_sym
23
+ gen.const(const, "%d", nil, ruby_name, &:to_i)
24
+ end
25
+ end
26
+
27
+ CONF = enum(*fcg.constants.map{|_, const|
28
+ [const.ruby_name, const.converted_value]
29
+ }.flatten)
30
+
31
+ attach_function :sysconf, [CONF], :long
17
32
  attach_function :free, [:pointer], :void
18
33
  end
19
34
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module Ethon
3
4
 
4
5
  # Contains logging behaviour.
data/lib/ethon/multi.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon/easy/util'
2
3
  require 'ethon/multi/stack'
3
4
  require 'ethon/multi/operations'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Multi # :nodoc
3
4
  # This module contains logic to run a multi.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Multi
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
  class Multi
3
4
 
data/lib/ethon/version.rb CHANGED
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module Ethon
2
3
 
3
4
  # Ethon version.
4
- VERSION = '0.12.0'
5
+ VERSION = '0.13.0'
5
6
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'ethon'
3
4
  require 'open-uri'
4
5
  require 'patron'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ethon'
2
3
  require 'ethon/easy'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #### SETUP
2
3
  require 'bundler'
3
4
  Bundler.setup
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'ruby_object_leak_tracker'
2
3
  require_relative 'os_memory_leak_tracker'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class OSMemoryLeakTracker
2
3
  attr_reader :current_run
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class RubyObjectLeakTracker
2
3
  attr_reader :previous_count_hash, :current_count_hash
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Curl do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Callbacks do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::DebugInfo do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Informations do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Form do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Header do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http::Custom do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http::Delete do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http::Get do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http::Head do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http::Options do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http::Patch do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http::Post do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http::Put do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Http do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Informations do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Mirror do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Operations do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Options do
@@ -12,7 +13,7 @@ describe Ethon::Easy::Options do
12
13
  :proxyuserpwd, :readdata, :readfunction, :redir_protocols, :ssl_verifyhost,
13
14
  :ssl_verifypeer, :sslcert, :sslcerttype, :sslkey, :sslkeytype, :sslversion,
14
15
  :timeout, :timeout_ms, :unrestricted_auth, :upload, :url, :useragent,
15
- :userpwd, :verbose, :pipewait
16
+ :userpwd, :verbose, :pipewait, :dns_shuffle_addresses, :path_as_is
16
17
  ].each do |name|
17
18
  describe "#{name}=" do
18
19
  it "responds_to" do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'spec_helper'
3
4
 
4
5
  describe Ethon::Easy::Queryable do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::ResponseCallbacks do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy::Util do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Easy do
@@ -106,8 +107,8 @@ describe Ethon::Easy do
106
107
  easy.on_complete { 'on_complete' }
107
108
  easy.on_headers { 'on_headers' }
108
109
  easy.on_progress { 'on_progress' }
109
- easy.response_body = 'test_body'
110
- easy.response_headers = 'test_headers'
110
+ easy.response_body = String.new('test_body')
111
+ easy.response_headers = String.new('test_headers')
111
112
  easy
112
113
  end
113
114
  let!(:e) { easy.dup }
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Libc do
4
- describe "#getdtablesize", :if => !Ethon::Curl.windows? do
5
+ describe "#sysconf(:open_max)", :if => !Ethon::Curl.windows? do
5
6
  it "returns an integer" do
6
- expect(Ethon::Libc.getdtablesize).to be_a(Integer)
7
+ expect(Ethon::Libc.sysconf(:open_max)).to be_a(Integer)
7
8
  end
8
9
 
9
10
  it "returns bigger zero", :if => !Ethon::Curl.windows? do
10
- expect(Ethon::Libc.getdtablesize).to_not be_zero
11
+ expect(Ethon::Libc.sysconf(:open_max)).to_not be_zero
11
12
  end
12
13
  end
13
14
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "spec_helper"
2
3
 
3
4
  describe Ethon::Loggable do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Multi::Operations do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Multi::Options do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Multi::Stack do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Ethon::Multi do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rack'
2
3
  require 'rack/handler/webrick'
3
4
  require 'net/http'
@@ -43,7 +44,7 @@ class LocalhostServer
43
44
  # Use WEBrick since it's part of the ruby standard library and is available on all ruby interpreters.
44
45
  options = { :Port => port }
45
46
  options.merge!(:AccessLog => [], :Logger => WEBrick::BasicLog.new(StringIO.new)) unless ENV['VERBOSE_SERVER']
46
- Rack::Handler::WEBrick.run(Identify.new(@rack_app), options)
47
+ Rack::Handler::WEBrick.run(Identify.new(@rack_app), **options)
47
48
  end
48
49
 
49
50
  def booted?
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  require 'json'
3
4
  require 'zlib'
4
5
  require 'sinatra/base'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hans Hasselberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2021-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: 1.15.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.0
26
+ version: 1.15.0
27
27
  description: Very lightweight libcurl wrapper.
28
28
  email:
29
29
  - me@hans.io
@@ -31,9 +31,9 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".github/workflows/ruby.yml"
34
35
  - ".gitignore"
35
36
  - ".rspec"
36
- - ".travis.yml"
37
37
  - CHANGELOG.md
38
38
  - Gemfile
39
39
  - Guardfile
@@ -152,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: 1.3.6
154
154
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.7.6
155
+ rubygems_version: 3.0.3
157
156
  signing_key:
158
157
  specification_version: 4
159
158
  summary: Libcurl wrapper.
data/.travis.yml DELETED
@@ -1,30 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- sudo: false
4
-
5
- bundler_args: --without perf
6
- script: bundle exec rake
7
- before_install:
8
- - gem install bundler
9
-
10
- rvm:
11
- - 1.8.7
12
- - 1.9.2
13
- - 1.9.3
14
- - 2.0.0-p648
15
- - 2.1.10
16
- - 2.2.10
17
- - 2.3.7
18
- - 2.4.4
19
- - 2.5.1
20
- - ruby-head
21
- - ree
22
- - jruby-18mode
23
- - jruby-19mode
24
- - jruby-head
25
-
26
- matrix:
27
- allow_failures:
28
- - rvm: ree
29
- - rvm: ruby-head
30
- - rvm: jruby-head