curb 1.3.1 → 1.3.3
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/ext/curb.h +3 -3
- data/ext/curb_easy.c +285 -142
- data/ext/curb_multi.c +185 -20
- data/ext/curb_multi.h +3 -0
- data/ext/curb_postfield.c +1 -0
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +3 -3
- data/tests/bug_follow_redirect_288.rb +7 -7
- data/tests/bug_raise_on_callback.rb +4 -3
- data/tests/helper.rb +7 -0
- data/tests/tc_curl_easy.rb +116 -0
- data/tests/tc_curl_easy_resolve.rb +32 -0
- data/tests/tc_curl_multi.rb +56 -0
- data/tests/tc_curl_native_coverage.rb +15 -0
- data/tests/tc_curl_postfield.rb +15 -0
- data/tests/tc_ftp_options.rb +14 -1
- metadata +2 -2
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
|
2
2
|
|
|
3
3
|
class TestCurbCurlEasyResolve < Test::Unit::TestCase
|
|
4
|
+
include TestServerMethods
|
|
5
|
+
|
|
4
6
|
def setup
|
|
7
|
+
server_setup
|
|
5
8
|
@easy = Curl::Easy.new
|
|
6
9
|
end
|
|
7
10
|
|
|
@@ -13,4 +16,33 @@ class TestCurbCurlEasyResolve < Test::Unit::TestCase
|
|
|
13
16
|
def test_empty_resolve
|
|
14
17
|
assert_equal @easy.resolve, nil
|
|
15
18
|
end
|
|
19
|
+
|
|
20
|
+
def test_setopt_resolve_persists_across_performs
|
|
21
|
+
host = "curb-setopt-resolve.invalid"
|
|
22
|
+
mapping = "#{host}:#{TestServlet.port}:127.0.0.1"
|
|
23
|
+
|
|
24
|
+
@easy.url = "http://#{host}:#{TestServlet.port}#{TestServlet.path}"
|
|
25
|
+
@easy.dns_cache_timeout = 0
|
|
26
|
+
@easy.set(:resolve, [mapping])
|
|
27
|
+
|
|
28
|
+
@easy.perform
|
|
29
|
+
assert_match(/GET/, @easy.body_str)
|
|
30
|
+
|
|
31
|
+
@easy.perform
|
|
32
|
+
assert_match(/GET/, @easy.body_str)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_resolve_entries_can_be_objects_that_convert_to_string
|
|
36
|
+
host = "curb-resolve-object.invalid"
|
|
37
|
+
mapping = "#{host}:#{TestServlet.port}:127.0.0.1"
|
|
38
|
+
entry = Object.new
|
|
39
|
+
entry.define_singleton_method(:to_s) { mapping }
|
|
40
|
+
|
|
41
|
+
@easy.url = "http://#{host}:#{TestServlet.port}#{TestServlet.path}"
|
|
42
|
+
@easy.dns_cache_timeout = 0
|
|
43
|
+
@easy.resolve = [entry]
|
|
44
|
+
|
|
45
|
+
@easy.perform
|
|
46
|
+
assert_match(/GET/, @easy.body_str)
|
|
47
|
+
end
|
|
16
48
|
end
|
data/tests/tc_curl_multi.rb
CHANGED
|
@@ -133,6 +133,62 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
|
133
133
|
Curl::Multi.autoclose = false
|
|
134
134
|
end
|
|
135
135
|
|
|
136
|
+
def test_close_inside_completion_callback_is_rejected_without_invalidating_multi
|
|
137
|
+
multi = Curl::Multi.new
|
|
138
|
+
easy = Curl::Easy.new(TestServlet.url)
|
|
139
|
+
|
|
140
|
+
easy.on_complete { multi.close }
|
|
141
|
+
multi.add(easy)
|
|
142
|
+
|
|
143
|
+
error = assert_raise(Curl::Err::AbortedByCallbackError) { multi.perform }
|
|
144
|
+
assert_match(/Cannot close an active Curl::Multi handle/, error.message)
|
|
145
|
+
assert multi.idle?
|
|
146
|
+
assert_equal({}, multi.requests)
|
|
147
|
+
|
|
148
|
+
easy.on_complete { |_curl| }
|
|
149
|
+
multi.add(easy)
|
|
150
|
+
multi.perform
|
|
151
|
+
|
|
152
|
+
assert_equal "GET", easy.body_str
|
|
153
|
+
ensure
|
|
154
|
+
multi.close if defined?(multi) && multi
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def test_close_inside_perform_block_is_rejected_without_invalidating_multi
|
|
158
|
+
multi = Curl::Multi.new
|
|
159
|
+
easy = Curl::Easy.new(TestServlet.url)
|
|
160
|
+
multi.add(easy)
|
|
161
|
+
|
|
162
|
+
error = assert_raise(RuntimeError) do
|
|
163
|
+
multi.perform { multi.close }
|
|
164
|
+
end
|
|
165
|
+
assert_match(/Cannot close an active Curl::Multi handle/, error.message)
|
|
166
|
+
|
|
167
|
+
assert_nothing_raised { multi.close }
|
|
168
|
+
multi = nil
|
|
169
|
+
ensure
|
|
170
|
+
multi.close if defined?(multi) && multi
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def test_active_easy_cannot_be_added_to_another_multi
|
|
174
|
+
first_multi = Curl::Multi.new
|
|
175
|
+
second_multi = Curl::Multi.new
|
|
176
|
+
easy = Curl::Easy.new(TestServlet.url)
|
|
177
|
+
|
|
178
|
+
first_multi.add(easy)
|
|
179
|
+
|
|
180
|
+
error = assert_raise(RuntimeError) { second_multi.add(easy) }
|
|
181
|
+
assert_match(/active Curl::Easy/, error.message)
|
|
182
|
+
assert_same first_multi, easy.multi
|
|
183
|
+
assert_equal easy, first_multi.requests[easy.object_id]
|
|
184
|
+
|
|
185
|
+
assert_nothing_raised { first_multi.close }
|
|
186
|
+
first_multi = nil
|
|
187
|
+
ensure
|
|
188
|
+
first_multi.close if defined?(first_multi) && first_multi
|
|
189
|
+
second_multi.close if defined?(second_multi) && second_multi
|
|
190
|
+
end
|
|
191
|
+
|
|
136
192
|
def test_close_makes_multi_unusable
|
|
137
193
|
multi = Curl::Multi.new
|
|
138
194
|
multi.close
|
|
@@ -90,6 +90,21 @@ class TestCurbCurlNativeCoverage < Test::Unit::TestCase
|
|
|
90
90
|
easy.close if defined?(easy) && easy
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
+
def test_clone_rebinds_upload_callbacks_to_clone_state
|
|
94
|
+
easy = Curl::Easy.new(TestServlet.url)
|
|
95
|
+
easy.put_data = 'clone-data'
|
|
96
|
+
|
|
97
|
+
clone = easy.clone
|
|
98
|
+
easy.put_data = 'other-data'
|
|
99
|
+
|
|
100
|
+
clone.perform
|
|
101
|
+
|
|
102
|
+
assert_equal "PUT\nclone-data", clone.body_str
|
|
103
|
+
ensure
|
|
104
|
+
clone.close if defined?(clone) && clone
|
|
105
|
+
easy.close if defined?(easy) && easy
|
|
106
|
+
end
|
|
107
|
+
|
|
93
108
|
def test_native_accessors_round_trip
|
|
94
109
|
easy = Curl::Easy.new(TestServlet.url)
|
|
95
110
|
|
data/tests/tc_curl_postfield.rb
CHANGED
|
@@ -136,11 +136,26 @@ class TestCurbCurlPostfield < Test::Unit::TestCase
|
|
|
136
136
|
assert_equal "foo=FOOBAR", pf.to_s
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
+
def test_content_proc_survives_gc
|
|
140
|
+
pf = postfield_with_only_native_proc_reference
|
|
141
|
+
|
|
142
|
+
10.times do
|
|
143
|
+
GC.start(full_mark: true, immediate_sweep: true)
|
|
144
|
+
GC.compact if GC.respond_to?(:compact)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
assert_equal "foo=FOOBAR", pf.to_s
|
|
148
|
+
end
|
|
149
|
+
|
|
139
150
|
def test_to_s_04
|
|
140
151
|
pf = Curl::PostField.file('foo.file', 'bar.file')
|
|
141
152
|
assert_nothing_raised { pf.to_s }
|
|
142
153
|
#assert_raise(Curl::Err::InvalidPostFieldError) { pf.to_s }
|
|
143
154
|
end
|
|
155
|
+
|
|
156
|
+
def postfield_with_only_native_proc_reference
|
|
157
|
+
Curl::PostField.content('foo') { |field| field.name.upcase + "BAR" }
|
|
158
|
+
end
|
|
144
159
|
end
|
|
145
160
|
|
|
146
161
|
class TestCurbCurlPostfieldNativeCoverage < Test::Unit::TestCase
|
data/tests/tc_ftp_options.rb
CHANGED
|
@@ -22,5 +22,18 @@ class TestCurbFtpOptions < Test::Unit::TestCase
|
|
|
22
22
|
assert_kind_of(Array, c.ftp_commands)
|
|
23
23
|
assert_equal ["PWD", "CWD /"], c.ftp_commands
|
|
24
24
|
end
|
|
25
|
-
end
|
|
26
25
|
|
|
26
|
+
def test_ftp_command_entries_can_be_objects_that_convert_to_string
|
|
27
|
+
command = Object.new
|
|
28
|
+
command.define_singleton_method(:to_s) { "PWD" }
|
|
29
|
+
|
|
30
|
+
c = Curl::Easy.new($TEST_URL)
|
|
31
|
+
c.ftp_commands = [command]
|
|
32
|
+
m = Curl::Multi.new
|
|
33
|
+
|
|
34
|
+
assert_nothing_raised { m.add(c) }
|
|
35
|
+
ensure
|
|
36
|
+
m.remove(c) if defined?(m) && m && m.requests[c.object_id]
|
|
37
|
+
m.close if defined?(m) && m
|
|
38
|
+
end
|
|
39
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: curb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ross Bamford
|
|
8
8
|
- Todd A. Fisher
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings
|
|
14
14
|
for the libcurl(3), a fully-featured client-side URL transfer library. cURL and
|