curb 0.9.3 → 1.0.5
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 +5 -5
- data/README.markdown +90 -22
- data/Rakefile +35 -20
- data/ext/banned.h +32 -0
- data/ext/curb.c +190 -14
- data/ext/curb.h +18 -5
- data/ext/curb_easy.c +514 -98
- data/ext/curb_easy.h +7 -0
- data/ext/curb_errors.c +86 -0
- data/ext/curb_macros.h +12 -0
- data/ext/curb_multi.c +178 -229
- data/ext/curb_multi.h +0 -1
- data/ext/curb_postfield.c +9 -7
- data/ext/curb_upload.c +1 -0
- data/ext/extconf.rb +76 -6
- data/lib/curb.rb +1 -0
- data/lib/curl/easy.rb +16 -9
- data/lib/curl/multi.rb +60 -14
- data/lib/curl.rb +20 -12
- data/tests/bug_crash_on_debug.rb +14 -28
- data/tests/bug_crash_on_progress.rb +7 -31
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +8 -13
- data/tests/bug_curb_easy_post_with_string_no_content_length_header.rb +6 -30
- data/tests/bug_follow_redirect_288.rb +83 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +3 -5
- data/tests/bug_issue277.rb +32 -0
- data/tests/bug_multi_segfault.rb +1 -0
- data/tests/bug_raise_on_callback.rb +29 -0
- data/tests/helper.rb +122 -13
- data/tests/tc_curl.rb +31 -1
- data/tests/tc_curl_download.rb +3 -3
- data/tests/tc_curl_easy.rb +167 -46
- data/tests/tc_curl_easy_resolve.rb +16 -0
- data/tests/tc_curl_maxfilesize.rb +12 -0
- data/tests/tc_curl_multi.rb +161 -18
- data/tests/tc_curl_postfield.rb +29 -29
- data/tests/tc_curl_protocols.rb +37 -0
- data/tests/timeout.rb +21 -5
- metadata +20 -8
data/tests/tc_curl_multi.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
|
+
require 'set'
|
2
3
|
|
3
4
|
class TestCurbCurlMulti < Test::Unit::TestCase
|
4
5
|
def teardown
|
@@ -6,6 +7,112 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
6
7
|
ObjectSpace.garbage_collect
|
7
8
|
end
|
8
9
|
|
10
|
+
# for https://github.com/taf2/curb/issues/277
|
11
|
+
# must connect to an external
|
12
|
+
def test_connection_keepalive
|
13
|
+
# this test fails with libcurl 7.22.0. I didn't investigate, but it may be related
|
14
|
+
# to CURLOPT_MAXCONNECTS bug fixed in 7.30.0:
|
15
|
+
# https://github.com/curl/curl/commit/e87e76e2dc108efb1cae87df496416f49c55fca0
|
16
|
+
omit("Skip, libcurl too old (< 7.22.0)") if Curl::CURL_VERSION.split('.')[1].to_i <= 22
|
17
|
+
|
18
|
+
@server.shutdown if @server
|
19
|
+
@test_thread.kill if @test_thread
|
20
|
+
@server = nil
|
21
|
+
File.unlink(locked_file)
|
22
|
+
Curl::Multi.autoclose = true
|
23
|
+
assert Curl::Multi.autoclose
|
24
|
+
# XXX: thought maybe we can clean house here to have the full suite pass in osx... but for now running this test in isolate does pass
|
25
|
+
# additionally, if ss allows this to pass on linux without requesting google i think this is a good trade off... leaving some of the thoughts below
|
26
|
+
# in hopes that coming back to this later will find it and remember how to fix it
|
27
|
+
# types = Set.new
|
28
|
+
# close_types = Set.new([TCPServer,TCPSocket,Socket,Curl::Multi, Curl::Easy,WEBrick::Log])
|
29
|
+
# ObjectSpace.each_object {|o|
|
30
|
+
# if o.respond_to?(:close)
|
31
|
+
# types << o.class
|
32
|
+
# end
|
33
|
+
# if close_types.include?(o.class)
|
34
|
+
# o.close
|
35
|
+
# end
|
36
|
+
# }
|
37
|
+
#puts "unique types: #{types.to_a.join("\n")}"
|
38
|
+
GC.start # cleanup FDs left over from other tests
|
39
|
+
server_setup
|
40
|
+
GC.start # cleanup FDs left over from other tests
|
41
|
+
|
42
|
+
if `which ss`.strip.size == 0
|
43
|
+
# osx need lsof still :(
|
44
|
+
open_fds = lambda do
|
45
|
+
out = `/usr/sbin/lsof -p #{Process.pid} | egrep "TCP|UDP"`# | egrep ':#{TestServlet.port} ' | egrep ESTABLISHED`# | wc -l`.strip.to_i
|
46
|
+
#puts out.lines.join("\n")
|
47
|
+
out.lines.size
|
48
|
+
end
|
49
|
+
else
|
50
|
+
ss = `which ss`.strip
|
51
|
+
open_fds = lambda do
|
52
|
+
`#{ss} -n4 state established dport = :#{TestServlet.port} | wc -l`.strip.to_i
|
53
|
+
end
|
54
|
+
end
|
55
|
+
Curl::Multi.autoclose = false
|
56
|
+
before_open = open_fds.call
|
57
|
+
#puts "before_open: #{before_open.inspect}"
|
58
|
+
assert !Curl::Multi.autoclose
|
59
|
+
multi = Curl::Multi.new
|
60
|
+
multi.max_connects = 1 # limit to 1 connection within the multi handle
|
61
|
+
|
62
|
+
did_complete = false
|
63
|
+
5.times do |n|
|
64
|
+
easy = Curl::Easy.new(TestServlet.url) do |curl|
|
65
|
+
curl.timeout = 5 # ensure we don't hang for ever connecting to an external host
|
66
|
+
curl.on_complete {
|
67
|
+
did_complete = true
|
68
|
+
}
|
69
|
+
end
|
70
|
+
multi.add(easy)
|
71
|
+
end
|
72
|
+
|
73
|
+
multi.perform
|
74
|
+
assert did_complete
|
75
|
+
after_open = open_fds.call
|
76
|
+
#puts "after_open: #{after_open} before_open: #{before_open.inspect}"
|
77
|
+
# ruby process may keep a connection alive
|
78
|
+
assert (after_open - before_open) < 3, "with max connections set to 1 at this point the connection to google should still be open"
|
79
|
+
assert (after_open - before_open) > 0, "with max connections set to 1 at this point the connection to google should still be open"
|
80
|
+
multi.close
|
81
|
+
|
82
|
+
after_open = open_fds.call
|
83
|
+
#puts "after_open: #{after_open} before_open: #{before_open.inspect}"
|
84
|
+
assert_equal 0, (after_open - before_open), "after closing the multi handle all connections should be closed"
|
85
|
+
|
86
|
+
Curl::Multi.autoclose = true
|
87
|
+
multi = Curl::Multi.new
|
88
|
+
did_complete = false
|
89
|
+
5.times do |n|
|
90
|
+
easy = Curl::Easy.new(TestServlet.url) do |curl|
|
91
|
+
curl.timeout = 5 # ensure we don't hang for ever connecting to an external host
|
92
|
+
curl.on_complete {
|
93
|
+
did_complete = true
|
94
|
+
}
|
95
|
+
end
|
96
|
+
multi.add(easy)
|
97
|
+
end
|
98
|
+
|
99
|
+
multi.perform
|
100
|
+
assert did_complete
|
101
|
+
after_open = open_fds.call
|
102
|
+
#puts "after_open: #{after_open} before_open: #{before_open.inspect}"
|
103
|
+
assert_equal 0, (after_open - before_open), "auto close the connections"
|
104
|
+
ensure
|
105
|
+
Curl::Multi.autoclose = false # restore default
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_connection_autoclose
|
109
|
+
assert !Curl::Multi.autoclose
|
110
|
+
Curl::Multi.autoclose = true
|
111
|
+
assert Curl::Multi.autoclose
|
112
|
+
ensure
|
113
|
+
Curl::Multi.autoclose = false # restore default
|
114
|
+
end
|
115
|
+
|
9
116
|
def test_new_multi_01
|
10
117
|
d1 = ""
|
11
118
|
c1 = Curl::Easy.new($TEST_URL) do |curl|
|
@@ -54,6 +161,44 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
54
161
|
|
55
162
|
end
|
56
163
|
|
164
|
+
def test_multi_easy_get
|
165
|
+
n = 1
|
166
|
+
urls = []
|
167
|
+
n.times { urls << $TEST_URL }
|
168
|
+
Curl::Multi.get(urls, {timeout: 5}) {|easy|
|
169
|
+
assert_match(/file:/, easy.last_effective_url)
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_multi_easy_get_with_error
|
174
|
+
begin
|
175
|
+
did_raise = false
|
176
|
+
n = 3
|
177
|
+
urls = []
|
178
|
+
n.times { urls << $TEST_URL }
|
179
|
+
error_line_number_should_be = nil
|
180
|
+
Curl::Multi.get(urls, {timeout: 5}) {|easy|
|
181
|
+
# if we got this right the error will be reported to be on the line below our error_line_number_should_be
|
182
|
+
error_line_number_should_be = __LINE__
|
183
|
+
raise
|
184
|
+
}
|
185
|
+
|
186
|
+
rescue Curl::Err::AbortedByCallbackError => e
|
187
|
+
did_raise = true
|
188
|
+
in_file = e.backtrace.detect {|err| err.match?(File.basename(__FILE__)) }
|
189
|
+
in_file_stack = e.backtrace.select {|err| err.match?(File.basename(__FILE__)) }
|
190
|
+
assert_match(__FILE__, in_file)
|
191
|
+
in_file.gsub!(__FILE__)
|
192
|
+
parts = in_file.split(':')
|
193
|
+
parts.shift
|
194
|
+
line_no = parts.shift.to_i
|
195
|
+
assert_equal error_line_number_should_be+1, line_no.to_i
|
196
|
+
end
|
197
|
+
|
198
|
+
assert did_raise, "we should have raised an exception"
|
199
|
+
|
200
|
+
end
|
201
|
+
|
57
202
|
# NOTE: if this test runs slowly on Mac OSX, it is probably due to the use of a port install curl+ssl+ares install
|
58
203
|
# on my MacBook, this causes curl_easy_init to take nearly 0.01 seconds / * 100 below is 1 second too many!
|
59
204
|
def test_n_requests
|
@@ -125,7 +270,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
125
270
|
def test_requests
|
126
271
|
m = Curl::Multi.new
|
127
272
|
|
128
|
-
assert_equal(
|
273
|
+
assert_equal(0, m.requests.length, 'A new Curl::Multi handle should have no requests')
|
129
274
|
|
130
275
|
10.times do
|
131
276
|
m.add(Curl::Easy.new($TEST_URL))
|
@@ -135,7 +280,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
135
280
|
|
136
281
|
m.perform
|
137
282
|
|
138
|
-
assert_equal(
|
283
|
+
assert_equal(0, m.requests.length, 'A new Curl::Multi handle should have no requests after a perform')
|
139
284
|
end
|
140
285
|
|
141
286
|
def test_cancel
|
@@ -148,7 +293,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
148
293
|
|
149
294
|
m.cancel!
|
150
295
|
|
151
|
-
assert_equal(
|
296
|
+
assert_equal(0, m.requests.size, 'A new Curl::Multi handle should have no requests after being canceled')
|
152
297
|
end
|
153
298
|
|
154
299
|
def test_with_success
|
@@ -192,7 +337,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
192
337
|
c1.on_success do|c|
|
193
338
|
success_called1 = true
|
194
339
|
#puts "success 1 called: #{c.body_str.inspect}"
|
195
|
-
|
340
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
|
196
341
|
end
|
197
342
|
|
198
343
|
c1.on_failure do|c,rc|
|
@@ -331,7 +476,6 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
331
476
|
Curl::Multi.download(urls,{},{},downloads) do|curl,download_path|
|
332
477
|
assert_equal 200, curl.response_code
|
333
478
|
assert File.exist?(download_path)
|
334
|
-
store = file_info[File.basename(download_path)]
|
335
479
|
assert_equal file_info[File.basename(download_path)][:size], File.size(download_path), "incomplete download: #{download_path}"
|
336
480
|
end
|
337
481
|
ensure
|
@@ -346,7 +490,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
346
490
|
]
|
347
491
|
Curl::Multi.post(urls, {:follow_location => true, :multipart_form_post => true}, {:pipeline => true}) do|easy|
|
348
492
|
str = easy.body_str
|
349
|
-
assert_match
|
493
|
+
assert_match(/POST/, str)
|
350
494
|
fields = {}
|
351
495
|
str.gsub(/POST\n/,'').split('&').map{|sv| k, v = sv.split('='); fields[k] = v }
|
352
496
|
expected = urls.find{|s| s[:url] == easy.last_effective_url }
|
@@ -361,8 +505,8 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
361
505
|
{ :url => TestServlet.url, :method => :put, :put_data => "message",
|
362
506
|
:headers => {'Content-Type' => 'application/json' } }]
|
363
507
|
Curl::Multi.put(urls, {}, {:pipeline => true}) do|easy|
|
364
|
-
assert_match
|
365
|
-
assert_match
|
508
|
+
assert_match(/PUT/, easy.body_str)
|
509
|
+
assert_match(/message/, easy.body_str)
|
366
510
|
end
|
367
511
|
end
|
368
512
|
|
@@ -376,34 +520,34 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
376
520
|
{ :url => TestServlet.url, :method => :get }
|
377
521
|
]
|
378
522
|
Curl::Multi.http(urls, {:pipeline => true}) do|easy, code, method|
|
379
|
-
assert_equal
|
523
|
+
assert_equal 200, code
|
380
524
|
case method
|
381
525
|
when :post
|
382
|
-
assert_match
|
526
|
+
assert_match(/POST/, easy.body_str)
|
383
527
|
when :get
|
384
|
-
assert_match
|
528
|
+
assert_match(/GET/, easy.body_str)
|
385
529
|
when :put
|
386
|
-
assert_match
|
530
|
+
assert_match(/PUT/, easy.body_str)
|
387
531
|
end
|
388
532
|
#puts "#{easy.body_str.inspect}, #{method.inspect}, #{code.inspect}"
|
389
533
|
end
|
390
534
|
end
|
391
535
|
|
392
536
|
def test_multi_easy_http_with_max_connects
|
393
|
-
|
537
|
+
urls = [
|
394
538
|
{ :url => TestServlet.url + '?q=1', :method => :get },
|
395
539
|
{ :url => TestServlet.url + '?q=2', :method => :get },
|
396
540
|
{ :url => TestServlet.url + '?q=3', :method => :get }
|
397
541
|
]
|
398
542
|
Curl::Multi.http(urls, {:pipeline => true, :max_connects => 1}) do|easy, code, method|
|
399
|
-
assert_equal
|
543
|
+
assert_equal 200, code
|
400
544
|
case method
|
401
545
|
when :post
|
402
|
-
assert_match
|
546
|
+
assert_match(/POST/, easy.body)
|
403
547
|
when :get
|
404
|
-
assert_match
|
548
|
+
assert_match(/GET/, easy.body)
|
405
549
|
when :put
|
406
|
-
assert_match
|
550
|
+
assert_match(/PUT/, easy.body)
|
407
551
|
end
|
408
552
|
end
|
409
553
|
end
|
@@ -485,5 +629,4 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
485
629
|
def setup
|
486
630
|
server_setup
|
487
631
|
end
|
488
|
-
|
489
632
|
end
|
data/tests/tc_curl_postfield.rb
CHANGED
@@ -2,63 +2,63 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
|
2
2
|
|
3
3
|
class TestCurbCurlPostfield < Test::Unit::TestCase
|
4
4
|
def test_private_new
|
5
|
-
assert_raise(NoMethodError) { Curl::PostField.new }
|
5
|
+
assert_raise(NoMethodError) { Curl::PostField.new }
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def test_new_content_01
|
9
9
|
pf = Curl::PostField.content('foo', 'bar')
|
10
|
-
|
10
|
+
|
11
11
|
assert_equal 'foo', pf.name
|
12
12
|
assert_equal 'bar', pf.content
|
13
13
|
assert_nil pf.content_type
|
14
14
|
assert_nil pf.local_file
|
15
|
-
assert_nil pf.remote_file
|
15
|
+
assert_nil pf.remote_file
|
16
16
|
assert_nil pf.set_content_proc
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def test_new_content_02
|
20
20
|
pf = Curl::PostField.content('foo', 'bar', 'text/html')
|
21
|
-
|
21
|
+
|
22
22
|
assert_equal 'foo', pf.name
|
23
23
|
assert_equal 'bar', pf.content
|
24
24
|
assert_equal 'text/html', pf.content_type
|
25
25
|
assert_nil pf.local_file
|
26
26
|
assert_nil pf.remote_file
|
27
|
-
assert_nil pf.set_content_proc
|
28
|
-
end
|
29
|
-
|
27
|
+
assert_nil pf.set_content_proc
|
28
|
+
end
|
29
|
+
|
30
30
|
def test_new_content_03
|
31
31
|
l = lambda { |field| "never gets run" }
|
32
32
|
pf = Curl::PostField.content('foo', &l)
|
33
|
-
|
33
|
+
|
34
34
|
assert_equal 'foo', pf.name
|
35
35
|
assert_nil pf.content
|
36
36
|
assert_nil pf.content_type
|
37
37
|
assert_nil pf.local_file
|
38
38
|
assert_nil pf.remote_file
|
39
|
-
|
39
|
+
|
40
40
|
# N.B. This doesn't just get the proc, but also removes it.
|
41
41
|
assert_equal l, pf.set_content_proc
|
42
|
-
end
|
42
|
+
end
|
43
43
|
|
44
44
|
def test_new_content_04
|
45
45
|
l = lambda { |field| "never gets run" }
|
46
46
|
pf = Curl::PostField.content('foo', 'text/html', &l)
|
47
|
-
|
47
|
+
|
48
48
|
assert_equal 'foo', pf.name
|
49
49
|
assert_nil pf.content
|
50
50
|
assert_equal 'text/html', pf.content_type
|
51
51
|
assert_nil pf.local_file
|
52
52
|
assert_nil pf.remote_file
|
53
|
-
|
53
|
+
|
54
54
|
# N.B. This doesn't just get the proc, but also removes it.
|
55
55
|
assert_equal l, pf.set_content_proc
|
56
|
-
end
|
56
|
+
end
|
57
57
|
|
58
58
|
|
59
59
|
def test_new_file_01
|
60
60
|
pf = Curl::PostField.file('foo', 'localname')
|
61
|
-
|
61
|
+
|
62
62
|
assert_equal 'foo', pf.name
|
63
63
|
assert_equal 'localname', pf.local_file
|
64
64
|
assert_equal 'localname', pf.remote_file
|
@@ -67,44 +67,44 @@ class TestCurbCurlPostfield < Test::Unit::TestCase
|
|
67
67
|
assert_nil pf.content
|
68
68
|
assert_nil pf.set_content_proc
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def test_new_file_02
|
72
72
|
pf = Curl::PostField.file('foo', 'localname', 'remotename')
|
73
|
-
|
73
|
+
|
74
74
|
assert_equal 'foo', pf.name
|
75
75
|
assert_equal 'localname', pf.local_file
|
76
76
|
assert_equal 'remotename', pf.remote_file
|
77
77
|
assert_nil pf.content_type
|
78
78
|
assert_nil pf.content
|
79
79
|
assert_nil pf.set_content_proc
|
80
|
-
end
|
81
|
-
|
80
|
+
end
|
81
|
+
|
82
82
|
def test_new_file_03
|
83
83
|
l = lambda { |field| "never gets run" }
|
84
84
|
pf = Curl::PostField.file('foo', 'remotename', &l)
|
85
|
-
|
85
|
+
|
86
86
|
assert_equal 'foo', pf.name
|
87
87
|
assert_equal 'remotename', pf.remote_file
|
88
88
|
assert_nil pf.local_file
|
89
89
|
assert_nil pf.content_type
|
90
90
|
assert_nil pf.content
|
91
|
-
|
91
|
+
|
92
92
|
# N.B. This doesn't just get the proc, but also removes it.
|
93
93
|
assert_equal l, pf.set_content_proc
|
94
|
-
end
|
94
|
+
end
|
95
95
|
|
96
96
|
def test_new_file_04
|
97
97
|
assert_raise(ArgumentError) do
|
98
98
|
# no local name, no block
|
99
99
|
Curl::PostField.file('foo')
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
assert_raise(ArgumentError) do
|
103
103
|
# no remote name with block
|
104
104
|
Curl::PostField.file('foo') { |field| "never runs" }
|
105
105
|
end
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
def test_new_file_05
|
109
109
|
# local gets ignored when supplying a block, but remote
|
110
110
|
# is still set up properly.
|
@@ -118,15 +118,15 @@ class TestCurbCurlPostfield < Test::Unit::TestCase
|
|
118
118
|
assert_nil pf.content
|
119
119
|
|
120
120
|
assert_equal l, pf.set_content_proc
|
121
|
-
end
|
122
|
-
|
121
|
+
end
|
122
|
+
|
123
123
|
def test_to_s_01
|
124
|
-
pf = Curl::PostField.content('foo', 'bar')
|
124
|
+
pf = Curl::PostField.content('foo', 'bar')
|
125
125
|
assert_equal "foo=bar", pf.to_s
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_to_s_02
|
129
|
-
pf = Curl::PostField.content('foo', 'bar ton')
|
129
|
+
pf = Curl::PostField.content('foo', 'bar ton')
|
130
130
|
assert_equal "foo=bar%20ton", pf.to_s
|
131
131
|
end
|
132
132
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class TestCurbCurlProtocols < Test::Unit::TestCase
|
2
|
+
include TestServerMethods
|
3
|
+
|
4
|
+
def setup
|
5
|
+
@easy = Curl::Easy.new
|
6
|
+
@easy.set :protocols, Curl::CURLPROTO_HTTP | Curl::CURLPROTO_HTTPS
|
7
|
+
@easy.follow_location = true
|
8
|
+
server_setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_protocol_allowed
|
12
|
+
@easy.set :url, "http://127.0.0.1:9129/this_file_does_not_exist.html"
|
13
|
+
@easy.perform
|
14
|
+
assert_equal 404, @easy.response_code
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_protocol_denied
|
18
|
+
@easy.set :url, "gopher://google.com/"
|
19
|
+
assert_raises Curl::Err::UnsupportedProtocolError do
|
20
|
+
@easy.perform
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_redir_protocol_allowed
|
25
|
+
@easy.set :url, TestServlet.url + "/redirect"
|
26
|
+
@easy.set :redir_protocols, Curl::CURLPROTO_HTTP
|
27
|
+
@easy.perform
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_redir_protocol_denied
|
31
|
+
@easy.set :url, TestServlet.url + "/redirect"
|
32
|
+
@easy.set :redir_protocols, Curl::CURLPROTO_HTTPS
|
33
|
+
assert_raises Curl::Err::UnsupportedProtocolError do
|
34
|
+
@easy.perform
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/tests/timeout.rb
CHANGED
@@ -17,9 +17,13 @@ class TestCurbTimeouts < Test::Unit::TestCase
|
|
17
17
|
def test_overall_timeout_on_dead_transfer
|
18
18
|
curl = Curl::Easy.new(wait_url(2))
|
19
19
|
curl.timeout = 1
|
20
|
-
assert_raise(Curl::Err::TimeoutError) do
|
20
|
+
exception = assert_raise(Curl::Err::TimeoutError) do
|
21
21
|
curl.http_get
|
22
22
|
end
|
23
|
+
assert_match(
|
24
|
+
/^Timeout was reached: Operation timed out after/,
|
25
|
+
exception.message
|
26
|
+
)
|
23
27
|
end
|
24
28
|
|
25
29
|
def test_overall_timeout_ms_on_dead_transfer
|
@@ -44,16 +48,20 @@ class TestCurbTimeouts < Test::Unit::TestCase
|
|
44
48
|
curl = Curl::Easy.new(serve_url(100, 2, 3))
|
45
49
|
curl.timeout = 1
|
46
50
|
# transfer is aborted despite data being exchanged
|
47
|
-
assert_raise(Curl::Err::TimeoutError) do
|
51
|
+
exception = assert_raise(Curl::Err::TimeoutError) do
|
48
52
|
curl.http_get
|
49
53
|
end
|
54
|
+
assert_match(
|
55
|
+
/^Timeout was reached: Operation timed out after/,
|
56
|
+
exception.message
|
57
|
+
)
|
50
58
|
end
|
51
59
|
|
52
60
|
def test_low_speed_time_on_slow_transfer
|
53
61
|
curl = Curl::Easy.new(serve_url(100, 1, 3))
|
54
62
|
curl.low_speed_time = 2
|
55
63
|
# use default low_speed_limit of 1
|
56
|
-
|
64
|
+
assert_equal true, curl.http_get
|
57
65
|
end
|
58
66
|
|
59
67
|
def test_low_speed_time_on_very_slow_transfer
|
@@ -63,18 +71,26 @@ class TestCurbTimeouts < Test::Unit::TestCase
|
|
63
71
|
# XXX for some reason this test fails if low speed limit is not specified
|
64
72
|
curl.low_speed_limit = 1
|
65
73
|
# use default low_speed_limit of 1
|
66
|
-
assert_raise(Curl::Err::TimeoutError) do
|
74
|
+
exception = assert_raise(Curl::Err::TimeoutError) do
|
67
75
|
curl.http_get
|
68
76
|
end
|
77
|
+
assert_match(
|
78
|
+
/^Timeout was reached: Operation too slow/,
|
79
|
+
exception.message
|
80
|
+
)
|
69
81
|
end
|
70
82
|
|
71
83
|
def test_low_speed_limit_on_slow_transfer
|
72
84
|
curl = Curl::Easy.new(serve_url(10, 1, 3))
|
73
85
|
curl.low_speed_time = 2
|
74
86
|
curl.low_speed_limit = 1000
|
75
|
-
assert_raise(Curl::Err::TimeoutError) do
|
87
|
+
exception = assert_raise(Curl::Err::TimeoutError) do
|
76
88
|
curl.http_get
|
77
89
|
end
|
90
|
+
assert_match(
|
91
|
+
/^Timeout was reached: Operation too slow/,
|
92
|
+
exception.message
|
93
|
+
)
|
78
94
|
end
|
79
95
|
|
80
96
|
def test_clearing_low_speed_time
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Bamford
|
8
8
|
- Todd A. Fisher
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings
|
15
15
|
for the libcurl(3), a fully-featured client-side URL transfer library. cURL and
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- README.markdown
|
27
27
|
- Rakefile
|
28
28
|
- doc.rb
|
29
|
+
- ext/banned.h
|
29
30
|
- ext/curb.c
|
30
31
|
- ext/curb.h
|
31
32
|
- ext/curb_easy.c
|
@@ -49,11 +50,14 @@ files:
|
|
49
50
|
- tests/bug_crash_on_progress.rb
|
50
51
|
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
51
52
|
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
53
|
+
- tests/bug_follow_redirect_288.rb
|
52
54
|
- tests/bug_instance_post_differs_from_class_post.rb
|
53
55
|
- tests/bug_issue102.rb
|
56
|
+
- tests/bug_issue277.rb
|
54
57
|
- tests/bug_multi_segfault.rb
|
55
58
|
- tests/bug_postfields_crash.rb
|
56
59
|
- tests/bug_postfields_crash2.rb
|
60
|
+
- tests/bug_raise_on_callback.rb
|
57
61
|
- tests/bug_require_last_or_segfault.rb
|
58
62
|
- tests/bugtests.rb
|
59
63
|
- tests/helper.rb
|
@@ -63,17 +67,20 @@ files:
|
|
63
67
|
- tests/tc_curl.rb
|
64
68
|
- tests/tc_curl_download.rb
|
65
69
|
- tests/tc_curl_easy.rb
|
70
|
+
- tests/tc_curl_easy_resolve.rb
|
66
71
|
- tests/tc_curl_easy_setopt.rb
|
72
|
+
- tests/tc_curl_maxfilesize.rb
|
67
73
|
- tests/tc_curl_multi.rb
|
68
74
|
- tests/tc_curl_postfield.rb
|
75
|
+
- tests/tc_curl_protocols.rb
|
69
76
|
- tests/timeout.rb
|
70
77
|
- tests/timeout_server.rb
|
71
78
|
- tests/unittests.rb
|
72
|
-
homepage:
|
79
|
+
homepage: https://github.com/taf2/curb
|
73
80
|
licenses:
|
74
81
|
- MIT
|
75
82
|
metadata: {}
|
76
|
-
post_install_message:
|
83
|
+
post_install_message:
|
77
84
|
rdoc_options:
|
78
85
|
- "--main"
|
79
86
|
- README.markdown
|
@@ -91,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
98
|
- !ruby/object:Gem::Version
|
92
99
|
version: '0'
|
93
100
|
requirements: []
|
94
|
-
|
95
|
-
|
96
|
-
signing_key:
|
101
|
+
rubygems_version: 3.2.33
|
102
|
+
signing_key:
|
97
103
|
specification_version: 4
|
98
104
|
summary: Ruby libcurl bindings
|
99
105
|
test_files:
|
@@ -102,11 +108,14 @@ test_files:
|
|
102
108
|
- tests/bug_crash_on_progress.rb
|
103
109
|
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
104
110
|
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
111
|
+
- tests/bug_follow_redirect_288.rb
|
105
112
|
- tests/bug_instance_post_differs_from_class_post.rb
|
106
113
|
- tests/bug_issue102.rb
|
114
|
+
- tests/bug_issue277.rb
|
107
115
|
- tests/bug_multi_segfault.rb
|
108
116
|
- tests/bug_postfields_crash.rb
|
109
117
|
- tests/bug_postfields_crash2.rb
|
118
|
+
- tests/bug_raise_on_callback.rb
|
110
119
|
- tests/bug_require_last_or_segfault.rb
|
111
120
|
- tests/bugtests.rb
|
112
121
|
- tests/helper.rb
|
@@ -116,9 +125,12 @@ test_files:
|
|
116
125
|
- tests/tc_curl.rb
|
117
126
|
- tests/tc_curl_download.rb
|
118
127
|
- tests/tc_curl_easy.rb
|
128
|
+
- tests/tc_curl_easy_resolve.rb
|
119
129
|
- tests/tc_curl_easy_setopt.rb
|
130
|
+
- tests/tc_curl_maxfilesize.rb
|
120
131
|
- tests/tc_curl_multi.rb
|
121
132
|
- tests/tc_curl_postfield.rb
|
133
|
+
- tests/tc_curl_protocols.rb
|
122
134
|
- tests/timeout.rb
|
123
135
|
- tests/timeout_server.rb
|
124
136
|
- tests/unittests.rb
|