ethon 0.15.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -1
- data/README.md +23 -0
- data/ethon.gemspec +6 -3
- data/lib/ethon/curls/classes.rb +12 -2
- data/lib/ethon/curls/codes.rb +3 -2
- data/lib/ethon/curls/options.rb +4 -3
- data/lib/ethon/easy/callbacks.rb +2 -1
- data/lib/ethon/easy/informations.rb +3 -0
- data/lib/ethon/easy/response_callbacks.rb +6 -1
- data/lib/ethon/version.rb +1 -1
- metadata +6 -85
- data/.github/workflows/ruby.yml +0 -41
- data/.gitignore +0 -8
- data/.rspec +0 -3
- data/Gemfile +0 -43
- data/Guardfile +0 -10
- data/Rakefile +0 -40
- data/profile/benchmarks.rb +0 -104
- data/profile/memory_leaks.rb +0 -114
- data/profile/perf_spec_helper.rb +0 -37
- data/profile/support/memory_test_helpers.rb +0 -76
- data/profile/support/os_memory_leak_tracker.rb +0 -48
- data/profile/support/ruby_object_leak_tracker.rb +0 -49
- data/spec/ethon/curl_spec.rb +0 -38
- data/spec/ethon/easy/callbacks_spec.rb +0 -59
- data/spec/ethon/easy/debug_info_spec.rb +0 -54
- data/spec/ethon/easy/features_spec.rb +0 -24
- data/spec/ethon/easy/form_spec.rb +0 -104
- data/spec/ethon/easy/header_spec.rb +0 -79
- data/spec/ethon/easy/http/custom_spec.rb +0 -177
- data/spec/ethon/easy/http/delete_spec.rb +0 -21
- data/spec/ethon/easy/http/get_spec.rb +0 -126
- data/spec/ethon/easy/http/head_spec.rb +0 -80
- data/spec/ethon/easy/http/options_spec.rb +0 -51
- data/spec/ethon/easy/http/patch_spec.rb +0 -51
- data/spec/ethon/easy/http/post_spec.rb +0 -317
- data/spec/ethon/easy/http/put_spec.rb +0 -168
- data/spec/ethon/easy/http_spec.rb +0 -64
- data/spec/ethon/easy/informations_spec.rb +0 -120
- data/spec/ethon/easy/mirror_spec.rb +0 -47
- data/spec/ethon/easy/operations_spec.rb +0 -268
- data/spec/ethon/easy/options_spec.rb +0 -193
- data/spec/ethon/easy/queryable_spec.rb +0 -235
- data/spec/ethon/easy/response_callbacks_spec.rb +0 -152
- data/spec/ethon/easy/util_spec.rb +0 -28
- data/spec/ethon/easy_spec.rb +0 -203
- data/spec/ethon/libc_spec.rb +0 -14
- data/spec/ethon/loggable_spec.rb +0 -22
- data/spec/ethon/multi/operations_spec.rb +0 -298
- data/spec/ethon/multi/options_spec.rb +0 -182
- data/spec/ethon/multi/stack_spec.rb +0 -80
- data/spec/ethon/multi_spec.rb +0 -152
- data/spec/spec_helper.rb +0 -28
- data/spec/support/localhost_server.rb +0 -95
- data/spec/support/server.rb +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8540ddcb77af693ed5b18a89ebcd126dd1e73e1c0d6f748d3ee2deec929fd7d
|
4
|
+
data.tar.gz: 62c1f741fb9bf87f914bb769a6e512bf01cf4e91b0f2393b6e63d3674bed12b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85604eb698147db21a2e20d83b2cbdca48d0beea0d8485a9aa992450a5dc13b3033faa1f8fa14f33faefbc71ceea317945211b116e13dd4a189b9a60963aa5fa
|
7
|
+
data.tar.gz: ed6a4381cafd5acfc1a9c5c3482e0f7b7edbf9f757aa548e16e29a76670b8b7b08b53388f52c8df76b6afa8072974311341e5acbc4c78df07092c5eb14d492de
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,35 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/typhoeus/ethon/compare/v0.
|
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)
|
31
|
+
|
32
|
+
* Added `redirect_url` value to available informations and `Easy::Mirror`.
|
33
|
+
([Adrien Rey-Jarthon](https://github.com/jarthod)
|
6
34
|
|
7
35
|
## 0.15.0
|
8
36
|
|
data/README.md
CHANGED
@@ -70,6 +70,29 @@ easy.perform
|
|
70
70
|
This is really handy when making requests since you don't have to care about setting
|
71
71
|
everything up correctly.
|
72
72
|
|
73
|
+
## Http2
|
74
|
+
Standard http2 servers require the client to connect once and create a session (multi) and then add simple requests to the multi handler.
|
75
|
+
The `perform` method then takes all the requests in the multi handler and sends them to the server.
|
76
|
+
|
77
|
+
See the following example
|
78
|
+
```ruby
|
79
|
+
multi = Ethon::Multi.new
|
80
|
+
easy = Ethon::Easy.new
|
81
|
+
|
82
|
+
easy.http_request("www.example.com/get", :get, { http_version: :httpv2_0 })
|
83
|
+
|
84
|
+
# Sending a request with http version 2 will send an Upgrade header to the server, which many older servers will not support
|
85
|
+
# See below for more info: https://everything.curl.dev/http/http2
|
86
|
+
# If this is a problem, send the below:
|
87
|
+
easy.http_request("www.example.com/get", :get, { http_version: :httpv2_prior_knowledge })
|
88
|
+
|
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 })
|
91
|
+
|
92
|
+
multi.add(easy)
|
93
|
+
multi.perform
|
94
|
+
```
|
95
|
+
|
73
96
|
## LICENSE
|
74
97
|
|
75
98
|
(The MIT License)
|
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.
|
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
|
24
|
-
|
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
|
data/lib/ethon/curls/classes.rb
CHANGED
@@ -32,8 +32,18 @@ module Ethon
|
|
32
32
|
|
33
33
|
def clear; self[:fd_count] = 0; end
|
34
34
|
else
|
35
|
-
#
|
36
|
-
FD_SETSIZE =
|
35
|
+
# https://github.com/typhoeus/ethon/issues/182
|
36
|
+
FD_SETSIZE = begin
|
37
|
+
# Allow to override the (new) default cap
|
38
|
+
if ENV['ETHON_FD_SIZE']
|
39
|
+
ENV['ETHON_FD_SIZE']
|
40
|
+
|
41
|
+
# auto-detect ulimit, but cap at 2^16
|
42
|
+
else
|
43
|
+
[::Ethon::Libc.getdtablesize, 65_536].min
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
37
47
|
layout :fds_bits, [:long, FD_SETSIZE / ::FFI::Type::LONG.size]
|
38
48
|
|
39
49
|
# :nodoc:
|
data/lib/ethon/curls/codes.rb
CHANGED
@@ -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
|
-
:
|
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
|
-
:
|
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/curls/options.rb
CHANGED
@@ -307,6 +307,7 @@ module Ethon
|
|
307
307
|
option :easy, :port, :int, 3
|
308
308
|
option :easy, :tcp_nodelay, :bool, 121
|
309
309
|
option :easy, :address_scope, :int, 171
|
310
|
+
option :easy, :tcp_fastopen, :bool, 212
|
310
311
|
option :easy, :tcp_keepalive, :bool, 213
|
311
312
|
option :easy, :tcp_keepidle, :int, 214
|
312
313
|
option :easy, :tcp_keepintvl, :int, 215
|
@@ -352,7 +353,7 @@ module Ethon
|
|
352
353
|
option :easy, :cookiesession, :bool, 96
|
353
354
|
option :easy, :cookielist, :string, 135
|
354
355
|
option :easy, :httpget, :bool, 80
|
355
|
-
option :easy, :http_version, :enum, 84, [:none, :httpv1_0, :httpv1_1, :httpv2_0]
|
356
|
+
option :easy, :http_version, :enum, 84, [:none, :httpv1_0, :httpv1_1, :httpv2_0, :httpv2_tls, :httpv2_prior_knowledge]
|
356
357
|
option :easy, :ignore_content_length, :bool, 136
|
357
358
|
option :easy, :http_content_decoding, :bool, 158
|
358
359
|
option :easy, :http_transfer_decoding, :bool, 157
|
@@ -440,7 +441,7 @@ module Ethon
|
|
440
441
|
option_alias :easy, :keypasswd, :sslkeypasswd
|
441
442
|
option :easy, :sslengine, :string, 89
|
442
443
|
option :easy, :sslengine_default, :none, 90
|
443
|
-
option :easy, :sslversion, :enum, 32, [:default, :tlsv1, :sslv2, :sslv3, :tlsv1_0, :tlsv1_1, :tlsv1_2]
|
444
|
+
option :easy, :sslversion, :enum, 32, [:default, :tlsv1, :sslv2, :sslv3, :tlsv1_0, :tlsv1_1, :tlsv1_2, :tlsv1_3]
|
444
445
|
option :easy, :ssl_verifypeer, :bool, 64
|
445
446
|
option :easy, :cainfo, :string, 65
|
446
447
|
option :easy, :issuercert, :string, 170
|
@@ -463,7 +464,7 @@ module Ethon
|
|
463
464
|
option :easy, :proxy_capath, :string, 247
|
464
465
|
option :easy, :proxy_ssl_verifypeer, :bool, 248
|
465
466
|
option :easy, :proxy_ssl_verifyhost, :int, 249
|
466
|
-
option :easy, :proxy_sslversion, :enum, 250, [:default, :tlsv1, :sslv2, :sslv3, :tlsv1_0, :tlsv1_1, :tlsv1_2]
|
467
|
+
option :easy, :proxy_sslversion, :enum, 250, [:default, :tlsv1, :sslv2, :sslv3, :tlsv1_0, :tlsv1_1, :tlsv1_2, :tlsv1_3]
|
467
468
|
option :easy, :proxy_tlsauth_username, :string, 251
|
468
469
|
option :easy, :proxy_tlsauth_password, :string, 252
|
469
470
|
option :easy, :proxy_tlsauth_type, :enum, 253, [:none, :srp]
|
data/lib/ethon/easy/callbacks.rb
CHANGED
@@ -52,8 +52,9 @@ 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
|
55
56
|
@response_headers << stream.read_string(size * num)
|
56
|
-
size * num
|
57
|
+
result != :abort ? size * num : -1
|
57
58
|
}
|
58
59
|
end
|
59
60
|
|
@@ -73,6 +73,9 @@ module Ethon
|
|
73
73
|
# actually followed.
|
74
74
|
:redirect_count => :long,
|
75
75
|
|
76
|
+
# URL a redirect would take you to, had you enabled redirects (Added in 7.18.2)
|
77
|
+
:redirect_url => :string,
|
78
|
+
|
76
79
|
# Return the bytes, the total amount of bytes that were uploaded
|
77
80
|
:size_upload => :double,
|
78
81
|
|
@@ -43,7 +43,12 @@ module Ethon
|
|
43
43
|
return if @headers_called
|
44
44
|
@headers_called = true
|
45
45
|
if defined?(@on_headers) and not @on_headers.nil?
|
46
|
-
|
46
|
+
result = nil
|
47
|
+
@on_headers.each do |callback|
|
48
|
+
result = callback.call(self)
|
49
|
+
break if result == :abort
|
50
|
+
end
|
51
|
+
result
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
data/lib/ethon/version.rb
CHANGED
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.
|
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:
|
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: '
|
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:
|
107
|
+
version: '0'
|
154
108
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
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: []
|
data/.github/workflows/ruby.yml
DELETED
@@ -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, 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
DELETED
data/.rspec
DELETED
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
|
-
|
data/profile/benchmarks.rb
DELETED
@@ -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
|