taf2-curb 0.3.5.0 → 0.3.6.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.
- data/ext/curb.h +3 -3
- data/ext/curb_easy.c +64 -2
- data/ext/curb_easy.h +2 -0
- data/ext/curb_errors.c +77 -0
- data/ext/curb_errors.h +9 -0
- data/ext/curb_multi.c +14 -2
- data/ext/extconf.rb +11 -0
- data/tests/tc_curl_easy.rb +15 -1
- metadata +2 -2
data/ext/curb.h
CHANGED
@@ -20,11 +20,11 @@
|
|
20
20
|
#include "curb_macros.h"
|
21
21
|
|
22
22
|
// These should be managed from the Rake 'release' task.
|
23
|
-
#define CURB_VERSION "0.3.
|
24
|
-
#define CURB_VER_NUM
|
23
|
+
#define CURB_VERSION "0.3.6.0"
|
24
|
+
#define CURB_VER_NUM 360
|
25
25
|
#define CURB_VER_MAJ 0
|
26
26
|
#define CURB_VER_MIN 3
|
27
|
-
#define CURB_VER_MIC
|
27
|
+
#define CURB_VER_MIC 6
|
28
28
|
#define CURB_VER_PATCH 0
|
29
29
|
|
30
30
|
|
data/ext/curb_easy.c
CHANGED
@@ -128,6 +128,8 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
|
|
128
128
|
rb_gc_mark(rbce->userpwd);
|
129
129
|
rb_gc_mark(rbce->proxypwd);
|
130
130
|
rb_gc_mark(rbce->headers);
|
131
|
+
rb_gc_mark(rbce->cookies);
|
132
|
+
rb_gc_mark(rbce->cookiefile);
|
131
133
|
rb_gc_mark(rbce->cookiejar);
|
132
134
|
rb_gc_mark(rbce->cert);
|
133
135
|
rb_gc_mark(rbce->encoding);
|
@@ -190,6 +192,8 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
|
|
190
192
|
rbce->userpwd = Qnil;
|
191
193
|
rbce->proxypwd = Qnil;
|
192
194
|
rbce->headers = rb_hash_new();
|
195
|
+
rbce->cookies = Qnil;
|
196
|
+
rbce->cookiefile = Qnil;
|
193
197
|
rbce->cookiejar = Qnil;
|
194
198
|
rbce->cert = Qnil;
|
195
199
|
rbce->encoding = Qnil;
|
@@ -435,12 +439,58 @@ static VALUE ruby_curl_easy_proxypwd_get(VALUE self) {
|
|
435
439
|
CURB_OBJECT_GETTER(ruby_curl_easy, proxypwd);
|
436
440
|
}
|
437
441
|
|
442
|
+
|
443
|
+
/*
|
444
|
+
* call-seq:
|
445
|
+
* easy.cookies = "name1=content1; name2=content2;" => "pwd string"
|
446
|
+
*
|
447
|
+
* Set cookies to be sent by this Curl::Easy instance. The format of the string should
|
448
|
+
* be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
|
449
|
+
* Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
|
450
|
+
*/
|
451
|
+
static VALUE ruby_curl_easy_cookies_set(VALUE self, VALUE cookies) {
|
452
|
+
CURB_OBJECT_SETTER(ruby_curl_easy, cookies);
|
453
|
+
}
|
454
|
+
|
455
|
+
/*
|
456
|
+
* call-seq:
|
457
|
+
* easy.cookies => "name1=content1; name2=content2;"
|
458
|
+
*
|
459
|
+
* Obtain the cookies for this Curl::Easy instance.
|
460
|
+
*/
|
461
|
+
static VALUE ruby_curl_easy_cookies_get(VALUE self) {
|
462
|
+
CURB_OBJECT_GETTER(ruby_curl_easy, cookies);
|
463
|
+
}
|
464
|
+
|
465
|
+
/*
|
466
|
+
* call-seq:
|
467
|
+
* easy.cookiefile = "cookies.txt" => "pwd string"
|
468
|
+
*
|
469
|
+
* Set a file that contains cookies to be sent in subsequent requests by this Curl::Easy instance.
|
470
|
+
*
|
471
|
+
* *Note* that you must set enable_cookies true to enable the cookie
|
472
|
+
* engine, or this option will be ignored.
|
473
|
+
*/
|
474
|
+
static VALUE ruby_curl_easy_cookiefile_set(VALUE self, VALUE cookiefile) {
|
475
|
+
CURB_OBJECT_SETTER(ruby_curl_easy, cookiefile);
|
476
|
+
}
|
477
|
+
|
478
|
+
/*
|
479
|
+
* call-seq:
|
480
|
+
* easy.cookiefile => "cookies.txt"
|
481
|
+
*
|
482
|
+
* Obtain the cookiefile file for this Curl::Easy instance.
|
483
|
+
*/
|
484
|
+
static VALUE ruby_curl_easy_cookiefile_get(VALUE self) {
|
485
|
+
CURB_OBJECT_GETTER(ruby_curl_easy, cookiefile);
|
486
|
+
}
|
487
|
+
|
438
488
|
/*
|
439
489
|
* call-seq:
|
440
490
|
* easy.cookiejar = "cookiejar.file" => "pwd string"
|
441
491
|
*
|
442
|
-
* Set a cookiejar file to use for this Curl::Easy instance.
|
443
|
-
* will be
|
492
|
+
* Set a cookiejar file to use for this Curl::Easy instance.
|
493
|
+
* Cookies from the response will be written into this file.
|
444
494
|
*
|
445
495
|
* *Note* that you must set enable_cookies true to enable the cookie
|
446
496
|
* engine, or this option will be ignored.
|
@@ -1380,11 +1430,19 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
|
|
1380
1430
|
if (rbce->enable_cookies) {
|
1381
1431
|
if (rbce->cookiejar != Qnil) {
|
1382
1432
|
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, StringValuePtr(rbce->cookiejar));
|
1433
|
+
}
|
1434
|
+
|
1435
|
+
if (rbce->cookiefile != Qnil) {
|
1436
|
+
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, StringValuePtr(rbce->cookiefile));
|
1383
1437
|
} else {
|
1384
1438
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* "" = magic to just enable */
|
1385
1439
|
}
|
1386
1440
|
}
|
1387
1441
|
|
1442
|
+
if (rbce->cookies != Qnil) {
|
1443
|
+
curl_easy_setopt(curl, CURLOPT_COOKIE, StringValuePtr(rbce->cookies));
|
1444
|
+
}
|
1445
|
+
|
1388
1446
|
/* Set up HTTPS cert handling if necessary */
|
1389
1447
|
if (rbce->cert != Qnil) {
|
1390
1448
|
curl_easy_setopt(curl, CURLOPT_SSLCERT, StringValuePtr(rbce->cert));
|
@@ -2556,6 +2614,10 @@ void init_curb_easy() {
|
|
2556
2614
|
rb_define_method(cCurlEasy, "userpwd", ruby_curl_easy_userpwd_get, 0);
|
2557
2615
|
rb_define_method(cCurlEasy, "proxypwd=", ruby_curl_easy_proxypwd_set, 1);
|
2558
2616
|
rb_define_method(cCurlEasy, "proxypwd", ruby_curl_easy_proxypwd_get, 0);
|
2617
|
+
rb_define_method(cCurlEasy, "cookies=", ruby_curl_easy_cookies_set, 1);
|
2618
|
+
rb_define_method(cCurlEasy, "cookies", ruby_curl_easy_cookies_get, 0);
|
2619
|
+
rb_define_method(cCurlEasy, "cookiefile=", ruby_curl_easy_cookiefile_set, 1);
|
2620
|
+
rb_define_method(cCurlEasy, "cookiefile", ruby_curl_easy_cookiefile_get, 0);
|
2559
2621
|
rb_define_method(cCurlEasy, "cookiejar=", ruby_curl_easy_cookiejar_set, 1);
|
2560
2622
|
rb_define_method(cCurlEasy, "cookiejar", ruby_curl_easy_cookiejar_get, 0);
|
2561
2623
|
rb_define_method(cCurlEasy, "cert=", ruby_curl_easy_cert_set, 1);
|
data/ext/curb_easy.h
CHANGED
data/ext/curb_errors.c
CHANGED
@@ -98,6 +98,16 @@ VALUE eCurlErrTFTPUnknownID;
|
|
98
98
|
VALUE eCurlErrTFTPFileExists;
|
99
99
|
VALUE eCurlErrTFTPNoSuchUser;
|
100
100
|
|
101
|
+
VALUE eCurlErrConvFailed;
|
102
|
+
VALUE eCurlErrConvReqd;
|
103
|
+
VALUE eCurlErrSSLCacertBadfile;
|
104
|
+
VALUE eCurlErrRemoteFileNotFound;
|
105
|
+
VALUE eCurlErrSSH;
|
106
|
+
VALUE eCurlErrSSLShutdownFailed;
|
107
|
+
VALUE eCurlErrAgain;
|
108
|
+
VALUE eCurlErrSSLCRLBadfile;
|
109
|
+
VALUE eCurlErrSSLIssuerError;
|
110
|
+
|
101
111
|
/* multi errors */
|
102
112
|
VALUE mCurlErrCallMultiPerform;
|
103
113
|
VALUE mCurlErrBadHandle;
|
@@ -360,6 +370,63 @@ void raise_curl_easy_error_exception(CURLcode code) {
|
|
360
370
|
case CURLE_TFTP_NOSUCHUSER: /* 74 - No such user */
|
361
371
|
exclz = eCurlErrTFTPNotFound;
|
362
372
|
break;
|
373
|
+
#endif
|
374
|
+
#ifdef HAVE_CURLE_CONV_FAILED
|
375
|
+
case CURLE_CONV_FAILED: /* 75 - conversion failed */
|
376
|
+
exclz = eCurlErrConvFailed;
|
377
|
+
break;
|
378
|
+
#endif
|
379
|
+
#ifdef HAVE_CURLE_CONV_REQD
|
380
|
+
case CURLE_CONV_REQD: /* 76 - caller must register conversion
|
381
|
+
callbacks using curl_easy_setopt options
|
382
|
+
CURLOPT_CONV_FROM_NETWORK_FUNCTION,
|
383
|
+
CURLOPT_CONV_TO_NETWORK_FUNCTION, and
|
384
|
+
CURLOPT_CONV_FROM_UTF8_FUNCTION */
|
385
|
+
exclz = eCurlErrConvReqd;
|
386
|
+
break;
|
387
|
+
#endif
|
388
|
+
#ifdef HAVE_CURLE_SSL_CACERT_BADFILE
|
389
|
+
case CURLE_SSL_CACERT_BADFILE: /* 77 - could not load CACERT file, missing
|
390
|
+
or wrong format */
|
391
|
+
exclz = eCurlErrSSLCacertBadfile;
|
392
|
+
break;
|
393
|
+
#endif
|
394
|
+
#ifdef HAVE_CURLE_REMOTE_FILE_NOT_FOUND
|
395
|
+
case CURLE_REMOTE_FILE_NOT_FOUND: /* 78 - remote file not found */
|
396
|
+
exclz = eCurlErrRemoteFileNotFound;
|
397
|
+
break;
|
398
|
+
#endif
|
399
|
+
#ifdef HAVE_CURLE_SSH
|
400
|
+
case CURLE_SSH: /* 79 - error from the SSH layer, somewhat
|
401
|
+
generic so the error message will be of
|
402
|
+
interest when this has happened */
|
403
|
+
exclz = eCurlErrSSH;
|
404
|
+
break;
|
405
|
+
#endif
|
406
|
+
#ifdef HAVE_CURLE_SSL_SHUTDOWN_FAILED
|
407
|
+
case CURLE_SSL_SHUTDOWN_FAILED: /* 80 - Failed to shut down the SSL
|
408
|
+
connection */
|
409
|
+
exclz = eCurlErrSSLShutdownFailed;
|
410
|
+
break;
|
411
|
+
#endif
|
412
|
+
#ifdef HAVE_CURLE_AGAIN
|
413
|
+
case CURLE_AGAIN: /* 81 - socket is not ready for send/recv,
|
414
|
+
wait till it's ready and try again (Added
|
415
|
+
in 7.18.2) */
|
416
|
+
exclz = eCurlErrAgain;
|
417
|
+
break;
|
418
|
+
#endif
|
419
|
+
#ifdef HAVE_CURLE_SSL_CRL_BADFILE
|
420
|
+
case CURLE_SSL_CRL_BADFILE: /* 82 - could not load CRL file, missing or
|
421
|
+
wrong format (Added in 7.19.0) */
|
422
|
+
exclz = eCurlErrSSLCRLBadfile;
|
423
|
+
break;
|
424
|
+
#endif
|
425
|
+
#ifdef HAVE_CURLE_SSL_ISSUER_ERROR
|
426
|
+
case CURLE_SSL_ISSUER_ERROR: /* 83 - Issuer check failed. (Added in
|
427
|
+
7.19.0) */
|
428
|
+
exclz = eCurlErrSSLIssuerError;
|
429
|
+
break;
|
363
430
|
#endif
|
364
431
|
default:
|
365
432
|
exclz = eCurlErrError;
|
@@ -501,10 +568,20 @@ void init_curb_errors() {
|
|
501
568
|
eCurlErrRecvError = rb_define_class_under(mCurlErr, "RecvError", eCurlErrError);
|
502
569
|
eCurlErrShareInUse = rb_define_class_under(mCurlErr, "ShareInUseError", eCurlErrError);
|
503
570
|
|
571
|
+
eCurlErrConvFailed = rb_define_class_under(mCurlErr, "ConvFailed", eCurlErrError);
|
572
|
+
eCurlErrConvReqd = rb_define_class_under(mCurlErr, "ConvReqd", eCurlErrError);
|
573
|
+
eCurlErrRemoteFileNotFound = rb_define_class_under(mCurlErr, "RemoteFileNotFound", eCurlErrError);
|
574
|
+
eCurlErrAgain = rb_define_class_under(mCurlErr, "Again", eCurlErrError);
|
575
|
+
|
504
576
|
eCurlErrSSLCertificate = rb_define_class_under(mCurlErr, "SSLCertificateError", eCurlErrError);
|
505
577
|
eCurlErrSSLCipher = rb_define_class_under(mCurlErr, "SSLCypherError", eCurlErrError);
|
506
578
|
eCurlErrSSLCACertificate = rb_define_class_under(mCurlErr, "SSLCACertificateError", eCurlErrError);
|
507
579
|
eCurlErrBadContentEncoding = rb_define_class_under(mCurlErr, "BadContentEncodingError", eCurlErrError);
|
580
|
+
eCurlErrSSLCacertBadfile = rb_define_class_under(mCurlErr, "SSLCaertBadFile", eCurlErrError);
|
581
|
+
eCurlErrSSLCRLBadfile = rb_define_class_under(mCurlErr, "SSLCRLBadfile", eCurlErrError);
|
582
|
+
eCurlErrSSLIssuerError = rb_define_class_under(mCurlErr, "SSLIssuerError", eCurlErrError);
|
583
|
+
eCurlErrSSLShutdownFailed = rb_define_class_under(mCurlErr, "SSLShutdownFailed", eCurlErrError);
|
584
|
+
eCurlErrSSH = rb_define_class_under(mCurlErr, "SSH", eCurlErrError);
|
508
585
|
|
509
586
|
eCurlErrLDAPInvalidURL = rb_define_class_under(mCurlErr, "InvalidLDAPURLError", eCurlErrLDAPError);
|
510
587
|
|
data/ext/curb_errors.h
CHANGED
@@ -97,6 +97,15 @@ extern VALUE eCurlErrTFTPIllegalOperation;
|
|
97
97
|
extern VALUE eCurlErrTFTPUnknownID;
|
98
98
|
extern VALUE eCurlErrTFTPFileExists;
|
99
99
|
extern VALUE eCurlErrTFTPNoSuchUser;
|
100
|
+
extern VALUE eCurlErrConvFailed;
|
101
|
+
extern VALUE eCurlErrConvReqd;
|
102
|
+
extern VALUE eCurlErrSSLCacertBadfile;
|
103
|
+
extern VALUE eCurlErrRemoteFileNotFound;
|
104
|
+
extern VALUE eCurlErrSSH;
|
105
|
+
extern VALUE eCurlErrSSLShutdownFailed;
|
106
|
+
extern VALUE eCurlErrAgain;
|
107
|
+
extern VALUE eCurlErrSSLCRLBadfile;
|
108
|
+
extern VALUE eCurlErrSSLIssuerError;
|
100
109
|
|
101
110
|
/* multi errors */
|
102
111
|
extern VALUE mCurlErrCallMultiPerform;
|
data/ext/curb_multi.c
CHANGED
@@ -42,7 +42,19 @@ static void curl_multi_mark(ruby_curl_multi *rbcm) {
|
|
42
42
|
}
|
43
43
|
|
44
44
|
static void curl_multi_flush_easy(VALUE key, VALUE easy, ruby_curl_multi *rbcm) {
|
45
|
-
rb_curl_multi_remove(rbcm, easy);
|
45
|
+
//rb_curl_multi_remove(rbcm, easy);
|
46
|
+
CURLMcode result;
|
47
|
+
ruby_curl_easy *rbce;
|
48
|
+
Data_Get_Struct(easy, ruby_curl_easy, rbce);
|
49
|
+
result = curl_multi_remove_handle(rbcm->handle, rbce->curl);
|
50
|
+
if (result != 0) {
|
51
|
+
raise_curl_multi_error_exception(result);
|
52
|
+
}
|
53
|
+
// XXX: easy handle may not be finished yet... so don't clean it GC pass will get it next time
|
54
|
+
VALUE r = rb_hash_delete( rbcm->requests, easy );
|
55
|
+
if( r != easy || r == Qnil ) {
|
56
|
+
rb_raise(rb_eRuntimeError, "Critical:: Unable to remove easy from requests");
|
57
|
+
}
|
46
58
|
}
|
47
59
|
|
48
60
|
static void curl_multi_free(ruby_curl_multi *rbcm) {
|
@@ -187,7 +199,7 @@ static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy) {
|
|
187
199
|
// active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
|
188
200
|
VALUE r = rb_hash_delete( rbcm->requests, easy );
|
189
201
|
if( r != easy || r == Qnil ) {
|
190
|
-
|
202
|
+
rb_raise(rb_eRuntimeError, "Critical:: Unable to remove easy from requests");
|
191
203
|
}
|
192
204
|
}
|
193
205
|
|
data/ext/extconf.rb
CHANGED
@@ -78,6 +78,17 @@ have_constant "curle_login_denied"
|
|
78
78
|
# older than 7.16.3
|
79
79
|
have_constant "curlmopt_maxconnects"
|
80
80
|
|
81
|
+
# additional consts
|
82
|
+
have_constant "curle_conv_failed"
|
83
|
+
have_constant "curle_conv_reqd"
|
84
|
+
have_constant "curle_ssl_cacert_badfile"
|
85
|
+
have_constant "curle_remote_file_not_found"
|
86
|
+
have_constant "curle_ssh"
|
87
|
+
have_constant "curle_ssl_shutdown_failed"
|
88
|
+
have_constant "curle_again"
|
89
|
+
have_constant "curle_ssl_crl_badfile"
|
90
|
+
have_constant "curle_ssl_issuer_error"
|
91
|
+
|
81
92
|
# centos 4.5 build of libcurl
|
82
93
|
have_constant "curlm_bad_socket"
|
83
94
|
have_constant "curlm_unknown_option"
|
data/tests/tc_curl_easy.rb
CHANGED
@@ -432,7 +432,21 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
432
432
|
assert c.enable_cookies = true
|
433
433
|
assert c.enable_cookies?
|
434
434
|
end
|
435
|
-
|
435
|
+
|
436
|
+
def test_cookies_option
|
437
|
+
c = Curl::Easy.new
|
438
|
+
assert_nil c.cookies
|
439
|
+
assert_equal "name1=content1; name2=content2;", c.cookies = "name1=content1; name2=content2;"
|
440
|
+
assert_equal "name1=content1; name2=content2;", c.cookies
|
441
|
+
end
|
442
|
+
|
443
|
+
def test_cookiefile
|
444
|
+
c = Curl::Easy.new
|
445
|
+
assert_nil c.cookiefile
|
446
|
+
assert_equal "some.file", c.cookiefile = "some.file"
|
447
|
+
assert_equal "some.file", c.cookiefile
|
448
|
+
end
|
449
|
+
|
436
450
|
def test_cookiejar
|
437
451
|
c = Curl::Easy.new
|
438
452
|
assert_nil c.cookiejar
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taf2-curb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Bamford
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-06-
|
13
|
+
date: 2009-06-13 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|