curb 1.0.1 → 1.0.2
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/README.markdown +2 -1
- data/Rakefile +0 -7
- data/ext/curb.c +4 -0
- data/ext/curb.h +3 -3
- data/ext/curb_easy.c +6 -0
- data/ext/curb_macros.h +6 -0
- data/ext/curb_multi.c +32 -16
- data/ext/curb_postfield.c +2 -0
- data/ext/curb_upload.c +1 -0
- data/ext/extconf.rb +2 -0
- data/tests/bug_crash_on_debug.rb +14 -4
- data/tests/bug_crash_on_progress.rb +4 -2
- data/tests/bug_follow_redirect_288.rb +91 -0
- data/tests/bug_raise_on_callback.rb +40 -0
- data/tests/tc_curl_easy.rb +4 -4
- data/tests/tc_curl_multi.rb +9 -7
- metadata +27 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b338d766fda8dfadab0c602cdad4a9f15a529bb495725b15ca5def63a9d8390a
|
4
|
+
data.tar.gz: 5b074f1154e3da7ce37eee89e6e5a577a2c09202b6baee72afd2098eac986bd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59a25fdf7add62512432495a89d6c8832513ecbc94bb14e7e5720abbfbfea24e0ae52c77fe10497871c6683f39e6988ff184088318e06a14848ab764db38bea2
|
7
|
+
data.tar.gz: 4fc8fb4b8111f102107cabc002f1b1a11d2f73e9b66d188ebaf3027a803c90868184c751a3448639bf23ca62eace0a227769aff716a4ba0a8a39b23888346097
|
data/README.markdown
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
# Curb - Libcurl bindings for Ruby
|
1
|
+
# Curb - Libcurl bindings for Ruby
|
2
2
|
|
3
|
+
* [CI Build Status](https://github.com/taf2/curb/actions/workflows/CI.yml)
|
3
4
|
* [rubydoc rdoc](http://www.rubydoc.info/github/taf2/curb/)
|
4
5
|
* [github project](http://github.com/taf2/curb/tree/master)
|
5
6
|
|
data/Rakefile
CHANGED
@@ -10,13 +10,6 @@ CLOBBER.include '**/*.log'
|
|
10
10
|
CLOBBER.include '**/Makefile'
|
11
11
|
CLOBBER.include '**/extconf.h'
|
12
12
|
|
13
|
-
# Not available for really old rubies, but that's ok.
|
14
|
-
begin
|
15
|
-
require 'pry'
|
16
|
-
rescue LoadError
|
17
|
-
puts "Failed to load pry."
|
18
|
-
end
|
19
|
-
|
20
13
|
# Load support ruby and rake files (in this order)
|
21
14
|
Dir.glob('tasks/*.rb').each { |r| load r}
|
22
15
|
Dir.glob('tasks/*.rake').each { |r| load r}
|
data/ext/curb.c
CHANGED
@@ -1076,6 +1076,10 @@ void Init_curb_core() {
|
|
1076
1076
|
CURB_DEFINE(CURLOPT_HAPROXYPROTOCOL);
|
1077
1077
|
#endif
|
1078
1078
|
|
1079
|
+
#if HAVE_CURLOPT_PROXY_SSL_VERIFYHOST
|
1080
|
+
CURB_DEFINE(CURLOPT_PROXY_SSL_VERIFYHOST);
|
1081
|
+
#endif
|
1082
|
+
|
1079
1083
|
#if HAVE_CURLPROTO_RTMPTE
|
1080
1084
|
CURB_DEFINE(CURLPROTO_RTMPTE);
|
1081
1085
|
#endif
|
data/ext/curb.h
CHANGED
@@ -28,11 +28,11 @@
|
|
28
28
|
#include "curb_macros.h"
|
29
29
|
|
30
30
|
// These should be managed from the Rake 'release' task.
|
31
|
-
#define CURB_VERSION "1.0.
|
32
|
-
#define CURB_VER_NUM
|
31
|
+
#define CURB_VERSION "1.0.2"
|
32
|
+
#define CURB_VER_NUM 1002
|
33
33
|
#define CURB_VER_MAJ 1
|
34
34
|
#define CURB_VER_MIN 0
|
35
|
-
#define CURB_VER_MIC
|
35
|
+
#define CURB_VER_MIC 2
|
36
36
|
#define CURB_VER_PATCH 0
|
37
37
|
|
38
38
|
|
data/ext/curb_easy.c
CHANGED
@@ -3653,6 +3653,11 @@ static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
|
|
3653
3653
|
case CURLOPT_SSL_SESSIONID_CACHE:
|
3654
3654
|
curl_easy_setopt(rbce->curl, CURLOPT_SSL_SESSIONID_CACHE, NUM2LONG(val));
|
3655
3655
|
break;
|
3656
|
+
#endif
|
3657
|
+
#if HAVE_CURLOPT_PROXY_SSL_VERIFYHOST
|
3658
|
+
case CURLOPT_PROXY_SSL_VERIFYHOST:
|
3659
|
+
curl_easy_setopt(rbce->curl, CURLOPT_PROXY_SSL_VERIFYHOST, NUM2LONG(val));
|
3660
|
+
break;
|
3656
3661
|
#endif
|
3657
3662
|
default:
|
3658
3663
|
rb_raise(rb_eTypeError, "Curb unsupported option");
|
@@ -3770,6 +3775,7 @@ static VALUE ruby_curl_easy_error_message(VALUE klass, VALUE code) {
|
|
3770
3775
|
}
|
3771
3776
|
|
3772
3777
|
/* =================== INIT LIB =====================*/
|
3778
|
+
// TODO: https://bugs.ruby-lang.org/issues/18007
|
3773
3779
|
void init_curb_easy() {
|
3774
3780
|
idCall = rb_intern("call");
|
3775
3781
|
idJoin = rb_intern("join");
|
data/ext/curb_macros.h
CHANGED
@@ -156,4 +156,10 @@
|
|
156
156
|
#define CURB_DEFINE(name) \
|
157
157
|
rb_define_const(mCurl, #name, LONG2NUM(name))
|
158
158
|
|
159
|
+
#define CURB_RB_CALLBACK_RAISE(context) \
|
160
|
+
VALUE exception = rb_errinfo(); \
|
161
|
+
const char *msg = rb_respond_to(exception,rb_intern("message")) ? RSTRING_PTR(rb_funcall(exception, rb_intern("message"), 0)) : ""; \
|
162
|
+
rb_set_errinfo(Qnil); \
|
163
|
+
rb_raise(eCurlErrAbortedByCallback, "Operation was aborted by an application callback[%s]:\"%s\"", context, msg);
|
164
|
+
|
159
165
|
#endif
|
data/ext/curb_multi.c
CHANGED
@@ -43,10 +43,6 @@ static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy);
|
|
43
43
|
static void rb_curl_multi_read_info(VALUE self, CURLM *mptr);
|
44
44
|
static void rb_curl_multi_run(VALUE self, CURLM *multi_handle, int *still_running);
|
45
45
|
|
46
|
-
static VALUE callback_exception(VALUE unused) {
|
47
|
-
return Qfalse;
|
48
|
-
}
|
49
|
-
|
50
46
|
void curl_multi_free(ruby_curl_multi *rbcm) {
|
51
47
|
curl_multi_cleanup(rbcm->handle);
|
52
48
|
free(rbcm);
|
@@ -274,7 +270,7 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
|
|
274
270
|
long response_code = -1;
|
275
271
|
VALUE easy;
|
276
272
|
ruby_curl_easy *rbce = NULL;
|
277
|
-
VALUE callargs
|
273
|
+
VALUE callargs;
|
278
274
|
|
279
275
|
CURLcode ecode = curl_easy_getinfo(easy_handle, CURLINFO_PRIVATE, (char**)&easy);
|
280
276
|
|
@@ -295,11 +291,16 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
|
|
295
291
|
raise_curl_easy_error_exception(ecode);
|
296
292
|
}
|
297
293
|
|
294
|
+
int status;
|
295
|
+
|
298
296
|
if (!rb_easy_nil("complete_proc")) {
|
299
297
|
callargs = rb_ary_new3(2, rb_easy_get("complete_proc"), easy);
|
300
298
|
rbce->callback_active = 1;
|
301
|
-
|
299
|
+
rb_protect(call_status_handler1, callargs, &status);
|
302
300
|
rbce->callback_active = 0;
|
301
|
+
if (status) {
|
302
|
+
CURB_RB_CALLBACK_RAISE("complete")
|
303
|
+
}
|
303
304
|
}
|
304
305
|
|
305
306
|
#ifdef HAVE_CURLINFO_RESPONSE_CODE
|
@@ -308,42 +309,55 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
|
|
308
309
|
// old libcurl
|
309
310
|
curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CODE, &response_code);
|
310
311
|
#endif
|
312
|
+
long redirect_count;
|
313
|
+
curl_easy_getinfo(rbce->curl, CURLINFO_REDIRECT_COUNT, &redirect_count);
|
311
314
|
|
312
315
|
if (result != 0) {
|
313
316
|
if (!rb_easy_nil("failure_proc")) {
|
314
317
|
callargs = rb_ary_new3(3, rb_easy_get("failure_proc"), easy, rb_curl_easy_error(result));
|
315
318
|
rbce->callback_active = 1;
|
316
|
-
|
319
|
+
rb_protect(call_status_handler2, callargs, &status);
|
317
320
|
rbce->callback_active = 0;
|
318
|
-
|
321
|
+
if (status) {
|
322
|
+
CURB_RB_CALLBACK_RAISE("failure")
|
323
|
+
}
|
319
324
|
}
|
320
325
|
} else if (!rb_easy_nil("success_proc") &&
|
321
326
|
((response_code >= 200 && response_code < 300) || response_code == 0)) {
|
322
327
|
/* NOTE: we allow response_code == 0, in the case of non http requests e.g. reading from disk */
|
323
328
|
callargs = rb_ary_new3(2, rb_easy_get("success_proc"), easy);
|
324
329
|
rbce->callback_active = 1;
|
325
|
-
|
330
|
+
rb_protect(call_status_handler1, callargs, &status);
|
326
331
|
rbce->callback_active = 0;
|
327
|
-
|
328
|
-
|
329
|
-
|
332
|
+
if (status) {
|
333
|
+
CURB_RB_CALLBACK_RAISE("success")
|
334
|
+
}
|
335
|
+
} else if (!rb_easy_nil("redirect_proc") && ((response_code >= 300 && response_code < 400) || redirect_count > 0) ) {
|
330
336
|
rbce->callback_active = 1;
|
331
337
|
callargs = rb_ary_new3(3, rb_easy_get("redirect_proc"), easy, rb_curl_easy_error(result));
|
332
338
|
rbce->callback_active = 0;
|
333
|
-
|
339
|
+
rb_protect(call_status_handler2, callargs, &status);
|
340
|
+
if (status) {
|
341
|
+
CURB_RB_CALLBACK_RAISE("redirect")
|
342
|
+
}
|
334
343
|
} else if (!rb_easy_nil("missing_proc") &&
|
335
344
|
(response_code >= 400 && response_code < 500)) {
|
336
345
|
rbce->callback_active = 1;
|
337
346
|
callargs = rb_ary_new3(3, rb_easy_get("missing_proc"), easy, rb_curl_easy_error(result));
|
338
347
|
rbce->callback_active = 0;
|
339
|
-
|
348
|
+
rb_protect(call_status_handler2, callargs, &status);
|
349
|
+
if (status) {
|
350
|
+
CURB_RB_CALLBACK_RAISE("missing")
|
351
|
+
}
|
340
352
|
} else if (!rb_easy_nil("failure_proc") &&
|
341
353
|
(response_code >= 500 && response_code <= 999)) {
|
342
354
|
callargs = rb_ary_new3(3, rb_easy_get("failure_proc"), easy, rb_curl_easy_error(result));
|
343
355
|
rbce->callback_active = 1;
|
344
|
-
|
356
|
+
rb_protect(call_status_handler2, callargs, &status);
|
345
357
|
rbce->callback_active = 0;
|
346
|
-
|
358
|
+
if (status) {
|
359
|
+
CURB_RB_CALLBACK_RAISE("failure")
|
360
|
+
}
|
347
361
|
}
|
348
362
|
|
349
363
|
}
|
@@ -627,6 +641,8 @@ void init_curb_multi() {
|
|
627
641
|
idCall = rb_intern("call");
|
628
642
|
cCurlMulti = rb_define_class_under(mCurl, "Multi", rb_cObject);
|
629
643
|
|
644
|
+
rb_undef_alloc_func(cCurlMulti);
|
645
|
+
|
630
646
|
/* Class methods */
|
631
647
|
rb_define_singleton_method(cCurlMulti, "new", ruby_curl_multi_new, 0);
|
632
648
|
rb_define_singleton_method(cCurlMulti, "default_timeout=", ruby_curl_multi_set_default_timeout, 1);
|
data/ext/curb_postfield.c
CHANGED
@@ -498,6 +498,8 @@ void init_curb_postfield() {
|
|
498
498
|
|
499
499
|
cCurlPostField = rb_define_class_under(mCurl, "PostField", rb_cObject);
|
500
500
|
|
501
|
+
rb_undef_alloc_func(cCurlPostField);
|
502
|
+
|
501
503
|
/* Class methods */
|
502
504
|
rb_define_singleton_method(cCurlPostField, "content", ruby_curl_postfield_new_content, -1);
|
503
505
|
rb_define_singleton_method(cCurlPostField, "file", ruby_curl_postfield_new_file, -1);
|
data/ext/curb_upload.c
CHANGED
@@ -72,6 +72,7 @@ VALUE ruby_curl_upload_offset_get(VALUE self) {
|
|
72
72
|
/* =================== INIT LIB =====================*/
|
73
73
|
void init_curb_upload() {
|
74
74
|
cCurlUpload = rb_define_class_under(mCurl, "Upload", rb_cObject);
|
75
|
+
rb_undef_alloc_func(cCurlUpload);
|
75
76
|
rb_define_singleton_method(cCurlUpload, "new", ruby_curl_upload_new, 0);
|
76
77
|
rb_define_method(cCurlUpload, "stream=", ruby_curl_upload_stream_set, 1);
|
77
78
|
rb_define_method(cCurlUpload, "stream", ruby_curl_upload_stream_get, 0);
|
data/ext/extconf.rb
CHANGED
data/tests/bug_crash_on_debug.rb
CHANGED
@@ -20,11 +20,21 @@ class BugCrashOnDebug < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
puts 'b'
|
22
22
|
c = Curl::Easy.new('http://127.0.0.1:9999/test')
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
did_raise = false
|
24
|
+
did_call = false
|
25
|
+
begin
|
26
|
+
c.on_success do|x|
|
27
|
+
puts x.inspect
|
28
|
+
did_call = true
|
29
|
+
raise "error" # this will get swallowed
|
30
|
+
end
|
31
|
+
c.perform
|
32
|
+
rescue => e
|
33
|
+
did_raise = true
|
26
34
|
end
|
27
|
-
c.
|
35
|
+
puts c.response_code
|
36
|
+
assert did_raise
|
37
|
+
assert did_call
|
28
38
|
puts 'c'
|
29
39
|
ensure
|
30
40
|
puts 'd'
|
@@ -28,7 +28,8 @@ class BugCrashOnDebug < Test::Unit::TestCase
|
|
28
28
|
assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
|
29
29
|
c.close
|
30
30
|
ensure
|
31
|
-
server
|
31
|
+
server&.shutdown
|
32
|
+
thread&.exit
|
32
33
|
end
|
33
34
|
|
34
35
|
def test_on_progress_abort
|
@@ -67,7 +68,8 @@ class BugCrashOnDebug < Test::Unit::TestCase
|
|
67
68
|
assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
|
68
69
|
c.close
|
69
70
|
ensure
|
70
|
-
server
|
71
|
+
server&.shutdown
|
72
|
+
thread&.exit
|
71
73
|
end
|
72
74
|
|
73
75
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
|
+
require 'webrick'
|
3
|
+
class ::WEBrick::HTTPServer ; def access_log(config, req, res) ; end ; end
|
4
|
+
class ::WEBrick::BasicLog ; def log(level, data) ; end ; end
|
5
|
+
|
6
|
+
class BugFollowRedirect288 < Test::Unit::TestCase
|
7
|
+
def test_follow_redirect_with_no_redirect
|
8
|
+
server = WEBrick::HTTPServer.new( :Port => 9999 )
|
9
|
+
server.mount_proc("/test") do|req,res|
|
10
|
+
res.body = "hi"
|
11
|
+
res['Content-Type'] = "text/html"
|
12
|
+
end
|
13
|
+
server.mount_proc("/redirect_to_test") do|req,res|
|
14
|
+
res.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, "/test")
|
15
|
+
end
|
16
|
+
|
17
|
+
thread = Thread.new(server) do|srv|
|
18
|
+
srv.start
|
19
|
+
end
|
20
|
+
|
21
|
+
c = Curl::Easy.new('http://127.0.0.1:9999/test')
|
22
|
+
did_call_redirect = false
|
23
|
+
c.on_redirect do|x|
|
24
|
+
did_call_redirect = true
|
25
|
+
end
|
26
|
+
c.perform
|
27
|
+
|
28
|
+
assert !did_call_redirect, "should reach this point redirect should not have been called"
|
29
|
+
|
30
|
+
c = Curl::Easy.new('http://127.0.0.1:9999/test')
|
31
|
+
did_call_redirect = false
|
32
|
+
c.on_redirect do|x|
|
33
|
+
did_call_redirect = true
|
34
|
+
end
|
35
|
+
c.follow_location = true
|
36
|
+
c.perform
|
37
|
+
|
38
|
+
assert_equal 0, c.redirect_count
|
39
|
+
assert !did_call_redirect, "should reach this point redirect should not have been called"
|
40
|
+
|
41
|
+
c = Curl::Easy.new('http://127.0.0.1:9999/redirect_to_test')
|
42
|
+
did_call_redirect = false
|
43
|
+
c.on_redirect do|x|
|
44
|
+
did_call_redirect = true
|
45
|
+
end
|
46
|
+
c.perform
|
47
|
+
assert_equal 307, c.response_code
|
48
|
+
|
49
|
+
assert did_call_redirect, "we should have called on_redirect"
|
50
|
+
|
51
|
+
c = Curl::Easy.new('http://127.0.0.1:9999/redirect_to_test')
|
52
|
+
did_call_redirect = false
|
53
|
+
c.follow_location = true
|
54
|
+
# NOTE: while this API is not supported by libcurl e.g. there is no redirect function callback in libcurl we could
|
55
|
+
# add support in ruby for this by executing this callback if redirect_count is greater than 0 at the end of a request in curb_multi.c
|
56
|
+
c.on_redirect do|x|
|
57
|
+
did_call_redirect = true
|
58
|
+
end
|
59
|
+
c.perform
|
60
|
+
assert_equal 1, c.redirect_count
|
61
|
+
assert_equal 200, c.response_code
|
62
|
+
|
63
|
+
assert did_call_redirect, "we should have called on_redirect"
|
64
|
+
|
65
|
+
c.url = 'http://127.0.0.1:9999/test'
|
66
|
+
c.perform
|
67
|
+
assert_equal 0, c.redirect_count
|
68
|
+
assert_equal 200, c.response_code
|
69
|
+
|
70
|
+
did_raise = false
|
71
|
+
begin
|
72
|
+
c = Curl::Easy.new('http://127.0.0.1:9999/redirect_to_test')
|
73
|
+
did_call_redirect = false
|
74
|
+
c.on_redirect do|x|
|
75
|
+
raise "raise"
|
76
|
+
did_call_redirect = true
|
77
|
+
end
|
78
|
+
c.perform
|
79
|
+
rescue => e
|
80
|
+
did_raise = true
|
81
|
+
end
|
82
|
+
assert did_raise
|
83
|
+
assert_equal 307, c.response_code
|
84
|
+
|
85
|
+
ensure
|
86
|
+
server.stop
|
87
|
+
thread.join
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
|
+
|
3
|
+
require 'webrick'
|
4
|
+
class ::WEBrick::HTTPServer ; def access_log(config, req, res) ; end ; end
|
5
|
+
class ::WEBrick::BasicLog ; def log(level, data) ; end ; end
|
6
|
+
|
7
|
+
require 'curl'
|
8
|
+
|
9
|
+
class BugRaiseOnCallback < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def test_on_complte
|
12
|
+
server = WEBrick::HTTPServer.new( :Port => 9999 )
|
13
|
+
server.mount_proc("/test") do|req,res|
|
14
|
+
res.body = "hi"
|
15
|
+
res['Content-Type'] = "text/html"
|
16
|
+
end
|
17
|
+
thread = Thread.new(server) do|srv|
|
18
|
+
srv.start
|
19
|
+
end
|
20
|
+
c = Curl::Easy.new('http://127.0.0.1:9999/test')
|
21
|
+
did_raise = false
|
22
|
+
begin
|
23
|
+
c.on_complete do|x|
|
24
|
+
assert_equal 'http://127.0.0.1:9999/test', x.url
|
25
|
+
raise "error complete" # this will get swallowed
|
26
|
+
end
|
27
|
+
c.perform
|
28
|
+
rescue => e
|
29
|
+
did_raise = true
|
30
|
+
end
|
31
|
+
assert did_raise, "we want to raise an exception if the ruby callbacks raise"
|
32
|
+
|
33
|
+
ensure
|
34
|
+
server.shutdown
|
35
|
+
thread.exit
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
#test_on_debug
|
data/tests/tc_curl_easy.rb
CHANGED
@@ -721,9 +721,9 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
721
721
|
on_success_called = false
|
722
722
|
curl.on_success {|c|
|
723
723
|
on_success_called = true
|
724
|
-
assert_not_nil c.
|
725
|
-
|
726
|
-
assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.
|
724
|
+
assert_not_nil c.body
|
725
|
+
assert_match /Content-Length: 7714/, c.head
|
726
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body)
|
727
727
|
}
|
728
728
|
curl.perform
|
729
729
|
assert on_success_called, "Success handler not called"
|
@@ -1147,7 +1147,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
1147
1147
|
c = Curl::Easy.new($TEST_URL)
|
1148
1148
|
c.on_success {|x| raise "error" }
|
1149
1149
|
c.perform
|
1150
|
-
rescue => e
|
1150
|
+
rescue Curl::Err::AbortedByCallbackError => e
|
1151
1151
|
assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
|
1152
1152
|
c.close
|
1153
1153
|
end
|
data/tests/tc_curl_multi.rb
CHANGED
@@ -74,7 +74,9 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
74
74
|
assert did_complete
|
75
75
|
after_open = open_fds.call
|
76
76
|
#puts "after_open: #{after_open} before_open: #{before_open.inspect}"
|
77
|
-
|
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"
|
78
80
|
multi.close
|
79
81
|
|
80
82
|
after_open = open_fds.call
|
@@ -480,7 +482,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
480
482
|
{ :url => TestServlet.url, :method => :get }
|
481
483
|
]
|
482
484
|
Curl::Multi.http(urls, {:pipeline => true}) do|easy, code, method|
|
483
|
-
assert_equal
|
485
|
+
assert_equal 200, code
|
484
486
|
case method
|
485
487
|
when :post
|
486
488
|
assert_match(/POST/, easy.body_str)
|
@@ -494,20 +496,20 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
494
496
|
end
|
495
497
|
|
496
498
|
def test_multi_easy_http_with_max_connects
|
497
|
-
|
499
|
+
urls = [
|
498
500
|
{ :url => TestServlet.url + '?q=1', :method => :get },
|
499
501
|
{ :url => TestServlet.url + '?q=2', :method => :get },
|
500
502
|
{ :url => TestServlet.url + '?q=3', :method => :get }
|
501
503
|
]
|
502
504
|
Curl::Multi.http(urls, {:pipeline => true, :max_connects => 1}) do|easy, code, method|
|
503
|
-
assert_equal
|
505
|
+
assert_equal 200, code
|
504
506
|
case method
|
505
507
|
when :post
|
506
|
-
assert_match(/POST/, easy.
|
508
|
+
assert_match(/POST/, easy.body)
|
507
509
|
when :get
|
508
|
-
assert_match(/GET/, easy.
|
510
|
+
assert_match(/GET/, easy.body)
|
509
511
|
when :put
|
510
|
-
assert_match(/PUT/, easy.
|
512
|
+
assert_match(/PUT/, easy.body)
|
511
513
|
end
|
512
514
|
end
|
513
515
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Bamford
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-12-28 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
|
@@ -50,12 +50,14 @@ files:
|
|
50
50
|
- tests/bug_crash_on_progress.rb
|
51
51
|
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
52
52
|
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
53
|
+
- tests/bug_follow_redirect_288.rb
|
53
54
|
- tests/bug_instance_post_differs_from_class_post.rb
|
54
55
|
- tests/bug_issue102.rb
|
55
56
|
- tests/bug_issue277.rb
|
56
57
|
- tests/bug_multi_segfault.rb
|
57
58
|
- tests/bug_postfields_crash.rb
|
58
59
|
- tests/bug_postfields_crash2.rb
|
60
|
+
- tests/bug_raise_on_callback.rb
|
59
61
|
- tests/bug_require_last_or_segfault.rb
|
60
62
|
- tests/bugtests.rb
|
61
63
|
- tests/helper.rb
|
@@ -96,37 +98,39 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
98
|
- !ruby/object:Gem::Version
|
97
99
|
version: '0'
|
98
100
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.2.33
|
100
102
|
signing_key:
|
101
103
|
specification_version: 4
|
102
104
|
summary: Ruby libcurl bindings
|
103
105
|
test_files:
|
104
|
-
- tests/tc_curl_multi.rb
|
105
106
|
- tests/alltests.rb
|
106
|
-
- tests/
|
107
|
-
- tests/tc_curl.rb
|
108
|
-
- tests/bug_postfields_crash.rb
|
107
|
+
- tests/bug_crash_on_debug.rb
|
109
108
|
- tests/bug_crash_on_progress.rb
|
110
|
-
- tests/
|
109
|
+
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
110
|
+
- tests/bug_curb_easy_post_with_string_no_content_length_header.rb
|
111
|
+
- tests/bug_follow_redirect_288.rb
|
112
|
+
- tests/bug_instance_post_differs_from_class_post.rb
|
113
|
+
- tests/bug_issue102.rb
|
111
114
|
- tests/bug_issue277.rb
|
115
|
+
- tests/bug_multi_segfault.rb
|
116
|
+
- tests/bug_postfields_crash.rb
|
112
117
|
- tests/bug_postfields_crash2.rb
|
118
|
+
- tests/bug_raise_on_callback.rb
|
113
119
|
- tests/bug_require_last_or_segfault.rb
|
114
|
-
- tests/
|
115
|
-
- tests/
|
116
|
-
- tests/
|
117
|
-
- tests/tc_curl_protocols.rb
|
118
|
-
- tests/bug_issue102.rb
|
119
|
-
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
120
|
-
- tests/bug_multi_segfault.rb
|
121
|
-
- tests/bug_instance_post_differs_from_class_post.rb
|
120
|
+
- tests/bugtests.rb
|
121
|
+
- tests/helper.rb
|
122
|
+
- tests/mem_check.rb
|
122
123
|
- tests/require_last_or_segfault_script.rb
|
123
|
-
- tests/
|
124
|
+
- tests/signals.rb
|
125
|
+
- tests/tc_curl.rb
|
124
126
|
- tests/tc_curl_download.rb
|
125
127
|
- tests/tc_curl_easy.rb
|
126
|
-
- tests/mem_check.rb
|
127
|
-
- tests/tc_curl_postfield.rb
|
128
|
-
- tests/tc_curl_maxfilesize.rb
|
129
|
-
- tests/bugtests.rb
|
130
128
|
- tests/tc_curl_easy_resolve.rb
|
131
|
-
- tests/
|
132
|
-
- tests/
|
129
|
+
- tests/tc_curl_easy_setopt.rb
|
130
|
+
- tests/tc_curl_maxfilesize.rb
|
131
|
+
- tests/tc_curl_multi.rb
|
132
|
+
- tests/tc_curl_postfield.rb
|
133
|
+
- tests/tc_curl_protocols.rb
|
134
|
+
- tests/timeout.rb
|
135
|
+
- tests/timeout_server.rb
|
136
|
+
- tests/unittests.rb
|