curb 0.7.15 → 0.7.16
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/README +4 -0
- data/Rakefile +7 -3
- data/ext/curb.c +591 -0
- data/ext/curb.h +3 -3
- data/ext/curb_easy.c +261 -379
- data/ext/curb_easy.h +1 -0
- data/ext/curb_errors.c +8 -0
- data/ext/curb_macros.h +4 -0
- data/ext/curb_multi.c +26 -11
- data/ext/extconf.rb +212 -3
- data/lib/curb.rb +2 -307
- data/lib/curl/easy.rb +385 -0
- data/lib/curl/multi.rb +244 -0
- data/tests/bug_crash_on_debug.rb +33 -0
- data/tests/tc_curl_easy.rb +56 -8
- data/tests/tc_curl_easy_setopt.rb +31 -0
- metadata +31 -41
data/ext/curb.h
CHANGED
@@ -20,12 +20,12 @@
|
|
20
20
|
#include "curb_macros.h"
|
21
21
|
|
22
22
|
// These should be managed from the Rake 'release' task.
|
23
|
-
#define CURB_VERSION "0.7.
|
24
|
-
#define CURB_VER_NUM
|
23
|
+
#define CURB_VERSION "0.7.16"
|
24
|
+
#define CURB_VER_NUM 716
|
25
25
|
#define CURB_VER_MAJ 0
|
26
26
|
#define CURB_VER_MIN 7
|
27
27
|
#define CURB_VER_MIC 1
|
28
|
-
#define CURB_VER_PATCH
|
28
|
+
#define CURB_VER_PATCH 6
|
29
29
|
|
30
30
|
|
31
31
|
// Maybe not yet defined in Ruby
|
data/ext/curb_easy.c
CHANGED
@@ -28,6 +28,10 @@ VALUE cCurlEasy;
|
|
28
28
|
|
29
29
|
/* ================== CURL HANDLER FUNCS ==============*/
|
30
30
|
|
31
|
+
static VALUE callback_exception(VALUE unused) {
|
32
|
+
return Qfalse;
|
33
|
+
}
|
34
|
+
|
31
35
|
/* These handle both body and header data */
|
32
36
|
static size_t default_data_handler(char *stream,
|
33
37
|
size_t size,
|
@@ -111,27 +115,54 @@ static size_t proc_data_handler(char *stream,
|
|
111
115
|
}
|
112
116
|
}
|
113
117
|
|
118
|
+
static VALUE call_progress_handler(VALUE ary) {
|
119
|
+
return rb_funcall(rb_ary_entry(ary, 0), idCall, 4,
|
120
|
+
rb_ary_entry(ary, 1), // rb_float_new(dltotal),
|
121
|
+
rb_ary_entry(ary, 2), // rb_float_new(dlnow),
|
122
|
+
rb_ary_entry(ary, 3), // rb_float_new(ultotal),
|
123
|
+
rb_ary_entry(ary, 4)); // rb_float_new(ulnow));
|
124
|
+
}
|
125
|
+
|
114
126
|
static int proc_progress_handler(VALUE proc,
|
115
127
|
double dltotal,
|
116
128
|
double dlnow,
|
117
129
|
double ultotal,
|
118
130
|
double ulnow) {
|
119
131
|
VALUE procret;
|
132
|
+
VALUE callargs = rb_ary_new2(5);
|
133
|
+
|
134
|
+
rb_ary_store(callargs, 0, proc);
|
135
|
+
rb_ary_store(callargs, 1, rb_float_new(dltotal));
|
136
|
+
rb_ary_store(callargs, 2, rb_float_new(dlnow));
|
137
|
+
rb_ary_store(callargs, 3, rb_float_new(ultotal));
|
138
|
+
rb_ary_store(callargs, 4, rb_float_new(ulnow));
|
120
139
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
140
|
+
//v = rb_rescue(range_check, (VALUE)args, range_failed, 0);
|
141
|
+
//procret = rb_funcall(proc, idCall, 4, rb_float_new(dltotal),
|
142
|
+
// rb_float_new(dlnow),
|
143
|
+
// rb_float_new(ultotal),
|
144
|
+
// rb_float_new(ulnow));
|
145
|
+
procret = rb_rescue(call_progress_handler, callargs, callback_exception, Qnil);
|
125
146
|
|
126
147
|
return(((procret == Qfalse) || (procret == Qnil)) ? -1 : 0);
|
127
148
|
}
|
128
149
|
|
150
|
+
static VALUE call_debug_handler(VALUE ary) {
|
151
|
+
return rb_funcall(rb_ary_entry(ary, 0), idCall, 2,
|
152
|
+
rb_ary_entry(ary, 1), // INT2FIX(type),
|
153
|
+
rb_ary_entry(ary, 2)); // rb_str_new(data, data_len)
|
154
|
+
}
|
129
155
|
static int proc_debug_handler(CURL *curl,
|
130
156
|
curl_infotype type,
|
131
157
|
char *data,
|
132
158
|
size_t data_len,
|
133
159
|
VALUE proc) {
|
134
|
-
|
160
|
+
VALUE callargs = rb_ary_new2(3);
|
161
|
+
rb_ary_store(callargs, 0, proc);
|
162
|
+
rb_ary_store(callargs, 1, INT2FIX(type));
|
163
|
+
rb_ary_store(callargs, 2, rb_str_new(data, data_len));
|
164
|
+
rb_rescue(call_debug_handler, callargs, callback_exception, Qnil);
|
165
|
+
//rb_funcall(proc, idCall, 2, INT2FIX(type), rb_str_new(data, data_len));
|
135
166
|
return 0;
|
136
167
|
}
|
137
168
|
|
@@ -347,18 +378,6 @@ static VALUE ruby_curl_easy_reset(VALUE self) {
|
|
347
378
|
|
348
379
|
/* ================ OBJ ATTRIBUTES ==================*/
|
349
380
|
|
350
|
-
/*
|
351
|
-
* call-seq:
|
352
|
-
* easy.url = "http://some.url/" => "http://some.url/"
|
353
|
-
*
|
354
|
-
* Set the URL for subsequent calls to +perform+. It is acceptable
|
355
|
-
* (and even recommended) to reuse Curl::Easy instances by reassigning
|
356
|
-
* the URL between calls to +perform+.
|
357
|
-
*/
|
358
|
-
static VALUE ruby_curl_easy_url_set(VALUE self, VALUE url) {
|
359
|
-
CURB_OBJECT_HSETTER(ruby_curl_easy, url);
|
360
|
-
}
|
361
|
-
|
362
381
|
/*
|
363
382
|
* call-seq:
|
364
383
|
* easy.url => string
|
@@ -369,35 +388,6 @@ static VALUE ruby_curl_easy_url_get(VALUE self) {
|
|
369
388
|
CURB_OBJECT_HGETTER(ruby_curl_easy, url);
|
370
389
|
}
|
371
390
|
|
372
|
-
/*
|
373
|
-
* call-seq:
|
374
|
-
* easy.proxy_url = string => string
|
375
|
-
*
|
376
|
-
* Set the URL of the HTTP proxy to use for subsequent calls to +perform+.
|
377
|
-
* The URL should specify the the host name or dotted IP address. To specify
|
378
|
-
* port number in this string, append :[port] to the end of the host name.
|
379
|
-
* The proxy string may be prefixed with [protocol]:// since any such prefix
|
380
|
-
* will be ignored. The proxy's port number may optionally be specified with
|
381
|
-
* the separate option proxy_port .
|
382
|
-
*
|
383
|
-
* When you tell the library to use an HTTP proxy, libcurl will transparently
|
384
|
-
* convert operations to HTTP even if you specify an FTP URL etc. This may have
|
385
|
-
* an impact on what other features of the library you can use, such as
|
386
|
-
* FTP specifics that don't work unless you tunnel through the HTTP proxy. Such
|
387
|
-
* tunneling is activated with proxy_tunnel = true.
|
388
|
-
*
|
389
|
-
* libcurl respects the environment variables *http_proxy*, *ftp_proxy*,
|
390
|
-
* *all_proxy* etc, if any of those is set. The proxy_url option does however
|
391
|
-
* override any possibly set environment variables.
|
392
|
-
*
|
393
|
-
* Starting with libcurl 7.14.1, the proxy host string given in environment
|
394
|
-
* variables can be specified the exact same way as the proxy can be set with
|
395
|
-
* proxy_url, including protocol prefix (http://) and embedded user + password.
|
396
|
-
*/
|
397
|
-
static VALUE ruby_curl_easy_proxy_url_set(VALUE self, VALUE proxy_url) {
|
398
|
-
CURB_OBJECT_HSETTER(ruby_curl_easy, proxy_url);
|
399
|
-
}
|
400
|
-
|
401
391
|
/*
|
402
392
|
* call-seq:
|
403
393
|
* easy.proxy_url => string
|
@@ -449,17 +439,6 @@ static VALUE ruby_curl_easy_headers_get(VALUE self) {
|
|
449
439
|
return headers;
|
450
440
|
}
|
451
441
|
|
452
|
-
/*
|
453
|
-
* call-seq:
|
454
|
-
* easy.interface = string => string
|
455
|
-
*
|
456
|
-
* Set the interface name to use as the outgoing network interface.
|
457
|
-
* The name can be an interface name, an IP address or a host name.
|
458
|
-
*/
|
459
|
-
static VALUE ruby_curl_easy_interface_set(VALUE self, VALUE interface_hm) {
|
460
|
-
CURB_OBJECT_HSETTER(ruby_curl_easy, interface_hm);
|
461
|
-
}
|
462
|
-
|
463
442
|
/*
|
464
443
|
* call-seq:
|
465
444
|
* easy.interface => string
|
@@ -471,17 +450,6 @@ static VALUE ruby_curl_easy_interface_get(VALUE self) {
|
|
471
450
|
CURB_OBJECT_HGETTER(ruby_curl_easy, interface_hm);
|
472
451
|
}
|
473
452
|
|
474
|
-
/*
|
475
|
-
* call-seq:
|
476
|
-
* easy.userpwd = string => string
|
477
|
-
*
|
478
|
-
* Set the username/password string to use for subsequent calls to +perform+.
|
479
|
-
* The supplied string should have the form "username:password"
|
480
|
-
*/
|
481
|
-
static VALUE ruby_curl_easy_userpwd_set(VALUE self, VALUE userpwd) {
|
482
|
-
CURB_OBJECT_HSETTER(ruby_curl_easy, userpwd);
|
483
|
-
}
|
484
|
-
|
485
453
|
/*
|
486
454
|
* call-seq:
|
487
455
|
* easy.userpwd => string
|
@@ -493,18 +461,6 @@ static VALUE ruby_curl_easy_userpwd_get(VALUE self) {
|
|
493
461
|
CURB_OBJECT_HGETTER(ruby_curl_easy, userpwd);
|
494
462
|
}
|
495
463
|
|
496
|
-
/*
|
497
|
-
* call-seq:
|
498
|
-
* easy.proxypwd = string => string
|
499
|
-
*
|
500
|
-
* Set the username/password string to use for proxy connection during
|
501
|
-
* subsequent calls to +perform+. The supplied string should have the
|
502
|
-
* form "username:password"
|
503
|
-
*/
|
504
|
-
static VALUE ruby_curl_easy_proxypwd_set(VALUE self, VALUE proxypwd) {
|
505
|
-
CURB_OBJECT_HSETTER(ruby_curl_easy, proxypwd);
|
506
|
-
}
|
507
|
-
|
508
464
|
/*
|
509
465
|
* call-seq:
|
510
466
|
* easy.proxypwd => string
|
@@ -517,19 +473,6 @@ static VALUE ruby_curl_easy_proxypwd_get(VALUE self) {
|
|
517
473
|
CURB_OBJECT_HGETTER(ruby_curl_easy, proxypwd);
|
518
474
|
}
|
519
475
|
|
520
|
-
|
521
|
-
/*
|
522
|
-
* call-seq:
|
523
|
-
* easy.cookies = "name1=content1; name2=content2;" => string
|
524
|
-
*
|
525
|
-
* Set cookies to be sent by this Curl::Easy instance. The format of the string should
|
526
|
-
* be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
|
527
|
-
* Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
|
528
|
-
*/
|
529
|
-
static VALUE ruby_curl_easy_cookies_set(VALUE self, VALUE cookies) {
|
530
|
-
CURB_OBJECT_HSETTER(ruby_curl_easy, cookies);
|
531
|
-
}
|
532
|
-
|
533
476
|
/*
|
534
477
|
* call-seq:
|
535
478
|
* easy.cookies => "name1=content1; name2=content2;"
|
@@ -540,19 +483,6 @@ static VALUE ruby_curl_easy_cookies_get(VALUE self) {
|
|
540
483
|
CURB_OBJECT_HGETTER(ruby_curl_easy, cookies);
|
541
484
|
}
|
542
485
|
|
543
|
-
/*
|
544
|
-
* call-seq:
|
545
|
-
* easy.cookiefile = string => string
|
546
|
-
*
|
547
|
-
* Set a file that contains cookies to be sent in subsequent requests by this Curl::Easy instance.
|
548
|
-
*
|
549
|
-
* *Note* that you must set enable_cookies true to enable the cookie
|
550
|
-
* engine, or this option will be ignored.
|
551
|
-
*/
|
552
|
-
static VALUE ruby_curl_easy_cookiefile_set(VALUE self, VALUE cookiefile) {
|
553
|
-
CURB_OBJECT_HSETTER(ruby_curl_easy, cookiefile);
|
554
|
-
}
|
555
|
-
|
556
486
|
/*
|
557
487
|
* call-seq:
|
558
488
|
* easy.cookiefile => string
|
@@ -563,20 +493,6 @@ static VALUE ruby_curl_easy_cookiefile_get(VALUE self) {
|
|
563
493
|
CURB_OBJECT_HGETTER(ruby_curl_easy, cookiefile);
|
564
494
|
}
|
565
495
|
|
566
|
-
/*
|
567
|
-
* call-seq:
|
568
|
-
* easy.cookiejar = string => string
|
569
|
-
*
|
570
|
-
* Set a cookiejar file to use for this Curl::Easy instance.
|
571
|
-
* Cookies from the response will be written into this file.
|
572
|
-
*
|
573
|
-
* *Note* that you must set enable_cookies true to enable the cookie
|
574
|
-
* engine, or this option will be ignored.
|
575
|
-
*/
|
576
|
-
static VALUE ruby_curl_easy_cookiejar_set(VALUE self, VALUE cookiejar) {
|
577
|
-
CURB_OBJECT_HSETTER(ruby_curl_easy, cookiejar);
|
578
|
-
}
|
579
|
-
|
580
496
|
/*
|
581
497
|
* call-seq:
|
582
498
|
* easy.cookiejar => string
|
@@ -1453,7 +1369,7 @@ static VALUE ruby_curl_easy_ssl_verify_peer_q(VALUE self) {
|
|
1453
1369
|
|
1454
1370
|
/*
|
1455
1371
|
* call-seq:
|
1456
|
-
* easy.ssl_verify_host =
|
1372
|
+
* easy.ssl_verify_host = [0, 1, 2] => [0, 1, 2]
|
1457
1373
|
*
|
1458
1374
|
* Configure whether this Curl instance will verify that the server cert
|
1459
1375
|
* is for the server it is known as. When true (the default) the server
|
@@ -1465,18 +1381,18 @@ static VALUE ruby_curl_easy_ssl_verify_peer_q(VALUE self) {
|
|
1465
1381
|
* The server could be lying. To control lying, see ssl_verify_peer? .
|
1466
1382
|
*/
|
1467
1383
|
static VALUE ruby_curl_easy_ssl_verify_host_set(VALUE self, VALUE ssl_verify_host) {
|
1468
|
-
|
1384
|
+
CURB_IMMED_SETTER(ruby_curl_easy, ssl_verify_host, 0);
|
1469
1385
|
}
|
1470
1386
|
|
1471
1387
|
/*
|
1472
1388
|
* call-seq:
|
1473
|
-
* easy.ssl_verify_host
|
1389
|
+
* easy.ssl_verify_host => number
|
1474
1390
|
*
|
1475
1391
|
* Determine whether this Curl instance will verify that the server cert
|
1476
1392
|
* is for the server it is known as.
|
1477
1393
|
*/
|
1478
|
-
static VALUE
|
1479
|
-
|
1394
|
+
static VALUE ruby_curl_easy_ssl_verify_host_get(VALUE self) {
|
1395
|
+
CURB_IMMED_GETTER(ruby_curl_easy, ssl_verify_host, 0);
|
1480
1396
|
}
|
1481
1397
|
|
1482
1398
|
/*
|
@@ -1685,6 +1601,65 @@ static VALUE ruby_curl_easy_ignore_content_length_q(VALUE self) {
|
|
1685
1601
|
CURB_BOOLEAN_GETTER(ruby_curl_easy, ignore_content_length);
|
1686
1602
|
}
|
1687
1603
|
|
1604
|
+
/*
|
1605
|
+
* call-seq:
|
1606
|
+
* easy.resolve_mode => symbol
|
1607
|
+
*
|
1608
|
+
* Determines what type of IP address this Curl::Easy instance
|
1609
|
+
* resolves DNS names to.
|
1610
|
+
*/
|
1611
|
+
static VALUE ruby_curl_easy_resolve_mode(VALUE self) {
|
1612
|
+
ruby_curl_easy *rbce;
|
1613
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
1614
|
+
|
1615
|
+
unsigned short rm = rbce->resolve_mode;
|
1616
|
+
|
1617
|
+
switch(rm) {
|
1618
|
+
case CURL_IPRESOLVE_V4:
|
1619
|
+
return rb_easy_sym("ipv4");
|
1620
|
+
case CURL_IPRESOLVE_V6:
|
1621
|
+
return rb_easy_sym("ipv6");
|
1622
|
+
default:
|
1623
|
+
return rb_easy_sym("auto");
|
1624
|
+
}
|
1625
|
+
}
|
1626
|
+
|
1627
|
+
/*
|
1628
|
+
* call-seq:
|
1629
|
+
* easy.resolve_mode = symbol => symbol
|
1630
|
+
*
|
1631
|
+
* Configures what type of IP address this Curl::Easy instance
|
1632
|
+
* resolves DNS names to. Valid options are:
|
1633
|
+
*
|
1634
|
+
* [:auto] resolves DNS names to all IP versions your system allows
|
1635
|
+
* [:ipv4] resolves DNS names to IPv4 only
|
1636
|
+
* [:ipv6] resolves DNS names to IPv6 only
|
1637
|
+
*/
|
1638
|
+
static VALUE ruby_curl_easy_resolve_mode_set(VALUE self, VALUE resolve_mode) {
|
1639
|
+
if (TYPE(resolve_mode) != T_SYMBOL) {
|
1640
|
+
rb_raise(rb_eTypeError, "Must pass a symbol");
|
1641
|
+
return Qnil;
|
1642
|
+
} else {
|
1643
|
+
ruby_curl_easy *rbce;
|
1644
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
1645
|
+
|
1646
|
+
ID resolve_mode_id = rb_to_id(resolve_mode);
|
1647
|
+
|
1648
|
+
if (resolve_mode_id == rb_intern("auto")) {
|
1649
|
+
rbce->resolve_mode = CURL_IPRESOLVE_WHATEVER;
|
1650
|
+
return resolve_mode;
|
1651
|
+
} else if (resolve_mode_id == rb_intern("ipv4")) {
|
1652
|
+
rbce->resolve_mode = CURL_IPRESOLVE_V4;
|
1653
|
+
return resolve_mode;
|
1654
|
+
} else if (resolve_mode_id == rb_intern("ipv6")) {
|
1655
|
+
rbce->resolve_mode = CURL_IPRESOLVE_V6;
|
1656
|
+
return resolve_mode;
|
1657
|
+
} else {
|
1658
|
+
rb_raise(rb_eArgError, "Must set to one of :auto, :ipv4, :ipv6");
|
1659
|
+
return Qnil;
|
1660
|
+
}
|
1661
|
+
}
|
1662
|
+
}
|
1688
1663
|
|
1689
1664
|
|
1690
1665
|
/* ================= EVENT PROCS ================== */
|
@@ -1816,7 +1791,10 @@ static VALUE ruby_curl_easy_on_debug_set(int argc, VALUE *argv, VALUE self) {
|
|
1816
1791
|
/***********************************************
|
1817
1792
|
* This is an rb_iterate callback used to set up http headers.
|
1818
1793
|
*/
|
1819
|
-
static VALUE cb_each_http_header(VALUE header,
|
1794
|
+
static VALUE cb_each_http_header(VALUE header, VALUE wrap) {
|
1795
|
+
struct curl_slist **list;
|
1796
|
+
Data_Get_Struct(wrap, struct curl_slist *, list);
|
1797
|
+
|
1820
1798
|
VALUE header_str = Qnil;
|
1821
1799
|
|
1822
1800
|
//rb_p(header);
|
@@ -1845,7 +1823,10 @@ static VALUE cb_each_http_header(VALUE header, struct curl_slist **list) {
|
|
1845
1823
|
/***********************************************
|
1846
1824
|
* This is an rb_iterate callback used to set up ftp commands.
|
1847
1825
|
*/
|
1848
|
-
static VALUE cb_each_ftp_command(VALUE ftp_command,
|
1826
|
+
static VALUE cb_each_ftp_command(VALUE ftp_command, VALUE wrap) {
|
1827
|
+
struct curl_slist **list;
|
1828
|
+
Data_Get_Struct(wrap, struct curl_slist *, list);
|
1829
|
+
|
1849
1830
|
VALUE ftp_command_string = rb_obj_as_string(ftp_command);
|
1850
1831
|
*list = curl_slist_append(*list, StringValuePtr(ftp_command));
|
1851
1832
|
|
@@ -1992,6 +1973,8 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
|
|
1992
1973
|
|
1993
1974
|
curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, rbce->ignore_content_length);
|
1994
1975
|
|
1976
|
+
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, rbce->resolve_mode);
|
1977
|
+
|
1995
1978
|
|
1996
1979
|
#if LIBCURL_VERSION_NUM >= 0x070a08
|
1997
1980
|
curl_easy_setopt(curl, CURLOPT_FTP_RESPONSE_TIMEOUT, rbce->ftp_response_timeout);
|
@@ -2077,7 +2060,9 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
|
|
2077
2060
|
|
2078
2061
|
/* Set up HTTPS cert handling if necessary */
|
2079
2062
|
if (!rb_easy_nil("cert")) {
|
2080
|
-
|
2063
|
+
if (!rb_easy_nil("certtype")) {
|
2064
|
+
curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, rb_easy_get_str("certtype"));
|
2065
|
+
}
|
2081
2066
|
curl_easy_setopt(curl, CURLOPT_SSLCERT, rb_easy_get_str("cert"));
|
2082
2067
|
if (!rb_easy_nil("certpassword")) {
|
2083
2068
|
curl_easy_setopt(curl, CURLOPT_SSLCERTPASSWD, rb_easy_get_str("certpassword"));
|
@@ -2086,13 +2071,15 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
|
|
2086
2071
|
curl_easy_setopt(curl, CURLOPT_SSLKEY, rb_easy_get_str("cert_key"));
|
2087
2072
|
}
|
2088
2073
|
}
|
2074
|
+
|
2089
2075
|
if (!rb_easy_nil("cacert")) {
|
2076
|
+
curl_easy_setopt(curl, CURLOPT_CAINFO, rb_easy_get_str("cacert"));
|
2077
|
+
}
|
2090
2078
|
#ifdef HAVE_CURL_CONFIG_CA
|
2079
|
+
else {
|
2091
2080
|
curl_easy_setopt(curl, CURLOPT_CAINFO, CURL_CONFIG_CA);
|
2092
|
-
#else
|
2093
|
-
curl_easy_setopt(curl, CURLOPT_CAINFO, "/usr/local/share/curl/curl-ca-bundle.crt");
|
2094
|
-
#endif
|
2095
2081
|
}
|
2082
|
+
#endif
|
2096
2083
|
|
2097
2084
|
#ifdef CURL_VERSION_SSL
|
2098
2085
|
if (rbce->ssl_version > 0) {
|
@@ -2122,7 +2109,8 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
|
|
2122
2109
|
|
2123
2110
|
if (!rb_easy_nil("headers")) {
|
2124
2111
|
if (rb_easy_type_check("headers", T_ARRAY) || rb_easy_type_check("headers", T_HASH)) {
|
2125
|
-
|
2112
|
+
VALUE wrap = Data_Wrap_Struct(rb_cObject, 0, 0, hdrs);
|
2113
|
+
rb_iterate(rb_each, rb_easy_get("headers"), cb_each_http_header, wrap);
|
2126
2114
|
} else {
|
2127
2115
|
VALUE headers_str = rb_obj_as_string(rb_easy_get("headers"));
|
2128
2116
|
*hdrs = curl_slist_append(*hdrs, StringValuePtr(headers_str));
|
@@ -2136,7 +2124,8 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
|
|
2136
2124
|
/* Setup FTP commands if necessary */
|
2137
2125
|
if (!rb_easy_nil("ftp_commands")) {
|
2138
2126
|
if (rb_easy_type_check("ftp_commands", T_ARRAY)) {
|
2139
|
-
|
2127
|
+
VALUE wrap = Data_Wrap_Struct(rb_cObject, 0, 0, cmds);
|
2128
|
+
rb_iterate(rb_each, rb_easy_get("ftp_commands"), cb_each_ftp_command, wrap);
|
2140
2129
|
}
|
2141
2130
|
|
2142
2131
|
if (*cmds) {
|
@@ -2181,35 +2170,6 @@ VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce ) {
|
|
2181
2170
|
return Qnil;
|
2182
2171
|
}
|
2183
2172
|
|
2184
|
-
/***********************************************
|
2185
|
-
*
|
2186
|
-
* This is the main worker for the perform methods (get, post, head, put).
|
2187
|
-
* It's not surfaced as a Ruby method - instead, the individual request
|
2188
|
-
* methods are responsible for setting up stuff specific to that type,
|
2189
|
-
* then calling this to handle common stuff and do the perform.
|
2190
|
-
*
|
2191
|
-
* Always returns Qtrue, rb_raise on error.
|
2192
|
-
*
|
2193
|
-
*/
|
2194
|
-
static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
|
2195
|
-
|
2196
|
-
VALUE ret;
|
2197
|
-
|
2198
|
-
/* reuse existing multi handle for this easy handle */
|
2199
|
-
if (NIL_P(rbce->multi)) {
|
2200
|
-
rbce->multi = ruby_curl_multi_new(cCurlMulti);
|
2201
|
-
}
|
2202
|
-
rb_funcall(rbce->multi, rb_intern("add"), 1, self );
|
2203
|
-
ret = rb_funcall(rbce->multi, rb_intern("perform"), 0);
|
2204
|
-
|
2205
|
-
/* check for errors in the easy response and raise exceptions if anything went wrong and their is no on_failure handler */
|
2206
|
-
if (rbce->last_result != 0 && rb_easy_nil("failure_proc")) {
|
2207
|
-
raise_curl_easy_error_exception(rbce->last_result);
|
2208
|
-
}
|
2209
|
-
|
2210
|
-
return ret;
|
2211
|
-
}
|
2212
|
-
|
2213
2173
|
/*
|
2214
2174
|
* call-seq:
|
2215
2175
|
* easy.http_get => true
|
@@ -2228,7 +2188,7 @@ static VALUE ruby_curl_easy_perform_get(VALUE self) {
|
|
2228
2188
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL);
|
2229
2189
|
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
|
2230
2190
|
|
2231
|
-
return
|
2191
|
+
return rb_funcall(self, rb_intern("perform"), 0);
|
2232
2192
|
}
|
2233
2193
|
|
2234
2194
|
/*
|
@@ -2244,7 +2204,7 @@ static VALUE ruby_curl_easy_perform_verb_str(VALUE self, const char *verb) {
|
|
2244
2204
|
|
2245
2205
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, verb);
|
2246
2206
|
|
2247
|
-
retval =
|
2207
|
+
retval = rb_funcall(self, rb_intern("perform"), 0);
|
2248
2208
|
|
2249
2209
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL);
|
2250
2210
|
|
@@ -2284,22 +2244,6 @@ static VALUE ruby_curl_easy_perform_verb(VALUE self, VALUE verb) {
|
|
2284
2244
|
}
|
2285
2245
|
}
|
2286
2246
|
|
2287
|
-
/*
|
2288
|
-
* call-seq:
|
2289
|
-
* easy.perform => true
|
2290
|
-
*
|
2291
|
-
* Transfer the currently configured URL using the options set for this
|
2292
|
-
* Curl::Easy instance. If this is an HTTP URL, it will be transferred via
|
2293
|
-
* the GET or HEAD request method.
|
2294
|
-
*/
|
2295
|
-
static VALUE ruby_curl_easy_perform(VALUE self) {
|
2296
|
-
ruby_curl_easy *rbce;
|
2297
|
-
|
2298
|
-
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
2299
|
-
|
2300
|
-
return handle_perform(self,rbce);
|
2301
|
-
}
|
2302
|
-
|
2303
2247
|
/*
|
2304
2248
|
* call-seq:
|
2305
2249
|
* easy.http_post("url=encoded%20form%20data;and=so%20on") => true
|
@@ -2353,7 +2297,7 @@ static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
|
|
2353
2297
|
|
2354
2298
|
curl_easy_setopt(curl, CURLOPT_POST, 0);
|
2355
2299
|
curl_easy_setopt(curl, CURLOPT_HTTPPOST, first);
|
2356
|
-
ret =
|
2300
|
+
ret = rb_funcall(self, rb_intern("perform"), 0);
|
2357
2301
|
curl_formfree(first);
|
2358
2302
|
|
2359
2303
|
return ret;
|
@@ -2375,7 +2319,7 @@ static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
|
|
2375
2319
|
ruby_curl_easy_post_body_set(self, post_body);
|
2376
2320
|
}
|
2377
2321
|
|
2378
|
-
return
|
2322
|
+
return rb_funcall(self, rb_intern("perform"), 0);
|
2379
2323
|
}
|
2380
2324
|
}
|
2381
2325
|
}
|
@@ -2400,7 +2344,7 @@ static VALUE ruby_curl_easy_perform_head(VALUE self) {
|
|
2400
2344
|
|
2401
2345
|
curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
|
2402
2346
|
|
2403
|
-
ret =
|
2347
|
+
ret = rb_funcall(self, rb_intern("perform"), 0);
|
2404
2348
|
|
2405
2349
|
curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
|
2406
2350
|
return ret;
|
@@ -2427,62 +2371,6 @@ static VALUE ruby_curl_easy_set_head_option(VALUE self, VALUE onoff) {
|
|
2427
2371
|
|
2428
2372
|
return onoff;
|
2429
2373
|
}
|
2430
|
-
/*
|
2431
|
-
*call-seq:
|
2432
|
-
*
|
2433
|
-
* easy = Curl::Easy.new("url")
|
2434
|
-
* easy.version = Curl::HTTP_1_1
|
2435
|
-
* easy.version = Curl::HTTP_1_0
|
2436
|
-
* easy.version = Curl::HTTP_NONE
|
2437
|
-
*
|
2438
|
-
*/
|
2439
|
-
static VALUE ruby_curl_easy_set_version(VALUE self, VALUE version) {
|
2440
|
-
ruby_curl_easy *rbce;
|
2441
|
-
//fprintf(stderr,"CURL_HTTP_VERSION_1_1: %d, CURL_HTTP_VERSION_1_0: %d, CURL_HTTP_VERSION_NONE: %d\n", CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_NONE);
|
2442
|
-
|
2443
|
-
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
2444
|
-
|
2445
|
-
curl_easy_setopt(rbce->curl, CURLOPT_HTTP_VERSION, FIX2INT(version));
|
2446
|
-
|
2447
|
-
return version;
|
2448
|
-
}
|
2449
|
-
/*
|
2450
|
-
* call-seq:
|
2451
|
-
*
|
2452
|
-
* easy = Curl::Easy.new
|
2453
|
-
* easy.nosignal = true
|
2454
|
-
*/
|
2455
|
-
static VALUE ruby_curl_easy_set_nosignal(VALUE self, VALUE onoff) {
|
2456
|
-
ruby_curl_easy *rbce;
|
2457
|
-
|
2458
|
-
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
2459
|
-
|
2460
|
-
curl_easy_setopt(rbce->curl, CURLOPT_NOSIGNAL, (Qtrue == onoff) ? 1 : 0);
|
2461
|
-
|
2462
|
-
return onoff;
|
2463
|
-
}
|
2464
|
-
/*
|
2465
|
-
*call-seq:
|
2466
|
-
* easy = Curl::Easy.new("url") do|c|
|
2467
|
-
* c.delete = true
|
2468
|
-
* end
|
2469
|
-
* easy.perform
|
2470
|
-
*/
|
2471
|
-
static VALUE ruby_curl_easy_set_delete_option(VALUE self, VALUE onoff) {
|
2472
|
-
ruby_curl_easy *rbce;
|
2473
|
-
|
2474
|
-
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
2475
|
-
|
2476
|
-
if( onoff == Qtrue ) {
|
2477
|
-
curl_easy_setopt(rbce->curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
2478
|
-
}
|
2479
|
-
else {
|
2480
|
-
curl_easy_setopt(rbce->curl, CURLOPT_CUSTOMREQUEST, NULL);
|
2481
|
-
}
|
2482
|
-
|
2483
|
-
return onoff;
|
2484
|
-
}
|
2485
|
-
|
2486
2374
|
/*
|
2487
2375
|
* call-seq:
|
2488
2376
|
* easy.http_put(data) => true
|
@@ -2501,20 +2389,9 @@ static VALUE ruby_curl_easy_perform_put(VALUE self, VALUE data) {
|
|
2501
2389
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL);
|
2502
2390
|
ruby_curl_easy_put_data_set(self, data);
|
2503
2391
|
|
2504
|
-
return
|
2392
|
+
return rb_funcall(self, rb_intern("perform"), 0);
|
2505
2393
|
}
|
2506
2394
|
|
2507
|
-
/*
|
2508
|
-
* call-seq:
|
2509
|
-
* Curl::Easy.http_put(url, data) {|c| ... }
|
2510
|
-
*
|
2511
|
-
* see easy.http_put
|
2512
|
-
*/
|
2513
|
-
static VALUE ruby_curl_easy_class_perform_put(VALUE klass, VALUE url, VALUE data) {
|
2514
|
-
VALUE c = ruby_curl_easy_new(1, &url, klass);
|
2515
|
-
ruby_curl_easy_perform_put(c, data);
|
2516
|
-
return c;
|
2517
|
-
}
|
2518
2395
|
|
2519
2396
|
/* =================== DATA FUNCS =============== */
|
2520
2397
|
|
@@ -2923,7 +2800,10 @@ static VALUE ruby_curl_easy_ssl_verify_result_get(VALUE self) {
|
|
2923
2800
|
|
2924
2801
|
/* TODO CURLINFO_SSL_ENGINES
|
2925
2802
|
|
2926
|
-
Pass the address of a 'struct curl_slist *' to receive a linked-list of OpenSSL crypto-engines supported.
|
2803
|
+
Pass the address of a 'struct curl_slist *' to receive a linked-list of OpenSSL crypto-engines supported.
|
2804
|
+
Note that engines are normally implemented in separate dynamic libraries.
|
2805
|
+
Hence not all the returned engines may be available at run-time.
|
2806
|
+
NOTE: you must call curl_slist_free_all(3) on the list pointer once you're done with it, as libcurl will not free the data for you. (Added in 7.12.3)
|
2927
2807
|
*/
|
2928
2808
|
|
2929
2809
|
/*
|
@@ -3099,6 +2979,119 @@ static VALUE ruby_curl_easy_ftp_entry_path_get(VALUE self) {
|
|
3099
2979
|
#endif
|
3100
2980
|
}
|
3101
2981
|
|
2982
|
+
/*
|
2983
|
+
* call-seq:
|
2984
|
+
* easy.multi => "#<Curl::Multi>"
|
2985
|
+
*/
|
2986
|
+
static VALUE ruby_curl_easy_multi_get(VALUE self) {
|
2987
|
+
ruby_curl_easy *rbce;
|
2988
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
2989
|
+
return rbce->multi;
|
2990
|
+
}
|
2991
|
+
|
2992
|
+
/*
|
2993
|
+
* call-seq:
|
2994
|
+
* easy.multi=multi => "#<Curl::Multi>"
|
2995
|
+
*/
|
2996
|
+
static VALUE ruby_curl_easy_multi_set(VALUE self, VALUE multi) {
|
2997
|
+
ruby_curl_easy *rbce;
|
2998
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
2999
|
+
rbce->multi = multi;
|
3000
|
+
return rbce->multi;
|
3001
|
+
}
|
3002
|
+
|
3003
|
+
/*
|
3004
|
+
* call-seq:
|
3005
|
+
* easy.last_result => 0
|
3006
|
+
*/
|
3007
|
+
static VALUE ruby_curl_easy_last_result(VALUE self) {
|
3008
|
+
ruby_curl_easy *rbce;
|
3009
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
3010
|
+
return INT2FIX(rbce->last_result);
|
3011
|
+
}
|
3012
|
+
|
3013
|
+
/*
|
3014
|
+
* call-seq:
|
3015
|
+
* easy.setopt Fixnum, value => value
|
3016
|
+
*
|
3017
|
+
* Iniital access to libcurl curl_easy_setopt
|
3018
|
+
*/
|
3019
|
+
static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
|
3020
|
+
ruby_curl_easy *rbce;
|
3021
|
+
long option = FIX2LONG(opt);
|
3022
|
+
|
3023
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
3024
|
+
|
3025
|
+
switch (option) {
|
3026
|
+
/* BEHAVIOR OPTIONS */
|
3027
|
+
case CURLOPT_VERBOSE: {
|
3028
|
+
VALUE verbose = val;
|
3029
|
+
CURB_BOOLEAN_SETTER(ruby_curl_easy, verbose);
|
3030
|
+
} break;
|
3031
|
+
case CURLOPT_HEADER:
|
3032
|
+
case CURLOPT_NOPROGRESS:
|
3033
|
+
case CURLOPT_NOSIGNAL:
|
3034
|
+
curl_easy_setopt(rbce->curl, CURLOPT_NOSIGNAL, val == Qtrue ? 1 : 0);
|
3035
|
+
break;
|
3036
|
+
/* TODO: CALLBACK OPTIONS */
|
3037
|
+
/* TODO: ERROR OPTIONS */
|
3038
|
+
/* NETWORK OPTIONS */
|
3039
|
+
case CURLOPT_URL: {
|
3040
|
+
VALUE url = val;
|
3041
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, url);
|
3042
|
+
} break;
|
3043
|
+
case CURLOPT_CUSTOMREQUEST:
|
3044
|
+
curl_easy_setopt(rbce->curl, CURLOPT_CUSTOMREQUEST, NIL_P(val) ? NULL : StringValueCStr(val));
|
3045
|
+
break;
|
3046
|
+
case CURLOPT_HTTP_VERSION:
|
3047
|
+
curl_easy_setopt(rbce->curl, CURLOPT_HTTP_VERSION, FIX2INT(val));
|
3048
|
+
break;
|
3049
|
+
case CURLOPT_PROXY: {
|
3050
|
+
VALUE proxy_url = val;
|
3051
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, proxy_url);
|
3052
|
+
} break;
|
3053
|
+
case CURLOPT_INTERFACE: {
|
3054
|
+
VALUE interface_hm = val;
|
3055
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, interface_hm);
|
3056
|
+
} break;
|
3057
|
+
case CURLOPT_USERPWD: {
|
3058
|
+
VALUE userpwd = val;
|
3059
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, userpwd);
|
3060
|
+
} break;
|
3061
|
+
case CURLOPT_PROXYUSERPWD: {
|
3062
|
+
VALUE proxypwd = val;
|
3063
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, proxypwd);
|
3064
|
+
} break;
|
3065
|
+
case CURLOPT_COOKIE: {
|
3066
|
+
VALUE cookies = val;
|
3067
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, cookies);
|
3068
|
+
} break;
|
3069
|
+
case CURLOPT_COOKIEFILE: {
|
3070
|
+
VALUE cookiefile = val;
|
3071
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, cookiefile);
|
3072
|
+
} break;
|
3073
|
+
case CURLOPT_COOKIEJAR: {
|
3074
|
+
VALUE cookiejar = val;
|
3075
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, cookiejar);
|
3076
|
+
} break;
|
3077
|
+
|
3078
|
+
default:
|
3079
|
+
break;
|
3080
|
+
}
|
3081
|
+
|
3082
|
+
return val;
|
3083
|
+
}
|
3084
|
+
|
3085
|
+
/*
|
3086
|
+
* call-seq:
|
3087
|
+
* easy.getinfo Fixnum => value
|
3088
|
+
*
|
3089
|
+
* Iniital access to libcurl curl_easy_getinfo, remember getinfo doesn't return the same values as setopt
|
3090
|
+
*/
|
3091
|
+
static VALUE ruby_curl_easy_get_opt(VALUE self, VALUE opt) {
|
3092
|
+
return Qnil;
|
3093
|
+
}
|
3094
|
+
|
3102
3095
|
/*
|
3103
3096
|
* call-seq:
|
3104
3097
|
* easy.inspect => "#<Curl::Easy http://google.com/>"
|
@@ -3189,114 +3182,14 @@ static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
|
|
3189
3182
|
|
3190
3183
|
/*
|
3191
3184
|
* call-seq:
|
3192
|
-
* Curl::Easy.
|
3193
|
-
*
|
3194
|
-
* Convenience method that creates a new Curl::Easy instance with
|
3195
|
-
* the specified URL and calls the general +perform+ method, before returning
|
3196
|
-
* the new instance. For HTTP URLs, this is equivalent to calling +http_get+.
|
3185
|
+
* Curl::Easy.error(code) => String
|
3197
3186
|
*
|
3198
|
-
*
|
3199
|
-
* the +http_get+ call.
|
3187
|
+
* translate an internal libcurl error to ruby error class
|
3200
3188
|
*/
|
3201
|
-
static VALUE
|
3202
|
-
|
3203
|
-
|
3204
|
-
if (rb_block_given_p()) {
|
3205
|
-
rb_yield(c);
|
3206
|
-
}
|
3207
|
-
|
3208
|
-
ruby_curl_easy_perform(c);
|
3209
|
-
return c;
|
3210
|
-
}
|
3211
|
-
|
3212
|
-
/*
|
3213
|
-
* call-seq:
|
3214
|
-
* Curl::Easy.http_get(url) { |easy| ... } => #<Curl::Easy...>
|
3215
|
-
*
|
3216
|
-
* Convenience method that creates a new Curl::Easy instance with
|
3217
|
-
* the specified URL and calls +http_get+, before returning the new instance.
|
3218
|
-
*
|
3219
|
-
* If a block is supplied, the new instance will be yielded just prior to
|
3220
|
-
* the +http_get+ call.
|
3221
|
-
*/
|
3222
|
-
static VALUE ruby_curl_easy_class_perform_get(int argc, VALUE *argv, VALUE klass) {
|
3223
|
-
VALUE c = ruby_curl_easy_new(argc, argv, klass);
|
3224
|
-
|
3225
|
-
ruby_curl_easy_perform_get(c);
|
3226
|
-
return c;
|
3227
|
-
}
|
3228
|
-
|
3229
|
-
/*
|
3230
|
-
* call-seq:
|
3231
|
-
* Curl::Easy.http_delete(url) { |easy| ... } => #<Curl::Easy...>
|
3232
|
-
*
|
3233
|
-
* Convenience method that creates a new Curl::Easy instance with
|
3234
|
-
* the specified URL and calls +http_delete+, before returning the new instance.
|
3235
|
-
*
|
3236
|
-
* If a block is supplied, the new instance will be yielded just prior to
|
3237
|
-
* the +http_delete+ call.
|
3238
|
-
*/
|
3239
|
-
static VALUE ruby_curl_easy_class_perform_delete(int argc, VALUE *argv, VALUE klass) {
|
3240
|
-
VALUE c = ruby_curl_easy_new(argc, argv, klass);
|
3241
|
-
|
3242
|
-
ruby_curl_easy_perform_delete(c);
|
3243
|
-
return c;
|
3189
|
+
static VALUE ruby_curl_easy_error_message(VALUE klass, VALUE code) {
|
3190
|
+
return rb_curl_easy_error(FIX2INT(code));
|
3244
3191
|
}
|
3245
3192
|
|
3246
|
-
/*
|
3247
|
-
* call-seq:
|
3248
|
-
* Curl::Easy.http_head(url) { |easy| ... } => #<Curl::Easy...>
|
3249
|
-
*
|
3250
|
-
* Convenience method that creates a new Curl::Easy instance with
|
3251
|
-
* the specified URL and calls +http_head+, before returning the new instance.
|
3252
|
-
*
|
3253
|
-
* If a block is supplied, the new instance will be yielded just prior to
|
3254
|
-
* the +http_head+ call.
|
3255
|
-
*/
|
3256
|
-
static VALUE ruby_curl_easy_class_perform_head(int argc, VALUE *argv, VALUE klass) {
|
3257
|
-
VALUE c = ruby_curl_easy_new(argc, argv, klass);
|
3258
|
-
|
3259
|
-
ruby_curl_easy_perform_head(c);
|
3260
|
-
|
3261
|
-
return c;
|
3262
|
-
}
|
3263
|
-
|
3264
|
-
// TODO: add convenience method for http_post
|
3265
|
-
|
3266
|
-
/*
|
3267
|
-
* call-seq:
|
3268
|
-
* Curl::Easy.http_post(url, "some=urlencoded%20form%20data&and=so%20on") => true
|
3269
|
-
* Curl::Easy.http_post(url, "some=urlencoded%20form%20data", "and=so%20on", ...) => true
|
3270
|
-
* Curl::Easy.http_post(url, "some=urlencoded%20form%20data", Curl::PostField, "and=so%20on", ...) => true
|
3271
|
-
* Curl::Easy.http_post(url, Curl::PostField, Curl::PostField ..., Curl::PostField) => true
|
3272
|
-
*
|
3273
|
-
* POST the specified formdata to the currently configured URL using
|
3274
|
-
* the current options set for this Curl::Easy instance. This method
|
3275
|
-
* always returns true, or raises an exception (defined under
|
3276
|
-
* Curl::Err) on error.
|
3277
|
-
*
|
3278
|
-
* If you wish to use multipart form encoding, you'll need to supply a block
|
3279
|
-
* in order to set multipart_form_post true. See #http_post for more
|
3280
|
-
* information.
|
3281
|
-
*/
|
3282
|
-
static VALUE ruby_curl_easy_class_perform_post(int argc, VALUE *argv, VALUE klass) {
|
3283
|
-
VALUE url, fields;
|
3284
|
-
VALUE c;
|
3285
|
-
|
3286
|
-
rb_scan_args(argc, argv, "1*", &url, &fields);
|
3287
|
-
|
3288
|
-
c = ruby_curl_easy_new(1, &url, klass);
|
3289
|
-
|
3290
|
-
if (argc > 1) {
|
3291
|
-
ruby_curl_easy_perform_post(argc - 1, &argv[1], c);
|
3292
|
-
} else {
|
3293
|
-
ruby_curl_easy_perform_post(0, NULL, c);
|
3294
|
-
}
|
3295
|
-
|
3296
|
-
return c;
|
3297
|
-
}
|
3298
|
-
|
3299
|
-
|
3300
3193
|
/* =================== INIT LIB =====================*/
|
3301
3194
|
void init_curb_easy() {
|
3302
3195
|
idCall = rb_intern("call");
|
@@ -3309,31 +3202,18 @@ void init_curb_easy() {
|
|
3309
3202
|
|
3310
3203
|
/* Class methods */
|
3311
3204
|
rb_define_singleton_method(cCurlEasy, "new", ruby_curl_easy_new, -1);
|
3312
|
-
rb_define_singleton_method(cCurlEasy, "
|
3313
|
-
rb_define_singleton_method(cCurlEasy, "http_delete", ruby_curl_easy_class_perform_delete, -1);
|
3314
|
-
rb_define_singleton_method(cCurlEasy, "http_get", ruby_curl_easy_class_perform_get, -1);
|
3315
|
-
rb_define_singleton_method(cCurlEasy, "http_post", ruby_curl_easy_class_perform_post, -1);
|
3316
|
-
rb_define_singleton_method(cCurlEasy, "http_head", ruby_curl_easy_class_perform_head, -1);
|
3317
|
-
rb_define_singleton_method(cCurlEasy, "http_put", ruby_curl_easy_class_perform_put, 2);
|
3205
|
+
rb_define_singleton_method(cCurlEasy, "error", ruby_curl_easy_error_message, 1);
|
3318
3206
|
|
3319
3207
|
/* Attributes for config next perform */
|
3320
|
-
rb_define_method(cCurlEasy, "url=", ruby_curl_easy_url_set, 1);
|
3321
3208
|
rb_define_method(cCurlEasy, "url", ruby_curl_easy_url_get, 0);
|
3322
|
-
rb_define_method(cCurlEasy, "proxy_url=", ruby_curl_easy_proxy_url_set, 1);
|
3323
3209
|
rb_define_method(cCurlEasy, "proxy_url", ruby_curl_easy_proxy_url_get, 0);
|
3324
3210
|
rb_define_method(cCurlEasy, "headers=", ruby_curl_easy_headers_set, 1);
|
3325
3211
|
rb_define_method(cCurlEasy, "headers", ruby_curl_easy_headers_get, 0);
|
3326
|
-
rb_define_method(cCurlEasy, "interface=", ruby_curl_easy_interface_set, 1);
|
3327
3212
|
rb_define_method(cCurlEasy, "interface", ruby_curl_easy_interface_get, 0);
|
3328
|
-
rb_define_method(cCurlEasy, "userpwd=", ruby_curl_easy_userpwd_set, 1);
|
3329
3213
|
rb_define_method(cCurlEasy, "userpwd", ruby_curl_easy_userpwd_get, 0);
|
3330
|
-
rb_define_method(cCurlEasy, "proxypwd=", ruby_curl_easy_proxypwd_set, 1);
|
3331
3214
|
rb_define_method(cCurlEasy, "proxypwd", ruby_curl_easy_proxypwd_get, 0);
|
3332
|
-
rb_define_method(cCurlEasy, "cookies=", ruby_curl_easy_cookies_set, 1);
|
3333
3215
|
rb_define_method(cCurlEasy, "cookies", ruby_curl_easy_cookies_get, 0);
|
3334
|
-
rb_define_method(cCurlEasy, "cookiefile=", ruby_curl_easy_cookiefile_set, 1);
|
3335
3216
|
rb_define_method(cCurlEasy, "cookiefile", ruby_curl_easy_cookiefile_get, 0);
|
3336
|
-
rb_define_method(cCurlEasy, "cookiejar=", ruby_curl_easy_cookiejar_set, 1);
|
3337
3217
|
rb_define_method(cCurlEasy, "cookiejar", ruby_curl_easy_cookiejar_get, 0);
|
3338
3218
|
rb_define_method(cCurlEasy, "cert=", ruby_curl_easy_cert_set, 1);
|
3339
3219
|
rb_define_method(cCurlEasy, "cert", ruby_curl_easy_cert_get, 0);
|
@@ -3398,8 +3278,8 @@ void init_curb_easy() {
|
|
3398
3278
|
rb_define_method(cCurlEasy, "fetch_file_time?", ruby_curl_easy_fetch_file_time_q, 0);
|
3399
3279
|
rb_define_method(cCurlEasy, "ssl_verify_peer=", ruby_curl_easy_ssl_verify_peer_set, 1);
|
3400
3280
|
rb_define_method(cCurlEasy, "ssl_verify_peer?", ruby_curl_easy_ssl_verify_peer_q, 0);
|
3401
|
-
rb_define_method(cCurlEasy, "
|
3402
|
-
rb_define_method(cCurlEasy, "ssl_verify_host
|
3281
|
+
rb_define_method(cCurlEasy, "ssl_verify_host_integer=", ruby_curl_easy_ssl_verify_host_set, 1);
|
3282
|
+
rb_define_method(cCurlEasy, "ssl_verify_host", ruby_curl_easy_ssl_verify_host_get, 0);
|
3403
3283
|
rb_define_method(cCurlEasy, "header_in_body=", ruby_curl_easy_header_in_body_set, 1);
|
3404
3284
|
rb_define_method(cCurlEasy, "header_in_body?", ruby_curl_easy_header_in_body_q, 0);
|
3405
3285
|
rb_define_method(cCurlEasy, "use_netrc=", ruby_curl_easy_use_netrc_set, 1);
|
@@ -3417,6 +3297,8 @@ void init_curb_easy() {
|
|
3417
3297
|
rb_define_method(cCurlEasy, "enable_cookies?", ruby_curl_easy_enable_cookies_q, 0);
|
3418
3298
|
rb_define_method(cCurlEasy, "ignore_content_length=", ruby_curl_easy_ignore_content_length_set, 1);
|
3419
3299
|
rb_define_method(cCurlEasy, "ignore_content_length?", ruby_curl_easy_ignore_content_length_q, 0);
|
3300
|
+
rb_define_method(cCurlEasy, "resolve_mode", ruby_curl_easy_resolve_mode, 0);
|
3301
|
+
rb_define_method(cCurlEasy, "resolve_mode=", ruby_curl_easy_resolve_mode_set, 1);
|
3420
3302
|
|
3421
3303
|
rb_define_method(cCurlEasy, "on_body", ruby_curl_easy_on_body_set, -1);
|
3422
3304
|
rb_define_method(cCurlEasy, "on_header", ruby_curl_easy_on_header_set, -1);
|
@@ -3426,7 +3308,6 @@ void init_curb_easy() {
|
|
3426
3308
|
rb_define_method(cCurlEasy, "on_failure", ruby_curl_easy_on_failure_set, -1);
|
3427
3309
|
rb_define_method(cCurlEasy, "on_complete", ruby_curl_easy_on_complete_set, -1);
|
3428
3310
|
|
3429
|
-
rb_define_method(cCurlEasy, "perform", ruby_curl_easy_perform, 0);
|
3430
3311
|
rb_define_method(cCurlEasy, "http", ruby_curl_easy_perform_verb, 1);
|
3431
3312
|
rb_define_method(cCurlEasy, "http_delete", ruby_curl_easy_perform_delete, 0);
|
3432
3313
|
rb_define_method(cCurlEasy, "http_get", ruby_curl_easy_perform_get, 0);
|
@@ -3434,12 +3315,6 @@ void init_curb_easy() {
|
|
3434
3315
|
rb_define_method(cCurlEasy, "http_head", ruby_curl_easy_perform_head, 0);
|
3435
3316
|
rb_define_method(cCurlEasy, "http_put", ruby_curl_easy_perform_put, 1);
|
3436
3317
|
rb_define_method(cCurlEasy, "head=", ruby_curl_easy_set_head_option, 1);
|
3437
|
-
rb_define_method(cCurlEasy, "delete=", ruby_curl_easy_set_delete_option, 1);
|
3438
|
-
rb_define_method(cCurlEasy, "version=", ruby_curl_easy_set_version, 1);
|
3439
|
-
rb_define_const(mCurl, "HTTP_1_1", LONG2NUM(CURL_HTTP_VERSION_1_1));
|
3440
|
-
rb_define_const(mCurl, "HTTP_1_0", LONG2NUM(CURL_HTTP_VERSION_1_0));
|
3441
|
-
rb_define_const(mCurl, "HTTP_NONE", LONG2NUM(CURL_HTTP_VERSION_NONE));
|
3442
|
-
rb_define_method(cCurlEasy, "nosignal=", ruby_curl_easy_set_nosignal, 1);
|
3443
3318
|
|
3444
3319
|
/* Post-perform info methods */
|
3445
3320
|
rb_define_method(cCurlEasy, "body_str", ruby_curl_easy_body_str_get, 0);
|
@@ -3484,4 +3359,11 @@ void init_curb_easy() {
|
|
3484
3359
|
rb_define_method(cCurlEasy, "clone", ruby_curl_easy_clone, 0);
|
3485
3360
|
rb_define_alias(cCurlEasy, "dup", "clone");
|
3486
3361
|
rb_define_method(cCurlEasy, "inspect", ruby_curl_easy_inspect, 0);
|
3362
|
+
|
3363
|
+
rb_define_method(cCurlEasy, "multi", ruby_curl_easy_multi_get, 0);
|
3364
|
+
rb_define_method(cCurlEasy, "multi=", ruby_curl_easy_multi_set, 1);
|
3365
|
+
rb_define_method(cCurlEasy, "last_result", ruby_curl_easy_last_result, 0);
|
3366
|
+
|
3367
|
+
rb_define_method(cCurlEasy, "setopt", ruby_curl_easy_set_opt, 2);
|
3368
|
+
rb_define_method(cCurlEasy, "getinfo", ruby_curl_easy_get_opt, 1);
|
3487
3369
|
}
|