ethon 0.16.0 → 0.18.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -1
  3. data/README.md +1 -1
  4. data/ethon.gemspec +15 -4
  5. data/lib/ethon/curls/codes.rb +3 -2
  6. data/lib/ethon/easy/callbacks.rb +11 -5
  7. data/lib/ethon/loggable.rb +0 -1
  8. data/lib/ethon/version.rb +1 -1
  9. metadata +26 -86
  10. data/.github/workflows/ruby.yml +0 -41
  11. data/.gitignore +0 -8
  12. data/.rspec +0 -3
  13. data/Gemfile +0 -43
  14. data/Guardfile +0 -10
  15. data/Rakefile +0 -40
  16. data/profile/benchmarks.rb +0 -104
  17. data/profile/memory_leaks.rb +0 -114
  18. data/profile/perf_spec_helper.rb +0 -37
  19. data/profile/support/memory_test_helpers.rb +0 -76
  20. data/profile/support/os_memory_leak_tracker.rb +0 -48
  21. data/profile/support/ruby_object_leak_tracker.rb +0 -49
  22. data/spec/ethon/curl_spec.rb +0 -38
  23. data/spec/ethon/easy/callbacks_spec.rb +0 -81
  24. data/spec/ethon/easy/debug_info_spec.rb +0 -54
  25. data/spec/ethon/easy/features_spec.rb +0 -24
  26. data/spec/ethon/easy/form_spec.rb +0 -104
  27. data/spec/ethon/easy/header_spec.rb +0 -79
  28. data/spec/ethon/easy/http/custom_spec.rb +0 -177
  29. data/spec/ethon/easy/http/delete_spec.rb +0 -21
  30. data/spec/ethon/easy/http/get_spec.rb +0 -126
  31. data/spec/ethon/easy/http/head_spec.rb +0 -80
  32. data/spec/ethon/easy/http/options_spec.rb +0 -51
  33. data/spec/ethon/easy/http/patch_spec.rb +0 -51
  34. data/spec/ethon/easy/http/post_spec.rb +0 -317
  35. data/spec/ethon/easy/http/put_spec.rb +0 -168
  36. data/spec/ethon/easy/http_spec.rb +0 -64
  37. data/spec/ethon/easy/informations_spec.rb +0 -126
  38. data/spec/ethon/easy/mirror_spec.rb +0 -47
  39. data/spec/ethon/easy/operations_spec.rb +0 -271
  40. data/spec/ethon/easy/options_spec.rb +0 -193
  41. data/spec/ethon/easy/queryable_spec.rb +0 -235
  42. data/spec/ethon/easy/response_callbacks_spec.rb +0 -152
  43. data/spec/ethon/easy/util_spec.rb +0 -28
  44. data/spec/ethon/easy_spec.rb +0 -203
  45. data/spec/ethon/libc_spec.rb +0 -14
  46. data/spec/ethon/loggable_spec.rb +0 -22
  47. data/spec/ethon/multi/operations_spec.rb +0 -298
  48. data/spec/ethon/multi/options_spec.rb +0 -182
  49. data/spec/ethon/multi/stack_spec.rb +0 -80
  50. data/spec/ethon/multi_spec.rb +0 -152
  51. data/spec/spec_helper.rb +0 -28
  52. data/spec/support/localhost_server.rb +0 -95
  53. 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: e74ebd7d77141ab9fd017ab9ed797e04ef6f92e55101908da06763df58227aae
4
+ data.tar.gz: f1c5369ccd4571c1973bd60ae841faa130c5f2c498c42c9e309dc2cfb2e0afa8
5
5
  SHA512:
6
- metadata.gz: b6ec09378cd37ec552caee9a9153fb9e0582a770b18da882ec27f59028799885e1a9d9d7c496f1cfb4803ba3eb14bdd5e508f930cdc9523d16747d2a87ba1dfb
7
- data.tar.gz: 77a50827108e8c6bc44f293bae5c2bfe6e871c94f40f93904ff611245143ef7900cf4cc2aa8a1511d0797dd80c03578e06b4e256f929deab544c73f9ef0d9e33
6
+ metadata.gz: 19b2774077a996085dc70146d1ee92737039ec42f23b8188640ae0ecb7cf0a566fb3ecc5aaca1d1e14471376be317065e26216c648b976f83c2f26ea1b00a46c
7
+ data.tar.gz: dae27d0dba5329237e96adf628b1492d34a9d202930d70e01778a27a82aef0dd876cf58864151d1151d479bad3489df1398ff2dc10348c6bdb2f65bcaf641d48
data/CHANGELOG.md CHANGED
@@ -2,7 +2,49 @@
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.18.0...master)
6
+
7
+ ## 0.18.0
8
+
9
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.17.0...v0.18.0)
10
+
11
+ * Fixed verbose mode attempting to print binary SSL data by replacing it with a summary.
12
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#265](https://github.com/typhoeus/ethon/pull/265))
13
+ * Fixed `on_headers` callbacks being called once per header line instead of once for all headers.
14
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#264](https://github.com/typhoeus/ethon/pull/264))
15
+ * Stabilized test server boot on macOS by fixing IPv6/IPv4 localhost resolution and preventing orphaned processes.
16
+ ([Geremia Taglialatela](https://github.com/tagliala), [#261](https://github.com/typhoeus/ethon/pull/261))
17
+ * Added `logger` to runtime dependencies for Ruby 3.5+ compatibility.
18
+ ([Geremia Taglialatela](https://github.com/tagliala), [#259](https://github.com/typhoeus/ethon/pull/259))
19
+ * Opted-in for MFA requirement explicitly by adding `rubygems_mfa_required` metadata.
20
+ ([Geremia Taglialatela](https://github.com/tagliala), [#257](https://github.com/typhoeus/ethon/pull/257))
21
+ * Removed redundant encoding and require_relative checks.
22
+ ([Geremia Taglialatela](https://github.com/tagliala), [#258](https://github.com/typhoeus/ethon/pull/258))
23
+
24
+ ## 0.17.0
25
+
26
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.16.0...v0.17.0)
27
+
28
+ * Require Ruby 2.6+ and simplify Gemfile.
29
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#255](https://github.com/typhoeus/ethon/pull/255))
30
+ * Fixed mismatched libcurl error codes in `easy_codes` array.
31
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#253](https://github.com/typhoeus/ethon/pull/253))
32
+ * Add Ruby 3.3 and 3.4, remove Ruby 2.5 from CI matrix.
33
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#252](https://github.com/typhoeus/ethon/pull/252))
34
+ * Skip test due to libcurl 8.7.x bug in CURLINFO_REQUEST_SIZE.
35
+ ([Felipe Mesquita](https://github.com/felipedmesquita), [#251](https://github.com/typhoeus/ethon/pull/251))
36
+ * Use `Rackup::Handler.default` for Rack 3 compatibility.
37
+ ([Vít Ondruch](https://github.com/voxik), [#244](https://github.com/typhoeus/ethon/pull/244))
38
+ * Add Ruby 3.1 and 3.2 to the test matrix.
39
+ ([Orien Madgwick](https://github.com/orien), [#228](https://github.com/typhoeus/ethon/pull/228))
40
+ * Remove development and test files from the gem package.
41
+ ([Orien Madgwick](https://github.com/orien), [#227](https://github.com/typhoeus/ethon/pull/227))
42
+ * Fix missing parenthesis in example.
43
+ ([Aleksey Tsalolikhin](https://github.com/atsalolikhin-spokeo), [#226](https://github.com/typhoeus/ethon/pull/226))
44
+
45
+ ## 0.16.0
46
+
47
+ [Full Changelog](https://github.com/typhoeus/ethon/compare/v0.15.0...v0.16.0)
6
48
 
7
49
  * Added `redirect_url` value to available informations and `Easy::Mirror`.
8
50
  ([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
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
  lib = File.expand_path('../lib/', __FILE__)
4
3
  $:.unshift lib unless $:.include?(lib)
@@ -15,12 +14,24 @@ Gem::Specification.new do |s|
15
14
  s.summary = "Libcurl wrapper."
16
15
  s.description = "Very lightweight libcurl wrapper."
17
16
 
18
- s.required_rubygems_version = ">= 1.3.6"
17
+ s.required_ruby_version = ">= 2.6"
19
18
  s.license = 'MIT'
20
19
 
21
20
  s.add_dependency('ffi', ['>= 1.15.0'])
21
+ s.add_dependency('logger')
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'
29
+
30
+ s.metadata = {
31
+ 'bug_tracker_uri' => 'https://github.com/typhoeus/ethon/issues',
32
+ 'changelog_uri' => "https://github.com/typhoeus/ethon/blob/v#{s.version}/CHANGELOG.md",
33
+ 'documentation_uri' => "https://www.rubydoc.info/gems/ethon/#{s.version}",
34
+ 'rubygems_mfa_required' => 'true',
35
+ 'source_code_uri' => "https://github.com/typhoeus/ethon/tree/v#{s.version}"
36
+ }
26
37
  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,
@@ -37,10 +37,10 @@ module Ethon
37
37
  # @return [ Proc ] The callback.
38
38
  def body_write_callback
39
39
  @body_write_callback ||= proc do |stream, size, num, object|
40
- headers
40
+ headers_user_callback_result = headers
41
41
  result = body(chunk = stream.read_string(size * num))
42
42
  @response_body << chunk if result == :unyielded
43
- result != :abort ? size * num : -1
43
+ (result != :abort && headers_user_callback_result != :abort) ? size * num : -1
44
44
  end
45
45
  end
46
46
 
@@ -52,9 +52,8 @@ module Ethon
52
52
  # @return [ Proc ] The callback.
53
53
  def header_write_callback
54
54
  @header_write_callback ||= proc {|stream, size, num, object|
55
- result = headers
56
55
  @response_headers << stream.read_string(size * num)
57
- result != :abort ? size * num : -1
56
+ size * num
58
57
  }
59
58
  end
60
59
 
@@ -69,7 +68,14 @@ module Ethon
69
68
  @debug_callback ||= proc {|handle, type, data, size, udata|
70
69
  message = data.read_string(size)
71
70
  @debug_info.add type, message
72
- print message unless [:data_in, :data_out].include?(type)
71
+
72
+ if [:ssl_data_in, :ssl_data_out].include?(type)
73
+ print "[#{size} bytes data]\n"
74
+ elsif [:data_in, :data_out].include?(type)
75
+ # print "} [#{size} bytes data]\n"
76
+ else
77
+ print message
78
+ end
73
79
  0
74
80
  }
75
81
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
  module Ethon
4
3
 
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.18.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.18.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
@@ -24,6 +23,20 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: 1.15.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: logger
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
27
40
  description: Very lightweight libcurl wrapper.
28
41
  email:
29
42
  - me@hans.io
@@ -31,15 +44,9 @@ executables: []
31
44
  extensions: []
32
45
  extra_rdoc_files: []
33
46
  files:
34
- - ".github/workflows/ruby.yml"
35
- - ".gitignore"
36
- - ".rspec"
37
47
  - CHANGELOG.md
38
- - Gemfile
39
- - Guardfile
40
48
  - LICENSE
41
49
  - README.md
42
- - Rakefile
43
50
  - ethon.gemspec
44
51
  - lib/ethon.rb
45
52
  - lib/ethon/curl.rb
@@ -95,49 +102,15 @@ files:
95
102
  - lib/ethon/multi/options.rb
96
103
  - lib/ethon/multi/stack.rb
97
104
  - 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
105
  homepage: https://github.com/typhoeus/ethon
137
106
  licenses:
138
107
  - MIT
139
- metadata: {}
140
- post_install_message:
108
+ metadata:
109
+ bug_tracker_uri: https://github.com/typhoeus/ethon/issues
110
+ changelog_uri: https://github.com/typhoeus/ethon/blob/v0.18.0/CHANGELOG.md
111
+ documentation_uri: https://www.rubydoc.info/gems/ethon/0.18.0
112
+ rubygems_mfa_required: 'true'
113
+ source_code_uri: https://github.com/typhoeus/ethon/tree/v0.18.0
141
114
  rdoc_options: []
142
115
  require_paths:
143
116
  - lib
@@ -145,47 +118,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
118
  requirements:
146
119
  - - ">="
147
120
  - !ruby/object:Gem::Version
148
- version: '0'
121
+ version: '2.6'
149
122
  required_rubygems_version: !ruby/object:Gem::Requirement
150
123
  requirements:
151
124
  - - ">="
152
125
  - !ruby/object:Gem::Version
153
- version: 1.3.6
126
+ version: '0'
154
127
  requirements: []
155
- rubygems_version: 3.3.7
156
- signing_key:
128
+ rubygems_version: 3.7.1
157
129
  specification_version: 4
158
130
  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
131
+ 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