ethon 0.16.0 → 0.17.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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/README.md +1 -1
  4. data/ethon.gemspec +6 -3
  5. data/lib/ethon/curls/codes.rb +3 -2
  6. data/lib/ethon/version.rb +1 -1
  7. metadata +6 -85
  8. data/.github/workflows/ruby.yml +0 -41
  9. data/.gitignore +0 -8
  10. data/.rspec +0 -3
  11. data/Gemfile +0 -43
  12. data/Guardfile +0 -10
  13. data/Rakefile +0 -40
  14. data/profile/benchmarks.rb +0 -104
  15. data/profile/memory_leaks.rb +0 -114
  16. data/profile/perf_spec_helper.rb +0 -37
  17. data/profile/support/memory_test_helpers.rb +0 -76
  18. data/profile/support/os_memory_leak_tracker.rb +0 -48
  19. data/profile/support/ruby_object_leak_tracker.rb +0 -49
  20. data/spec/ethon/curl_spec.rb +0 -38
  21. data/spec/ethon/easy/callbacks_spec.rb +0 -81
  22. data/spec/ethon/easy/debug_info_spec.rb +0 -54
  23. data/spec/ethon/easy/features_spec.rb +0 -24
  24. data/spec/ethon/easy/form_spec.rb +0 -104
  25. data/spec/ethon/easy/header_spec.rb +0 -79
  26. data/spec/ethon/easy/http/custom_spec.rb +0 -177
  27. data/spec/ethon/easy/http/delete_spec.rb +0 -21
  28. data/spec/ethon/easy/http/get_spec.rb +0 -126
  29. data/spec/ethon/easy/http/head_spec.rb +0 -80
  30. data/spec/ethon/easy/http/options_spec.rb +0 -51
  31. data/spec/ethon/easy/http/patch_spec.rb +0 -51
  32. data/spec/ethon/easy/http/post_spec.rb +0 -317
  33. data/spec/ethon/easy/http/put_spec.rb +0 -168
  34. data/spec/ethon/easy/http_spec.rb +0 -64
  35. data/spec/ethon/easy/informations_spec.rb +0 -126
  36. data/spec/ethon/easy/mirror_spec.rb +0 -47
  37. data/spec/ethon/easy/operations_spec.rb +0 -271
  38. data/spec/ethon/easy/options_spec.rb +0 -193
  39. data/spec/ethon/easy/queryable_spec.rb +0 -235
  40. data/spec/ethon/easy/response_callbacks_spec.rb +0 -152
  41. data/spec/ethon/easy/util_spec.rb +0 -28
  42. data/spec/ethon/easy_spec.rb +0 -203
  43. data/spec/ethon/libc_spec.rb +0 -14
  44. data/spec/ethon/loggable_spec.rb +0 -22
  45. data/spec/ethon/multi/operations_spec.rb +0 -298
  46. data/spec/ethon/multi/options_spec.rb +0 -182
  47. data/spec/ethon/multi/stack_spec.rb +0 -80
  48. data/spec/ethon/multi_spec.rb +0 -152
  49. data/spec/spec_helper.rb +0 -28
  50. data/spec/support/localhost_server.rb +0 -95
  51. data/spec/support/server.rb +0 -115
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30f75feeae963db1b4648a0b88e028361c78fda7aec43524a35f93b287ab2305
4
- data.tar.gz: eb0ccd002c324dedaaceaa001172a61c520cd58e34d1a92440182faada17df74
3
+ metadata.gz: c8540ddcb77af693ed5b18a89ebcd126dd1e73e1c0d6f748d3ee2deec929fd7d
4
+ data.tar.gz: 62c1f741fb9bf87f914bb769a6e512bf01cf4e91b0f2393b6e63d3674bed12b7
5
5
  SHA512:
6
- metadata.gz: b6ec09378cd37ec552caee9a9153fb9e0582a770b18da882ec27f59028799885e1a9d9d7c496f1cfb4803ba3eb14bdd5e508f930cdc9523d16747d2a87ba1dfb
7
- data.tar.gz: 77a50827108e8c6bc44f293bae5c2bfe6e871c94f40f93904ff611245143ef7900cf4cc2aa8a1511d0797dd80c03578e06b4e256f929deab544c73f9ef0d9e33
6
+ metadata.gz: 85604eb698147db21a2e20d83b2cbdca48d0beea0d8485a9aa992450a5dc13b3033faa1f8fa14f33faefbc71ceea317945211b116e13dd4a189b9a60963aa5fa
7
+ data.tar.gz: ed6a4381cafd5acfc1a9c5c3482e0f7b7edbf9f757aa548e16e29a76670b8b7b08b53388f52c8df76b6afa8072974311341e5acbc4c78df07092c5eb14d492de
data/CHANGELOG.md CHANGED
@@ -2,7 +2,32 @@
2
2
 
3
3
  ## Master
4
4
 
5
- [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.15.0...master)
5
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.17.0...master)
6
+
7
+ ## 0.17.0
8
+
9
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.16.0...v0.17.0)
10
+
11
+ * Require Ruby 2.6+ and simplify Gemfile.
12
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#255](https://github.com/typhoeus/ethon/pull/255))
13
+ * Fixed mismatched libcurl error codes in `easy_codes` array.
14
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#253](https://github.com/typhoeus/ethon/pull/253))
15
+ * Add Ruby 3.3 and 3.4, remove Ruby 2.5 from CI matrix.
16
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#252](https://github.com/typhoeus/ethon/pull/252))
17
+ * Skip test due to libcurl 8.7.x bug in CURLINFO_REQUEST_SIZE.
18
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#251](https://github.com/typhoeus/ethon/pull/251))
19
+ * Use `Rackup::Handler.default` for Rack 3 compatibility.
20
+ ([Vít Ondruch](https://github.com/voxik), [#244](https://github.com/typhoeus/ethon/pull/244))
21
+ * Add Ruby 3.1 and 3.2 to the test matrix.
22
+ ([Orien Madgwick](https://github.com/orien), [#228](https://github.com/typhoeus/ethon/pull/228))
23
+ * Remove development and test files from the gem package.
24
+ ([Orien Madgwick](https://github.com/orien), [#227](https://github.com/typhoeus/ethon/pull/227))
25
+ * Fix missing parenthesis in example.
26
+ ([Aleksey Tsalolikhin](https://github.com/atsalolikhin-spokeo), [#226](https://github.com/typhoeus/ethon/pull/226))
27
+
28
+ ## 0.16.0
29
+
30
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.15.0...v0.16.0)
6
31
 
7
32
  * Added `redirect_url` value to available informations and `Easy::Mirror`.
8
33
  ([Adrien Rey-Jarthon](https://github.com/jarthod)
data/README.md CHANGED
@@ -87,7 +87,7 @@ easy.http_request("www.example.com/get", :get, { http_version: :httpv2_0 })
87
87
  easy.http_request("www.example.com/get", :get, { http_version: :httpv2_prior_knowledge })
88
88
 
89
89
  # To set the server to use http2 with https and http1 with http, send the following:
90
- easy.http_request("www.example.com/get", :get, { http_version: :httpv2_tls }
90
+ easy.http_request("www.example.com/get", :get, { http_version: :httpv2_tls })
91
91
 
92
92
  multi.add(easy)
93
93
  multi.perform
data/ethon.gemspec CHANGED
@@ -15,12 +15,15 @@ Gem::Specification.new do |s|
15
15
  s.summary = "Libcurl wrapper."
16
16
  s.description = "Very lightweight libcurl wrapper."
17
17
 
18
- s.required_rubygems_version = ">= 1.3.6"
18
+ s.required_ruby_version = ">= 2.6"
19
19
  s.license = 'MIT'
20
20
 
21
21
  s.add_dependency('ffi', ['>= 1.15.0'])
22
22
 
23
- s.files = `git ls-files`.split("\n")
24
- s.test_files = `git ls-files -- spec/*`.split("\n")
23
+ s.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |file|
25
+ file.start_with?(*%w[. Gemfile Guardfile Rakefile profile spec])
26
+ end
27
+ end
25
28
  s.require_path = 'lib'
26
29
  end
@@ -26,7 +26,7 @@ module Ethon
26
26
  :ftp_weird_pasv_reply,
27
27
  :ftp_weird_227_format,
28
28
  :ftp_cant_get_host,
29
- :obsolete16,
29
+ :http2,
30
30
  :ftp_couldnt_set_type,
31
31
  :partial_file,
32
32
  :ftp_couldnt_retr_file,
@@ -61,7 +61,7 @@ module Ethon
61
61
  :unknown_option,
62
62
  :telnet_option_syntax ,
63
63
  :obsolete50,
64
- :peer_failed_verification,
64
+ :obsolete51,
65
65
  :got_nothing,
66
66
  :ssl_engine_notfound,
67
67
  :ssl_engine_setfailed,
@@ -70,6 +70,7 @@ module Ethon
70
70
  :obsolete57,
71
71
  :ssl_certproblem,
72
72
  :ssl_cipher,
73
+ :peer_failed_verification,
73
74
  :bad_content_encoding,
74
75
  :ldap_invalid_url,
75
76
  :filesize_exceeded,
data/lib/ethon/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  module Ethon
3
3
 
4
4
  # Ethon version.
5
- VERSION = '0.16.0'
5
+ VERSION = '0.17.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hans Hasselberg
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-11-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: ffi
@@ -31,15 +30,9 @@ executables: []
31
30
  extensions: []
32
31
  extra_rdoc_files: []
33
32
  files:
34
- - ".github/workflows/ruby.yml"
35
- - ".gitignore"
36
- - ".rspec"
37
33
  - CHANGELOG.md
38
- - Gemfile
39
- - Guardfile
40
34
  - LICENSE
41
35
  - README.md
42
- - Rakefile
43
36
  - ethon.gemspec
44
37
  - lib/ethon.rb
45
38
  - lib/ethon/curl.rb
@@ -95,49 +88,10 @@ files:
95
88
  - lib/ethon/multi/options.rb
96
89
  - lib/ethon/multi/stack.rb
97
90
  - lib/ethon/version.rb
98
- - profile/benchmarks.rb
99
- - profile/memory_leaks.rb
100
- - profile/perf_spec_helper.rb
101
- - profile/support/memory_test_helpers.rb
102
- - profile/support/os_memory_leak_tracker.rb
103
- - profile/support/ruby_object_leak_tracker.rb
104
- - spec/ethon/curl_spec.rb
105
- - spec/ethon/easy/callbacks_spec.rb
106
- - spec/ethon/easy/debug_info_spec.rb
107
- - spec/ethon/easy/features_spec.rb
108
- - spec/ethon/easy/form_spec.rb
109
- - spec/ethon/easy/header_spec.rb
110
- - spec/ethon/easy/http/custom_spec.rb
111
- - spec/ethon/easy/http/delete_spec.rb
112
- - spec/ethon/easy/http/get_spec.rb
113
- - spec/ethon/easy/http/head_spec.rb
114
- - spec/ethon/easy/http/options_spec.rb
115
- - spec/ethon/easy/http/patch_spec.rb
116
- - spec/ethon/easy/http/post_spec.rb
117
- - spec/ethon/easy/http/put_spec.rb
118
- - spec/ethon/easy/http_spec.rb
119
- - spec/ethon/easy/informations_spec.rb
120
- - spec/ethon/easy/mirror_spec.rb
121
- - spec/ethon/easy/operations_spec.rb
122
- - spec/ethon/easy/options_spec.rb
123
- - spec/ethon/easy/queryable_spec.rb
124
- - spec/ethon/easy/response_callbacks_spec.rb
125
- - spec/ethon/easy/util_spec.rb
126
- - spec/ethon/easy_spec.rb
127
- - spec/ethon/libc_spec.rb
128
- - spec/ethon/loggable_spec.rb
129
- - spec/ethon/multi/operations_spec.rb
130
- - spec/ethon/multi/options_spec.rb
131
- - spec/ethon/multi/stack_spec.rb
132
- - spec/ethon/multi_spec.rb
133
- - spec/spec_helper.rb
134
- - spec/support/localhost_server.rb
135
- - spec/support/server.rb
136
91
  homepage: https://github.com/typhoeus/ethon
137
92
  licenses:
138
93
  - MIT
139
94
  metadata: {}
140
- post_install_message:
141
95
  rdoc_options: []
142
96
  require_paths:
143
97
  - lib
@@ -145,47 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
99
  requirements:
146
100
  - - ">="
147
101
  - !ruby/object:Gem::Version
148
- version: '0'
102
+ version: '2.6'
149
103
  required_rubygems_version: !ruby/object:Gem::Requirement
150
104
  requirements:
151
105
  - - ">="
152
106
  - !ruby/object:Gem::Version
153
- version: 1.3.6
107
+ version: '0'
154
108
  requirements: []
155
- rubygems_version: 3.3.7
156
- signing_key:
109
+ rubygems_version: 3.7.1
157
110
  specification_version: 4
158
111
  summary: Libcurl wrapper.
159
- test_files:
160
- - spec/ethon/curl_spec.rb
161
- - spec/ethon/easy/callbacks_spec.rb
162
- - spec/ethon/easy/debug_info_spec.rb
163
- - spec/ethon/easy/features_spec.rb
164
- - spec/ethon/easy/form_spec.rb
165
- - spec/ethon/easy/header_spec.rb
166
- - spec/ethon/easy/http/custom_spec.rb
167
- - spec/ethon/easy/http/delete_spec.rb
168
- - spec/ethon/easy/http/get_spec.rb
169
- - spec/ethon/easy/http/head_spec.rb
170
- - spec/ethon/easy/http/options_spec.rb
171
- - spec/ethon/easy/http/patch_spec.rb
172
- - spec/ethon/easy/http/post_spec.rb
173
- - spec/ethon/easy/http/put_spec.rb
174
- - spec/ethon/easy/http_spec.rb
175
- - spec/ethon/easy/informations_spec.rb
176
- - spec/ethon/easy/mirror_spec.rb
177
- - spec/ethon/easy/operations_spec.rb
178
- - spec/ethon/easy/options_spec.rb
179
- - spec/ethon/easy/queryable_spec.rb
180
- - spec/ethon/easy/response_callbacks_spec.rb
181
- - spec/ethon/easy/util_spec.rb
182
- - spec/ethon/easy_spec.rb
183
- - spec/ethon/libc_spec.rb
184
- - spec/ethon/loggable_spec.rb
185
- - spec/ethon/multi/operations_spec.rb
186
- - spec/ethon/multi/options_spec.rb
187
- - spec/ethon/multi/stack_spec.rb
188
- - spec/ethon/multi_spec.rb
189
- - spec/spec_helper.rb
190
- - spec/support/localhost_server.rb
191
- - spec/support/server.rb
112
+ test_files: []
@@ -1,41 +0,0 @@
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]
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 update && sudo apt install -y --no-install-recommends 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 DELETED
@@ -1,8 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- .DS_Store
5
- .yardoc
6
- doc
7
- coverage
8
- .idea
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --tty
2
- --color
3
- --format documentation
data/Gemfile DELETED
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
- source "https://rubygems.org"
3
- gemspec
4
-
5
- if Gem.ruby_version < Gem::Version.new("1.9.3")
6
- gem "rake", "< 11"
7
- else
8
- gem "rake"
9
- end
10
-
11
- group :development, :test do
12
- gem "rspec", "~> 3.4"
13
-
14
- gem "sinatra"
15
-
16
- if Gem.ruby_version < Gem::Version.new("2.0.0")
17
- gem "json", "< 2"
18
- else
19
- gem "json"
20
- end
21
-
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
33
-
34
- if Gem.ruby_version >= Gem::Version.new("3.0.0")
35
- gem "webrick"
36
- end
37
- end
38
-
39
- group :perf do
40
- gem "benchmark-ips"
41
- gem "patron"
42
- gem "curb"
43
- end
data/Guardfile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- # vim:set filetype=ruby:
3
- guard(
4
- "rspec",
5
- :all_after_pass => false,
6
- :cli => "--fail-fast --tty --format documentation --colour") do
7
-
8
- watch(%r{^spec/.+_spec\.rb$})
9
- watch(%r{^lib/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" }
10
- end
data/Rakefile DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
- require "bundler"
3
- Bundler.setup
4
-
5
- require "rake"
6
- require "rspec/core/rake_task"
7
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
8
- require "ethon/version"
9
-
10
- task :gem => :build
11
- task :build do
12
- system "gem build ethon.gemspec"
13
- end
14
-
15
- task :install => :build do
16
- system "gem install ethon-#{Ethon::VERSION}.gem"
17
- end
18
-
19
- task :release => :build do
20
- system "git tag -a v#{Ethon::VERSION} -m 'Tagging #{Ethon::VERSION}'"
21
- system "git push --tags"
22
- system "gem push ethon-#{Ethon::VERSION}.gem"
23
- end
24
-
25
- RSpec::Core::RakeTask.new(:spec) do |t|
26
- t.verbose = false
27
- t.ruby_opts = "-W -I./spec -rspec_helper"
28
- end
29
-
30
- desc "Start up the test servers"
31
- task :start do
32
- require_relative 'spec/support/boot'
33
- begin
34
- Boot.start_servers(:rake)
35
- rescue Exception
36
- end
37
- end
38
-
39
- task :default => :spec
40
-
@@ -1,104 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- require 'ethon'
4
- require 'open-uri'
5
- require 'patron'
6
- require 'curb'
7
- require 'net/http'
8
- require 'cgi'
9
- require 'benchmark/ips'
10
-
11
- require_relative '../spec/support/server'
12
- require_relative '../spec/support/localhost_server'
13
-
14
- LocalhostServer.new(TESTSERVER.new, 3000)
15
- LocalhostServer.new(TESTSERVER.new, 3001)
16
- LocalhostServer.new(TESTSERVER.new, 3002)
17
-
18
- url = 'http://localhost:3000/'.freeze
19
- uri = URI.parse('http://localhost:3000/').freeze
20
- ethon = Ethon::Easy.new(url: url)
21
- patron = Patron::Session.new
22
- patron_url = Patron::Session.new(base_url: url)
23
- curb = Curl::Easy.new(url)
24
-
25
- puts '[Creation]'
26
- Benchmark.ips do |x|
27
- x.report('String.new') { '' }
28
- x.report('Easy.new') { Ethon::Easy.new }
29
- end
30
-
31
- puts '[Escape]'
32
- Benchmark.ips do |x|
33
- x.report('CGI.escape') { CGI.escape("まつもと") }
34
- x.report('Easy.escape') { ethon.escape("まつもと") }
35
- end
36
-
37
- puts '[Requests]'
38
- Benchmark.ips do |x|
39
- x.report('net/http') { Net::HTTP.get_response(uri) }
40
- x.report('open-uri') { open url }
41
-
42
- x.report('patron') do
43
- patron.base_url = url
44
- patron.get('/')
45
- end
46
-
47
- x.report('patron reuse') { patron_url.get('/') }
48
-
49
- x.report('curb') do
50
- curb.url = url
51
- curb.perform
52
- end
53
-
54
- x.report('curb reuse') { curb.perform }
55
-
56
- x.report('Easy.perform') do
57
- ethon.url = url
58
- ethon.perform
59
- end
60
-
61
- x.report('Easy.perform reuse') { ethon.perform }
62
- end
63
-
64
- puts "[ 4 delayed Requests ]"
65
- Benchmark.ips do |x|
66
- x.report('net/http') do
67
- 3.times do |i|
68
- uri = URI.parse("http://localhost:300#{i}/?delay=1")
69
- Net::HTTP.get_response(uri)
70
- end
71
- end
72
-
73
- x.report("open-uri") do
74
- 3.times do |i|
75
- open("http://localhost:300#{i}/?delay=1")
76
- end
77
- end
78
-
79
- x.report("patron") do
80
- sess = Patron::Session.new
81
- 3.times do |i|
82
- sess.base_url = "http://localhost:300#{i}/?delay=1"
83
- sess.get("/")
84
- end
85
- end
86
-
87
- x.report("Easy.perform") do
88
- easy = Ethon::Easy.new
89
- 3.times do |i|
90
- easy.url = "http://localhost:300#{i}/?delay=1"
91
- easy.perform
92
- end
93
- end
94
-
95
- x.report("Multi.perform") do
96
- multi = Ethon::Multi.new
97
- 3.times do |i|
98
- easy = Ethon::Easy.new
99
- easy.url = "http://localhost:300#{i}/?delay=1"
100
- multi.add(easy)
101
- end
102
- multi.perform
103
- end
104
- end
@@ -1,114 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'ethon'
3
- require 'ethon/easy'
4
-
5
- require_relative 'perf_spec_helper'
6
- require 'rspec/autorun'
7
-
8
- describe "low-level interactions with libcurl" do
9
- describe Ethon::Multi do
10
- memory_leak_test("init") do
11
- Ethon::Multi.new
12
- end
13
-
14
- memory_leak_test("handle") do
15
- Ethon::Multi.new.handle
16
- end
17
- end
18
-
19
- describe Ethon::Easy do
20
- memory_leak_test("init") do
21
- Ethon::Easy.new
22
- end
23
-
24
- memory_leak_test("handle") do
25
- Ethon::Easy.new.handle
26
- end
27
-
28
- memory_leak_test("headers") do
29
- Ethon::Easy.new.headers = { "a" => 1, "b" => 2, "c" => 3, "d" => 4}
30
- end
31
-
32
- memory_leak_test("escape") do
33
- Ethon::Easy.new.escape("the_sky&is_blue")
34
- end
35
- end
36
-
37
-
38
- describe Ethon::Easy::Form do
39
- memory_leak_test("init") do
40
- Ethon::Easy::Form.new(nil, {})
41
- end
42
-
43
- memory_leak_test("first") do
44
- Ethon::Easy::Form.new(nil, {}).first
45
- end
46
-
47
- memory_leak_test("last") do
48
- Ethon::Easy::Form.new(nil, {}).last
49
- end
50
-
51
- memory_leak_test("materialized with some params") do
52
- form = Ethon::Easy::Form.new(nil, { "a" => "1" })
53
- form.materialize
54
- end
55
-
56
- memory_leak_test("materialized with a file") do
57
- File.open(__FILE__, "r") do |file|
58
- form = Ethon::Easy::Form.new(nil, { "a" => file })
59
- form.materialize
60
- end
61
- end
62
- end
63
- end
64
-
65
- describe "higher level operations" do
66
- memory_leak_test("a simple request") do
67
- Ethon::Easy.new(:url => "http://localhost:3001/",
68
- :forbid_reuse => true).perform
69
- end
70
-
71
- memory_leak_test("a request with headers") do
72
- Ethon::Easy.new(:url => "http://localhost:3001/",
73
- :headers => { "Content-Type" => "application/json",
74
- "Something" => "1",
75
- "Else" => "qwerty",
76
- "Long-String" => "aassddffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz"},
77
- :forbid_reuse => true).perform
78
- end
79
-
80
- memory_leak_test("a request with headers and params") do
81
- easy = Ethon::Easy.new(:url => "http://localhost:3001/",
82
- :headers => { "Content-Type" => "application/json",
83
- "Something" => "1",
84
- "Else" => "qwerty",
85
- "Long-String" => "aassddffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz"},
86
- :forbid_reuse => true)
87
- easy.http_request("http://localhost:3001/",
88
- :get,
89
- :params => { "param1" => "value1",
90
- "param2" => "value2",
91
- "param3" => "value3",
92
- "param4" => "value4"})
93
- end
94
-
95
- memory_leak_test("a request with headers, params, and body") do
96
- easy = Ethon::Easy.new(:url => "http://localhost:3001/",
97
- :headers => { "Content-Type" => "application/json",
98
- "Something" => "1",
99
- "Else" => "qwerty",
100
- "Long-String" => "aassddffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz"},
101
- :forbid_reuse => true)
102
- easy.http_request("http://localhost:3001/",
103
- :get,
104
- :params => { "param1" => "value1",
105
- "param2" => "value2",
106
- "param3" => "value3",
107
- "param4" => "value4"},
108
- :body => {
109
- "body1" => "value1",
110
- "body2" => "value2",
111
- "body3" => "value3"
112
- })
113
- end
114
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
- #### SETUP
3
- require 'bundler'
4
- Bundler.setup
5
- require 'rspec'
6
-
7
- require 'support/localhost_server'
8
- require 'support/server'
9
- require_relative 'support/memory_test_helpers'
10
-
11
- require 'logger'
12
-
13
- if ENV['VERBOSE']
14
- Ethon.logger = Logger.new($stdout)
15
- Ethon.logger.level = Logger::DEBUG
16
- end
17
-
18
- RSpec.configure do |config|
19
- config.before(:suite) do
20
- LocalhostServer.new(TESTSERVER.new, 3001)
21
- end
22
- config.include(MemoryTestHelpers)
23
- config.extend(MemoryTestHelpers::TestMethods)
24
- end
25
-
26
- MemoryTestHelpers.setup
27
- MemoryTestHelpers.logger = Logger.new($stdout)
28
- MemoryTestHelpers.logger.level = Logger::INFO
29
- MemoryTestHelpers.logger.formatter = proc do |severity, datetime, progname, msg|
30
- "\t\t#{msg}\n"
31
- end
32
-
33
- if ENV['VERBOSE']
34
- MemoryTestHelpers.logger.level = Logger::DEBUG
35
- end
36
-
37
- MemoryTestHelpers.iterations = ENV.fetch("ITERATIONS", 10_000).to_i