curb 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of curb might be problematic. Click here for more details.
- data/ext/curb.h +3 -3
- data/ext/curb_config.h +2 -2
- data/ext/curb_easy.c +72 -7
- 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 +28 -18
- data/ext/extconf.rb +14 -0
- data/tests/tc_curl_easy.rb +15 -1
- metadata +19 -17
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.7"
|
24
|
+
#define CURB_VER_NUM 370
|
25
25
|
#define CURB_VER_MAJ 0
|
26
26
|
#define CURB_VER_MIN 3
|
27
|
-
#define CURB_VER_MIC
|
27
|
+
#define CURB_VER_MIC 7
|
28
28
|
#define CURB_VER_PATCH 0
|
29
29
|
|
30
30
|
|
data/ext/curb_config.h
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
#define HAVE_CURLE_SSL_ENGINE_INITFAILED 1
|
39
39
|
#define HAVE_CURLE_LOGIN_DENIED 1
|
40
40
|
#define HAVE_CURLMOPT_MAXCONNECTS 1
|
41
|
-
#define
|
42
|
-
#define
|
41
|
+
#define HAVE_CURLMOPT_PIPELINING 1
|
42
|
+
#define HAVE_RUBY19_ST_H 1
|
43
43
|
#define HAVE_CURL_EASY_ESCAPE 1
|
44
44
|
#endif
|
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);
|
@@ -138,6 +140,10 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
|
|
138
140
|
rb_gc_mark(rbce->postdata_buffer);
|
139
141
|
rb_gc_mark(rbce->bodybuf);
|
140
142
|
rb_gc_mark(rbce->headerbuf);
|
143
|
+
|
144
|
+
if( rbce->self != Qnil ) {
|
145
|
+
rb_gc_mark(rbce->self);
|
146
|
+
}
|
141
147
|
}
|
142
148
|
|
143
149
|
void curl_easy_free(ruby_curl_easy *rbce) {
|
@@ -186,6 +192,8 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
|
|
186
192
|
rbce->userpwd = Qnil;
|
187
193
|
rbce->proxypwd = Qnil;
|
188
194
|
rbce->headers = rb_hash_new();
|
195
|
+
rbce->cookies = Qnil;
|
196
|
+
rbce->cookiefile = Qnil;
|
189
197
|
rbce->cookiejar = Qnil;
|
190
198
|
rbce->cert = Qnil;
|
191
199
|
rbce->encoding = Qnil;
|
@@ -224,6 +232,8 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
|
|
224
232
|
rbce->bodybuf = Qnil;
|
225
233
|
rbce->headerbuf = Qnil;
|
226
234
|
rbce->curl_headers = NULL;
|
235
|
+
|
236
|
+
rbce->self = Qnil;
|
227
237
|
|
228
238
|
new_curl = Data_Wrap_Struct(cCurlEasy, curl_easy_mark, curl_easy_free, rbce);
|
229
239
|
|
@@ -429,12 +439,58 @@ static VALUE ruby_curl_easy_proxypwd_get(VALUE self) {
|
|
429
439
|
CURB_OBJECT_GETTER(ruby_curl_easy, proxypwd);
|
430
440
|
}
|
431
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
|
+
|
432
488
|
/*
|
433
489
|
* call-seq:
|
434
490
|
* easy.cookiejar = "cookiejar.file" => "pwd string"
|
435
491
|
*
|
436
|
-
* Set a cookiejar file to use for this Curl::Easy instance.
|
437
|
-
* 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.
|
438
494
|
*
|
439
495
|
* *Note* that you must set enable_cookies true to enable the cookie
|
440
496
|
* engine, or this option will be ignored.
|
@@ -1374,11 +1430,19 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
|
|
1374
1430
|
if (rbce->enable_cookies) {
|
1375
1431
|
if (rbce->cookiejar != Qnil) {
|
1376
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));
|
1377
1437
|
} else {
|
1378
1438
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* "" = magic to just enable */
|
1379
1439
|
}
|
1380
1440
|
}
|
1381
1441
|
|
1442
|
+
if (rbce->cookies != Qnil) {
|
1443
|
+
curl_easy_setopt(curl, CURLOPT_COOKIE, StringValuePtr(rbce->cookies));
|
1444
|
+
}
|
1445
|
+
|
1382
1446
|
/* Set up HTTPS cert handling if necessary */
|
1383
1447
|
if (rbce->cert != Qnil) {
|
1384
1448
|
curl_easy_setopt(curl, CURLOPT_SSLCERT, StringValuePtr(rbce->cert));
|
@@ -1633,8 +1697,7 @@ static VALUE ruby_curl_easy_perform_delete(VALUE self) {
|
|
1633
1697
|
*
|
1634
1698
|
* Transfer the currently configured URL using the options set for this
|
1635
1699
|
* Curl::Easy instance. If this is an HTTP URL, it will be transferred via
|
1636
|
-
* the GET request method
|
1637
|
-
* when using HTTP URLs).
|
1700
|
+
* the GET or HEAD request method.
|
1638
1701
|
*/
|
1639
1702
|
static VALUE ruby_curl_easy_perform(VALUE self) {
|
1640
1703
|
ruby_curl_easy *rbce;
|
@@ -1743,7 +1806,6 @@ static VALUE ruby_curl_easy_perform_head(VALUE self) {
|
|
1743
1806
|
return handle_perform(self,rbce);
|
1744
1807
|
}
|
1745
1808
|
|
1746
|
-
|
1747
1809
|
/*
|
1748
1810
|
*call-seq:
|
1749
1811
|
* easy = Curl::Easy.new("url") do|c|
|
@@ -1766,7 +1828,6 @@ static VALUE ruby_curl_easy_set_head_option(VALUE self, VALUE onoff) {
|
|
1766
1828
|
return onoff;
|
1767
1829
|
}
|
1768
1830
|
|
1769
|
-
|
1770
1831
|
/*
|
1771
1832
|
* call-seq:
|
1772
1833
|
* easy.http_put(data) => true
|
@@ -2578,6 +2639,10 @@ void init_curb_easy() {
|
|
2578
2639
|
rb_define_method(cCurlEasy, "userpwd", ruby_curl_easy_userpwd_get, 0);
|
2579
2640
|
rb_define_method(cCurlEasy, "proxypwd=", ruby_curl_easy_proxypwd_set, 1);
|
2580
2641
|
rb_define_method(cCurlEasy, "proxypwd", ruby_curl_easy_proxypwd_get, 0);
|
2642
|
+
rb_define_method(cCurlEasy, "cookies=", ruby_curl_easy_cookies_set, 1);
|
2643
|
+
rb_define_method(cCurlEasy, "cookies", ruby_curl_easy_cookies_get, 0);
|
2644
|
+
rb_define_method(cCurlEasy, "cookiefile=", ruby_curl_easy_cookiefile_set, 1);
|
2645
|
+
rb_define_method(cCurlEasy, "cookiefile", ruby_curl_easy_cookiefile_get, 0);
|
2581
2646
|
rb_define_method(cCurlEasy, "cookiejar=", ruby_curl_easy_cookiejar_set, 1);
|
2582
2647
|
rb_define_method(cCurlEasy, "cookiejar", ruby_curl_easy_cookiejar_get, 0);
|
2583
2648
|
rb_define_method(cCurlEasy, "cert=", ruby_curl_easy_cert_set, 1);
|
@@ -2644,8 +2709,8 @@ void init_curb_easy() {
|
|
2644
2709
|
rb_define_method(cCurlEasy, "http_get", ruby_curl_easy_perform_get, 0);
|
2645
2710
|
rb_define_method(cCurlEasy, "http_post", ruby_curl_easy_perform_post, -1);
|
2646
2711
|
rb_define_method(cCurlEasy, "http_head", ruby_curl_easy_perform_head, 0);
|
2647
|
-
rb_define_method(cCurlEasy, "head=", ruby_curl_easy_set_head_option, 1);
|
2648
2712
|
rb_define_method(cCurlEasy, "http_put", ruby_curl_easy_perform_put, 1);
|
2713
|
+
rb_define_method(cCurlEasy, "head=", ruby_curl_easy_set_head_option, 1);
|
2649
2714
|
|
2650
2715
|
/* Post-perform info methods */
|
2651
2716
|
rb_define_method(cCurlEasy, "body_str", ruby_curl_easy_body_str_get, 0);
|
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) {
|
@@ -151,7 +163,7 @@ static VALUE ruby_curl_multi_add(VALUE self, VALUE easy) {
|
|
151
163
|
curl_multi_perform(rbcm->handle, &(rbcm->running));
|
152
164
|
}
|
153
165
|
|
154
|
-
rb_hash_aset( rbcm->requests,
|
166
|
+
rb_hash_aset( rbcm->requests, easy, easy );
|
155
167
|
// active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
|
156
168
|
|
157
169
|
if (rbcm->active > rbcm->running) {
|
@@ -184,8 +196,6 @@ static VALUE ruby_curl_multi_remove(VALUE self, VALUE easy) {
|
|
184
196
|
Data_Get_Struct(easy, ruby_curl_easy, rbce);
|
185
197
|
|
186
198
|
rb_curl_multi_remove(rbcm,easy);
|
187
|
-
// active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
|
188
|
-
rb_hash_delete( rbcm->requests, rb_int_new((long)rbce->curl) );
|
189
199
|
|
190
200
|
return self;
|
191
201
|
}
|
@@ -206,6 +216,12 @@ static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy) {
|
|
206
216
|
ruby_curl_easy_cleanup( easy, rbce, rbce->bodybuf, rbce->headerbuf, rbce->curl_headers );
|
207
217
|
rbce->headerbuf = Qnil;
|
208
218
|
rbce->bodybuf = Qnil;
|
219
|
+
|
220
|
+
// active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
|
221
|
+
VALUE r = rb_hash_delete( rbcm->requests, easy );
|
222
|
+
if( r != easy || r == Qnil ) {
|
223
|
+
rb_raise(rb_eRuntimeError, "Critical:: Unable to remove easy from requests");
|
224
|
+
}
|
209
225
|
}
|
210
226
|
|
211
227
|
static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) {
|
@@ -214,7 +230,6 @@ static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) {
|
|
214
230
|
CURLcode ecode;
|
215
231
|
CURL *easy_handle;
|
216
232
|
ruby_curl_easy *rbce = NULL;
|
217
|
-
// VALUE finished = rb_ary_new();
|
218
233
|
|
219
234
|
/* check for finished easy handles and remove from the multi handle */
|
220
235
|
while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
|
@@ -230,12 +245,10 @@ static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) {
|
|
230
245
|
if (ecode != 0) {
|
231
246
|
raise_curl_easy_error_exception(ecode);
|
232
247
|
}
|
233
|
-
//printf( "finished: 0x%X\n", (long)rbce->self );
|
234
|
-
//rb_ary_push(finished, rbce->self);
|
235
248
|
ruby_curl_multi_remove( self, rbce->self );
|
236
249
|
|
237
250
|
if (rbce->complete_proc != Qnil) {
|
238
|
-
rb_funcall( rbce->complete_proc, idCall, 1,
|
251
|
+
rb_funcall( rbce->complete_proc, idCall, 1, self );
|
239
252
|
}
|
240
253
|
|
241
254
|
long response_code = -1;
|
@@ -255,18 +268,12 @@ static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) {
|
|
255
268
|
(response_code >= 300 && response_code <= 999)) {
|
256
269
|
rb_funcall( rbce->failure_proc, idCall, 1, rbce->self );
|
257
270
|
}
|
271
|
+
rbce->self = Qnil;
|
258
272
|
}
|
259
273
|
else {
|
260
274
|
//printf( "missing easy handle\n" );
|
261
275
|
}
|
262
276
|
}
|
263
|
-
|
264
|
-
/*
|
265
|
-
while (RARRAY(finished)->len > 0) {
|
266
|
-
//printf( "finished handle\n" );
|
267
|
-
ruby_curl_multi_remove( self, rb_ary_pop(finished) );
|
268
|
-
}
|
269
|
-
*/
|
270
277
|
}
|
271
278
|
|
272
279
|
/* called within ruby_curl_multi_perform */
|
@@ -324,20 +331,23 @@ static VALUE ruby_curl_multi_perform(VALUE self) {
|
|
324
331
|
raise_curl_multi_error_exception(mcode);
|
325
332
|
}
|
326
333
|
|
334
|
+
#ifdef HAVE_CURL_MULTI_TIMEOUT
|
327
335
|
/* get the curl suggested time out */
|
328
336
|
mcode = curl_multi_timeout(rbcm->handle, &timeout);
|
329
337
|
if (mcode != CURLM_OK) {
|
330
338
|
raise_curl_multi_error_exception(mcode);
|
331
339
|
}
|
340
|
+
#else
|
341
|
+
/* libcurl doesn't have a timeout method defined... make a wild guess */
|
342
|
+
timeout = 1; /* wait a second */
|
343
|
+
#endif
|
332
344
|
|
333
345
|
if (timeout == 0) { /* no delay */
|
334
346
|
rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
|
335
347
|
continue;
|
336
348
|
}
|
337
349
|
else if (timeout == -1) {
|
338
|
-
timeout = 1; /*
|
339
|
-
(more than a few seconds perhaps) before
|
340
|
-
you call curl_multi_perform() again */
|
350
|
+
timeout = 1; /* wait a second */
|
341
351
|
}
|
342
352
|
|
343
353
|
if (rb_block_given_p()) {
|
data/ext/extconf.rb
CHANGED
@@ -78,9 +78,23 @@ 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"
|
95
|
+
have_func("curl_multi_timeout")
|
96
|
+
have_func("curl_multi_fdset")
|
97
|
+
have_func("curl_multi_perform")
|
84
98
|
|
85
99
|
if try_compile('int main() { return 0; }','-Wall')
|
86
100
|
$CFLAGS << ' -Wall'
|
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: curb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
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-17 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -32,19 +32,21 @@ files:
|
|
32
32
|
- lib/curb.rb
|
33
33
|
- lib/curl.rb
|
34
34
|
- ext/curb.c
|
35
|
-
- ext/curb_postfield.c
|
36
|
-
- ext/curb_multi.c
|
37
|
-
- ext/curb_errors.c
|
38
35
|
- ext/curb_easy.c
|
36
|
+
- ext/curb_errors.c
|
37
|
+
- ext/curb_multi.c
|
38
|
+
- ext/curb_postfield.c
|
39
|
+
- ext/curb.h
|
40
|
+
- ext/curb_config.h
|
39
41
|
- ext/curb_easy.h
|
40
42
|
- ext/curb_errors.h
|
41
43
|
- ext/curb_macros.h
|
42
|
-
- ext/curb.h
|
43
|
-
- ext/curb_postfield.h
|
44
|
-
- ext/curb_config.h
|
45
44
|
- ext/curb_multi.h
|
45
|
+
- ext/curb_postfield.h
|
46
46
|
has_rdoc: true
|
47
47
|
homepage: http://curb.rubyforge.org/
|
48
|
+
licenses: []
|
49
|
+
|
48
50
|
post_install_message:
|
49
51
|
rdoc_options:
|
50
52
|
- --main
|
@@ -67,19 +69,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
69
|
requirements: []
|
68
70
|
|
69
71
|
rubyforge_project: curb
|
70
|
-
rubygems_version: 1.3.
|
72
|
+
rubygems_version: 1.3.2
|
71
73
|
signing_key:
|
72
|
-
specification_version:
|
74
|
+
specification_version: 3
|
73
75
|
summary: Ruby libcurl bindings
|
74
76
|
test_files:
|
75
|
-
- tests/
|
76
|
-
- tests/tc_curl_postfield.rb
|
77
|
+
- tests/alltests.rb
|
77
78
|
- tests/bug_curb_easy_blocks_ruby_threads.rb
|
78
|
-
- tests/unittests.rb
|
79
|
-
- tests/bug_require_last_or_segfault.rb
|
80
79
|
- tests/bug_instance_post_differs_from_class_post.rb
|
81
|
-
- tests/
|
82
|
-
- tests/alltests.rb
|
80
|
+
- tests/bug_require_last_or_segfault.rb
|
83
81
|
- tests/helper.rb
|
84
|
-
- tests/tc_curl_easy.rb
|
85
82
|
- tests/require_last_or_segfault_script.rb
|
83
|
+
- tests/tc_curl_download.rb
|
84
|
+
- tests/tc_curl_easy.rb
|
85
|
+
- tests/tc_curl_multi.rb
|
86
|
+
- tests/tc_curl_postfield.rb
|
87
|
+
- tests/unittests.rb
|