curb 0.8.5 → 1.3.6
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 +7 -0
- data/README.md +579 -0
- data/Rakefile +85 -27
- data/doc.rb +48 -8
- data/ext/banned.h +32 -0
- data/ext/curb.c +563 -233
- data/ext/curb.h +19 -10
- data/ext/curb_easy.c +3229 -368
- data/ext/curb_easy.h +42 -0
- data/ext/curb_errors.c +117 -18
- data/ext/curb_errors.h +9 -5
- data/ext/curb_macros.h +33 -21
- data/ext/curb_multi.c +1904 -272
- data/ext/curb_multi.h +11 -3
- data/ext/curb_postfield.c +149 -77
- data/ext/curb_postfield.h +1 -0
- data/ext/curb_upload.c +38 -11
- data/ext/curb_upload.h +2 -0
- data/ext/extconf.rb +355 -35
- data/lib/curb.rb +1 -0
- data/lib/curl/download.rb +160 -0
- data/lib/curl/easy.rb +422 -88
- data/lib/curl/multi.rb +295 -56
- data/lib/curl.rb +676 -11
- data/tests/bug_crash_on_debug.rb +14 -28
- data/tests/bug_crash_on_progress.rb +32 -16
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +10 -15
- data/tests/bug_curb_easy_post_with_string_no_content_length_header.rb +6 -30
- data/tests/bug_follow_redirect_288.rb +83 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +3 -5
- data/tests/bug_issue102.rb +17 -0
- data/tests/bug_issue_noproxy.rb +56 -0
- data/tests/bug_issue_post_redirect.rb +93 -0
- data/tests/bug_issue_spnego.rb +41 -0
- data/tests/bug_multi_segfault.rb +1 -0
- data/tests/bug_poison.rb +29 -0
- data/tests/bug_raise_on_callback.rb +30 -0
- data/tests/helper.rb +400 -44
- data/tests/leak_trace.rb +237 -0
- data/tests/mem_check.rb +3 -0
- data/tests/tc_curl.rb +31 -1
- data/tests/tc_curl_download.rb +98 -7
- data/tests/tc_curl_easy.rb +985 -66
- data/tests/tc_curl_easy_cookielist.rb +277 -0
- data/tests/tc_curl_easy_request_target.rb +41 -0
- data/tests/tc_curl_easy_resolve.rb +48 -0
- data/tests/tc_curl_maxfilesize.rb +212 -0
- data/tests/tc_curl_multi.rb +1111 -51
- data/tests/tc_curl_native_coverage.rb +145 -0
- data/tests/tc_curl_network_policy.rb +1475 -0
- data/tests/tc_curl_postfield.rb +207 -30
- data/tests/tc_curl_protocols.rb +388 -0
- data/tests/tc_fiber_scheduler.rb +584 -0
- data/tests/tc_ftp_options.rb +39 -0
- data/tests/tc_gc_compact.rb +223 -0
- data/tests/tc_test_server_methods.rb +110 -0
- data/tests/timeout.rb +30 -6
- metadata +66 -31
- data/README +0 -194
data/ext/curb_easy.h
CHANGED
|
@@ -11,6 +11,18 @@
|
|
|
11
11
|
|
|
12
12
|
#include <curl/easy.h>
|
|
13
13
|
|
|
14
|
+
#define CURB_NETWORK_POLICY_NONE 0
|
|
15
|
+
#define CURB_NETWORK_POLICY_PUBLIC 1
|
|
16
|
+
|
|
17
|
+
#define CURB_CIDR_FAMILY_IPV4 4
|
|
18
|
+
#define CURB_CIDR_FAMILY_IPV6 6
|
|
19
|
+
|
|
20
|
+
typedef struct {
|
|
21
|
+
unsigned char family;
|
|
22
|
+
unsigned char prefix_bits;
|
|
23
|
+
unsigned char address[16];
|
|
24
|
+
} curb_cidr_rule;
|
|
25
|
+
|
|
14
26
|
#ifdef CURL_VERSION_SSL
|
|
15
27
|
#if LIBCURL_VERSION_NUM >= 0x070b00
|
|
16
28
|
# if LIBCURL_VERSION_NUM <= 0x071004
|
|
@@ -36,8 +48,14 @@ typedef struct {
|
|
|
36
48
|
/* The handler */
|
|
37
49
|
CURL *curl;
|
|
38
50
|
|
|
51
|
+
/* Buffer for error details from CURLOPT_ERRORBUFFER */
|
|
52
|
+
char err_buf[CURL_ERROR_SIZE];
|
|
53
|
+
char unsafe_destination_error[CURL_ERROR_SIZE];
|
|
54
|
+
|
|
55
|
+
VALUE self; /* owning Ruby object */
|
|
39
56
|
VALUE opts; /* rather then allocate everything we might need to store, allocate a Hash and only store objects we actually use... */
|
|
40
57
|
VALUE multi; /* keep a multi handle alive for each easy handle not being used by a multi handle. This improves easy performance when not within a multi context */
|
|
58
|
+
VALUE callback_error; /* preserves body/header callback exceptions without mutating the Ruby object */
|
|
41
59
|
|
|
42
60
|
/* Other opts */
|
|
43
61
|
unsigned short local_port; // 0 is no port
|
|
@@ -48,15 +66,21 @@ typedef struct {
|
|
|
48
66
|
long proxy_auth_types;
|
|
49
67
|
long max_redirs;
|
|
50
68
|
unsigned long timeout;
|
|
69
|
+
unsigned long timeout_ms;
|
|
51
70
|
unsigned long connect_timeout;
|
|
71
|
+
unsigned long connect_timeout_ms;
|
|
52
72
|
long dns_cache_timeout;
|
|
53
73
|
unsigned long ftp_response_timeout;
|
|
54
74
|
long low_speed_limit;
|
|
55
75
|
long low_speed_time;
|
|
76
|
+
long max_send_speed_large;
|
|
77
|
+
long max_recv_speed_large;
|
|
56
78
|
long ssl_version;
|
|
57
79
|
long use_ssl;
|
|
58
80
|
long ftp_filemethod;
|
|
81
|
+
long http_version;
|
|
59
82
|
unsigned short resolve_mode;
|
|
83
|
+
unsigned short network_policy;
|
|
60
84
|
|
|
61
85
|
/* bool flags */
|
|
62
86
|
char proxy_tunnel;
|
|
@@ -70,20 +94,38 @@ typedef struct {
|
|
|
70
94
|
char verbose;
|
|
71
95
|
char multipart_form_post;
|
|
72
96
|
char enable_cookies;
|
|
97
|
+
char cookielist_engine_enabled; /* track if CURLOPT_COOKIELIST was used with a non-command to enable engine */
|
|
73
98
|
char ignore_content_length;
|
|
74
99
|
char callback_active;
|
|
100
|
+
char unsafe_destination_blocked;
|
|
101
|
+
char allow_proxy;
|
|
102
|
+
char allow_unix_socket;
|
|
103
|
+
char forbid_reuse_set;
|
|
104
|
+
unsigned int native_active;
|
|
105
|
+
long forbid_reuse;
|
|
75
106
|
|
|
76
107
|
struct curl_slist *curl_headers;
|
|
108
|
+
struct curl_slist *curl_proxy_headers;
|
|
77
109
|
struct curl_slist *curl_ftp_commands;
|
|
110
|
+
struct curl_slist *curl_resolve;
|
|
111
|
+
struct curl_slist *curl_connect_to;
|
|
112
|
+
curb_cidr_rule *network_allowed_cidr_rules;
|
|
113
|
+
char **network_allowed_hosts;
|
|
78
114
|
|
|
115
|
+
unsigned long multi_attachment_generation;
|
|
116
|
+
curl_off_t downloaded_body_bytes;
|
|
117
|
+
size_t network_allowed_cidr_rule_count;
|
|
118
|
+
size_t network_allowed_host_count;
|
|
79
119
|
int last_result; /* last result code from multi loop */
|
|
80
120
|
|
|
81
121
|
} ruby_curl_easy;
|
|
82
122
|
|
|
83
123
|
extern VALUE cCurlEasy;
|
|
124
|
+
extern const rb_data_type_t ruby_curl_easy_data_type;
|
|
84
125
|
|
|
85
126
|
VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce);
|
|
86
127
|
VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce);
|
|
128
|
+
VALUE rb_curl_easy_take_callback_error(ruby_curl_easy *rbce);
|
|
87
129
|
|
|
88
130
|
void init_curb_easy();
|
|
89
131
|
|
data/ext/curb_errors.c
CHANGED
|
@@ -21,6 +21,7 @@ VALUE eCurlErrFileError;
|
|
|
21
21
|
VALUE eCurlErrLDAPError;
|
|
22
22
|
VALUE eCurlErrTelnetError;
|
|
23
23
|
VALUE eCurlErrTFTPError;
|
|
24
|
+
VALUE eCurlErrRTSPError;
|
|
24
25
|
|
|
25
26
|
/* Specific libcurl errors */
|
|
26
27
|
VALUE eCurlErrOK; /* not really an error but a return code */
|
|
@@ -32,13 +33,13 @@ VALUE eCurlErrNotBuiltIn;
|
|
|
32
33
|
VALUE eCurlErrProxyResolution;
|
|
33
34
|
VALUE eCurlErrHostResolution;
|
|
34
35
|
VALUE eCurlErrConnectFailed;
|
|
35
|
-
VALUE
|
|
36
|
+
VALUE eCurlErrFTPWeirdReply;
|
|
36
37
|
VALUE eCurlErrFTPAccessDenied;
|
|
37
38
|
VALUE eCurlErrFTPBadPassword;
|
|
38
|
-
VALUE
|
|
39
|
-
VALUE
|
|
40
|
-
VALUE
|
|
41
|
-
VALUE
|
|
39
|
+
VALUE eCurlErrFTPWeirdPassReply;
|
|
40
|
+
VALUE eCurlErrFTPWeirdUserReply;
|
|
41
|
+
VALUE eCurlErrFTPWeirdPasvReply;
|
|
42
|
+
VALUE eCurlErrFTPWeird227Format;
|
|
42
43
|
VALUE eCurlErrFTPCantGetHost;
|
|
43
44
|
VALUE eCurlErrFTPCantReconnect;
|
|
44
45
|
VALUE eCurlErrFTPCouldntSetBinary;
|
|
@@ -109,6 +110,7 @@ VALUE eCurlErrSSLShutdownFailed;
|
|
|
109
110
|
VALUE eCurlErrAgain;
|
|
110
111
|
VALUE eCurlErrSSLCRLBadfile;
|
|
111
112
|
VALUE eCurlErrSSLIssuerError;
|
|
113
|
+
VALUE eCurlErrUnsafeDestination;
|
|
112
114
|
|
|
113
115
|
/* multi errors */
|
|
114
116
|
VALUE mCurlErrFailedInit;
|
|
@@ -118,12 +120,27 @@ VALUE mCurlErrBadEasyHandle;
|
|
|
118
120
|
VALUE mCurlErrOutOfMemory;
|
|
119
121
|
VALUE mCurlErrInternalError;
|
|
120
122
|
VALUE mCurlErrBadSocket;
|
|
123
|
+
#ifdef HAVE_CURLM_ADDED_ALREADY
|
|
124
|
+
VALUE mCurlErrAddedAlready;
|
|
125
|
+
#endif
|
|
121
126
|
VALUE mCurlErrUnknownOption;
|
|
122
127
|
|
|
123
128
|
/* binding errors */
|
|
124
129
|
VALUE eCurlErrInvalidPostField;
|
|
125
130
|
|
|
126
131
|
|
|
132
|
+
/* new errors */
|
|
133
|
+
VALUE eCurlErrFTPPRETFailed;
|
|
134
|
+
VALUE eCurlErrRTSPCseqError;
|
|
135
|
+
VALUE eCurlErrRTSPSessionError;
|
|
136
|
+
VALUE eCurlErrFTPBadFileList;
|
|
137
|
+
VALUE eCurlErrChunkFailed;
|
|
138
|
+
VALUE eCurlErrNoConnectionAvailable;
|
|
139
|
+
VALUE eCurlErrSSLPinnedPubKeyNotMatch;
|
|
140
|
+
VALUE eCurlErrSSLInvalidCertStatus;
|
|
141
|
+
VALUE eCurlErrHTTP2Stream;
|
|
142
|
+
|
|
143
|
+
|
|
127
144
|
VALUE rb_curl_easy_error(CURLcode code) {
|
|
128
145
|
VALUE exclz;
|
|
129
146
|
const char *exmsg = NULL;
|
|
@@ -161,7 +178,7 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
161
178
|
exclz = eCurlErrConnectFailed;
|
|
162
179
|
break;
|
|
163
180
|
case CURLE_FTP_WEIRD_SERVER_REPLY: /* 8 */
|
|
164
|
-
exclz =
|
|
181
|
+
exclz = eCurlErrFTPWeirdReply;
|
|
165
182
|
break;
|
|
166
183
|
case CURLE_FTP_ACCESS_DENIED: /* 9 denied due to lack of access. */
|
|
167
184
|
exclz = eCurlErrFTPAccessDenied;
|
|
@@ -170,16 +187,16 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
170
187
|
exclz = eCurlErrFTPBadPassword;
|
|
171
188
|
break;
|
|
172
189
|
case CURLE_FTP_WEIRD_PASS_REPLY: /* 11 */
|
|
173
|
-
exclz =
|
|
190
|
+
exclz = eCurlErrFTPWeirdPassReply;
|
|
174
191
|
break;
|
|
175
192
|
case CURLE_FTP_WEIRD_USER_REPLY: /* 12 */
|
|
176
|
-
exclz =
|
|
193
|
+
exclz = eCurlErrFTPWeirdUserReply;
|
|
177
194
|
break;
|
|
178
195
|
case CURLE_FTP_WEIRD_PASV_REPLY: /* 13 */
|
|
179
|
-
exclz =
|
|
196
|
+
exclz = eCurlErrFTPWeirdPasvReply;
|
|
180
197
|
break;
|
|
181
198
|
case CURLE_FTP_WEIRD_227_FORMAT: /* 14 */
|
|
182
|
-
exclz =
|
|
199
|
+
exclz = eCurlErrFTPWeird227Format;
|
|
183
200
|
break;
|
|
184
201
|
case CURLE_FTP_CANT_GET_HOST: /* 15 */
|
|
185
202
|
exclz = eCurlErrFTPCantGetHost;
|
|
@@ -291,9 +308,11 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
291
308
|
exclz = eCurlErrObsolete;
|
|
292
309
|
break;
|
|
293
310
|
#endif
|
|
311
|
+
#if LIBCURL_VERSION_NUM < 0x073e00
|
|
294
312
|
case CURLE_SSL_PEER_CERTIFICATE: /* 51 - peer's certificate wasn't ok */
|
|
295
313
|
exclz = eCurlErrSSLPeerCertificate;
|
|
296
314
|
break;
|
|
315
|
+
#endif
|
|
297
316
|
case CURLE_GOT_NOTHING: /* 52 - when this is a specific error */
|
|
298
317
|
exclz = eCurlErrGotNothing;
|
|
299
318
|
break;
|
|
@@ -318,8 +337,13 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
318
337
|
case CURLE_SSL_CIPHER: /* 59 - couldn't use specified cipher */
|
|
319
338
|
exclz = eCurlErrSSLCipher;
|
|
320
339
|
break;
|
|
340
|
+
#if LIBCURL_VERSION_NUM >= 0x073e00
|
|
341
|
+
case CURLE_PEER_FAILED_VERIFICATION: /* 60 - problem with the CA cert (path?) */
|
|
342
|
+
exclz = eCurlErrSSLPeerCertificate;
|
|
343
|
+
#else
|
|
321
344
|
case CURLE_SSL_CACERT: /* 60 - problem with the CA cert (path?) */
|
|
322
345
|
exclz = eCurlErrSSLCACertificate;
|
|
346
|
+
#endif
|
|
323
347
|
break;
|
|
324
348
|
case CURLE_BAD_CONTENT_ENCODING: /* 61 - Unrecognized transfer encoding */
|
|
325
349
|
exclz = eCurlErrBadContentEncoding;
|
|
@@ -442,6 +466,61 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
442
466
|
exclz = eCurlErrSSLIssuerError;
|
|
443
467
|
break;
|
|
444
468
|
#endif
|
|
469
|
+
|
|
470
|
+
#ifdef HAVE_CURLE_FTP_PRET_FAILED
|
|
471
|
+
case CURLE_FTP_PRET_FAILED: /* 84 */
|
|
472
|
+
exclz = eCurlErrFTPPRETFailed;
|
|
473
|
+
break;
|
|
474
|
+
#endif
|
|
475
|
+
|
|
476
|
+
#ifdef HAVE_CURLE_RTSP_CSEQ_ERROR
|
|
477
|
+
case CURLE_RTSP_CSEQ_ERROR: /* 85 */
|
|
478
|
+
exclz = eCurlErrRTSPCseqError;
|
|
479
|
+
break;
|
|
480
|
+
#endif
|
|
481
|
+
|
|
482
|
+
#ifdef HAVE_CURLE_RTSP_SESSION_ERROR
|
|
483
|
+
case CURLE_RTSP_SESSION_ERROR: /* 86 */
|
|
484
|
+
exclz = eCurlErrRTSPSessionError;
|
|
485
|
+
break;
|
|
486
|
+
#endif
|
|
487
|
+
|
|
488
|
+
#ifdef HAVE_CURLE_FTP_BAD_FILE_LIST
|
|
489
|
+
case CURLE_FTP_BAD_FILE_LIST: /* 87 */
|
|
490
|
+
exclz = eCurlErrFTPBadFileList;
|
|
491
|
+
break;
|
|
492
|
+
#endif
|
|
493
|
+
|
|
494
|
+
#ifdef HAVE_CURLE_CHUNK_FAILED
|
|
495
|
+
case CURLE_CHUNK_FAILED: /* 88 */
|
|
496
|
+
exclz = eCurlErrChunkFailed;
|
|
497
|
+
break;
|
|
498
|
+
#endif
|
|
499
|
+
|
|
500
|
+
#ifdef HAVE_CURLE_NO_CONNECTION_AVAILABLE
|
|
501
|
+
case CURLE_NO_CONNECTION_AVAILABLE: /* 89 */
|
|
502
|
+
exclz = eCurlErrNoConnectionAvailable;
|
|
503
|
+
break;
|
|
504
|
+
#endif
|
|
505
|
+
|
|
506
|
+
#ifdef HAVE_CURLE_SSL_PINNEDPUBKEYNOTMATCH
|
|
507
|
+
case CURLE_SSL_PINNEDPUBKEYNOTMATCH: /* 90 */
|
|
508
|
+
exclz = eCurlErrSSLPinnedPubKeyNotMatch;
|
|
509
|
+
break;
|
|
510
|
+
#endif
|
|
511
|
+
|
|
512
|
+
#ifdef HAVE_CURLE_SSL_INVALIDCERTSTATUS
|
|
513
|
+
case CURLE_SSL_INVALIDCERTSTATUS: /* 91 */
|
|
514
|
+
exclz = eCurlErrSSLInvalidCertStatus;
|
|
515
|
+
break;
|
|
516
|
+
#endif
|
|
517
|
+
|
|
518
|
+
#ifdef HAVE_CURLE_HTTP2_STREAM
|
|
519
|
+
case CURLE_HTTP2_STREAM: /* 92 */
|
|
520
|
+
exclz = eCurlErrHTTP2Stream;
|
|
521
|
+
break;
|
|
522
|
+
#endif
|
|
523
|
+
|
|
445
524
|
default:
|
|
446
525
|
exclz = eCurlErrError;
|
|
447
526
|
exmsg = "Unknown error result from libcurl";
|
|
@@ -483,15 +562,20 @@ VALUE rb_curl_multi_error(CURLMcode code) {
|
|
|
483
562
|
case CURLM_INTERNAL_ERROR: /* 4 */
|
|
484
563
|
exclz = mCurlErrInternalError;
|
|
485
564
|
break;
|
|
486
|
-
#
|
|
565
|
+
#ifdef HAVE_CURLM_BAD_SOCKET
|
|
487
566
|
case CURLM_BAD_SOCKET: /* 5 */
|
|
488
567
|
exclz = mCurlErrBadSocket;
|
|
489
568
|
break;
|
|
490
569
|
#endif
|
|
491
|
-
#
|
|
570
|
+
#ifdef HAVE_CURLM_UNKNOWN_OPTION
|
|
492
571
|
case CURLM_UNKNOWN_OPTION: /* 6 */
|
|
493
572
|
exclz = mCurlErrUnknownOption;
|
|
494
573
|
break;
|
|
574
|
+
#endif
|
|
575
|
+
#ifdef HAVE_CURLM_ADDED_ALREADY
|
|
576
|
+
case CURLM_ADDED_ALREADY: /* 7 */
|
|
577
|
+
exclz = mCurlErrAddedAlready;
|
|
578
|
+
break;
|
|
495
579
|
#endif
|
|
496
580
|
default:
|
|
497
581
|
exclz = eCurlErrError;
|
|
@@ -524,6 +608,7 @@ void init_curb_errors() {
|
|
|
524
608
|
eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
|
|
525
609
|
eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
|
|
526
610
|
eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
|
|
611
|
+
eCurlErrRTSPError = rb_define_class_under(mCurlErr, "RTSPError", eCurlErrError);
|
|
527
612
|
|
|
528
613
|
eCurlErrOK = rb_define_class_under(mCurlErr, "CurlOK", eCurlErrError);
|
|
529
614
|
eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
|
|
@@ -535,13 +620,13 @@ void init_curb_errors() {
|
|
|
535
620
|
eCurlErrHostResolution = rb_define_class_under(mCurlErr, "HostResolutionError", eCurlErrError);
|
|
536
621
|
eCurlErrConnectFailed = rb_define_class_under(mCurlErr, "ConnectionFailedError", eCurlErrError);
|
|
537
622
|
|
|
538
|
-
|
|
623
|
+
eCurlErrFTPWeirdReply = rb_define_class_under(mCurlErr, "WeirdReplyError", eCurlErrFTPError);
|
|
539
624
|
eCurlErrFTPAccessDenied = rb_define_class_under(mCurlErr, "AccessDeniedError", eCurlErrFTPError);
|
|
540
|
-
eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
625
|
+
eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "BadPasswordError", eCurlErrFTPError);
|
|
626
|
+
eCurlErrFTPWeirdPassReply = rb_define_class_under(mCurlErr, "WeirdPassReplyError", eCurlErrFTPError);
|
|
627
|
+
eCurlErrFTPWeirdUserReply = rb_define_class_under(mCurlErr, "WeirdUserReplyError", eCurlErrFTPError);
|
|
628
|
+
eCurlErrFTPWeirdPasvReply = rb_define_class_under(mCurlErr, "WeirdPasvReplyError", eCurlErrFTPError);
|
|
629
|
+
eCurlErrFTPWeird227Format = rb_define_class_under(mCurlErr, "Weird227FormatError", eCurlErrFTPError);
|
|
545
630
|
eCurlErrFTPCantGetHost = rb_define_class_under(mCurlErr, "CantGetHostError", eCurlErrFTPError);
|
|
546
631
|
eCurlErrFTPCantReconnect = rb_define_class_under(mCurlErr, "CantReconnectError", eCurlErrFTPError);
|
|
547
632
|
eCurlErrFTPCouldntSetBinary = rb_define_class_under(mCurlErr, "CouldntSetBinaryError", eCurlErrFTPError);
|
|
@@ -615,6 +700,7 @@ void init_curb_errors() {
|
|
|
615
700
|
eCurlErrSSLCacertBadfile = rb_define_class_under(mCurlErr, "SSLCaertBadFile", eCurlErrError);
|
|
616
701
|
eCurlErrSSLCRLBadfile = rb_define_class_under(mCurlErr, "SSLCRLBadfile", eCurlErrError);
|
|
617
702
|
eCurlErrSSLIssuerError = rb_define_class_under(mCurlErr, "SSLIssuerError", eCurlErrError);
|
|
703
|
+
eCurlErrUnsafeDestination = rb_define_class_under(mCurlErr, "UnsafeDestinationError", eCurlErrError);
|
|
618
704
|
eCurlErrSSLShutdownFailed = rb_define_class_under(mCurlErr, "SSLShutdownFailed", eCurlErrError);
|
|
619
705
|
eCurlErrSSH = rb_define_class_under(mCurlErr, "SSH", eCurlErrError);
|
|
620
706
|
|
|
@@ -625,6 +711,9 @@ void init_curb_errors() {
|
|
|
625
711
|
mCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "MultiOutOfMemory", eCurlErrError);
|
|
626
712
|
mCurlErrInternalError = rb_define_class_under(mCurlErr, "MultiInternalError", eCurlErrError);
|
|
627
713
|
mCurlErrBadSocket = rb_define_class_under(mCurlErr, "MultiBadSocket", eCurlErrError);
|
|
714
|
+
#ifdef HAVE_CURLM_ADDED_ALREADY
|
|
715
|
+
mCurlErrAddedAlready = rb_define_class_under(mCurlErr, "MultiAddedAlready", eCurlErrError);
|
|
716
|
+
#endif
|
|
628
717
|
mCurlErrUnknownOption = rb_define_class_under(mCurlErr, "MultiUnknownOption", eCurlErrError);
|
|
629
718
|
|
|
630
719
|
eCurlErrLDAPInvalidURL = rb_define_class_under(mCurlErr, "InvalidLDAPURLError", eCurlErrLDAPError);
|
|
@@ -646,4 +735,14 @@ void init_curb_errors() {
|
|
|
646
735
|
eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);
|
|
647
736
|
|
|
648
737
|
eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError);
|
|
738
|
+
|
|
739
|
+
eCurlErrFTPPRETFailed = rb_define_class_under(mCurlErr, "PPRETFailedError", eCurlErrFTPError);
|
|
740
|
+
eCurlErrRTSPCseqError = rb_define_class_under(mCurlErr, "CseqError", eCurlErrRTSPError);
|
|
741
|
+
eCurlErrRTSPSessionError = rb_define_class_under(mCurlErr, "SessionError", eCurlErrRTSPError);
|
|
742
|
+
eCurlErrFTPBadFileList = rb_define_class_under(mCurlErr, "BadFileListError", eCurlErrFTPError);
|
|
743
|
+
eCurlErrChunkFailed = rb_define_class_under(mCurlErr, "ChunkFailedError", eCurlErrError);
|
|
744
|
+
eCurlErrNoConnectionAvailable = rb_define_class_under(mCurlErr, "NoConnectionAvailableError", eCurlErrError);
|
|
745
|
+
eCurlErrSSLPinnedPubKeyNotMatch = rb_define_class_under(mCurlErr, "SSLPinnedPubKeyNotMatchError", eCurlErrError);
|
|
746
|
+
eCurlErrSSLInvalidCertStatus = rb_define_class_under(mCurlErr, "SSLInvalidCertStatusError", eCurlErrError);
|
|
747
|
+
eCurlErrHTTP2Stream = rb_define_class_under(mCurlErr, "HTTP2StreamError", eCurlErrHTTPError);
|
|
649
748
|
}
|
data/ext/curb_errors.h
CHANGED
|
@@ -30,13 +30,13 @@ extern VALUE eCurlErrMalformedURLUser;
|
|
|
30
30
|
extern VALUE eCurlErrProxyResolution;
|
|
31
31
|
extern VALUE eCurlErrHostResolution;
|
|
32
32
|
extern VALUE eCurlErrConnectFailed;
|
|
33
|
-
extern VALUE
|
|
33
|
+
extern VALUE eCurlErrFTPWeirdReply;
|
|
34
34
|
extern VALUE eCurlErrFTPAccessDenied;
|
|
35
35
|
extern VALUE eCurlErrFTPBadPassword;
|
|
36
|
-
extern VALUE
|
|
37
|
-
extern VALUE
|
|
38
|
-
extern VALUE
|
|
39
|
-
extern VALUE
|
|
36
|
+
extern VALUE eCurlErrFTPWeirdPassReply;
|
|
37
|
+
extern VALUE eCurlErrFTPWeirdUserReply;
|
|
38
|
+
extern VALUE eCurlErrFTPWeirdPasvReply;
|
|
39
|
+
extern VALUE eCurlErrFTPWeird227Format;
|
|
40
40
|
extern VALUE eCurlErrFTPCantGetHost;
|
|
41
41
|
extern VALUE eCurlErrFTPCantReconnect;
|
|
42
42
|
extern VALUE eCurlErrFTPCouldntSetBinary;
|
|
@@ -106,6 +106,7 @@ extern VALUE eCurlErrSSLShutdownFailed;
|
|
|
106
106
|
extern VALUE eCurlErrAgain;
|
|
107
107
|
extern VALUE eCurlErrSSLCRLBadfile;
|
|
108
108
|
extern VALUE eCurlErrSSLIssuerError;
|
|
109
|
+
extern VALUE eCurlErrUnsafeDestination;
|
|
109
110
|
|
|
110
111
|
/* multi errors */
|
|
111
112
|
extern VALUE mCurlErrFailedInit;
|
|
@@ -116,6 +117,9 @@ extern VALUE mCurlErrOutOfMemory;
|
|
|
116
117
|
extern VALUE mCurlErrInternalError;
|
|
117
118
|
extern VALUE mCurlErrBadSocket;
|
|
118
119
|
extern VALUE mCurlErrUnknownOption;
|
|
120
|
+
#ifdef HAVE_CURLM_ADDED_ALREADY
|
|
121
|
+
extern VALUE mCurlErrAddedAlready;
|
|
122
|
+
#endif
|
|
119
123
|
|
|
120
124
|
/* binding errors */
|
|
121
125
|
extern VALUE eCurlErrInvalidPostField;
|
data/ext/curb_macros.h
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
#define CURB_OBJECT_SETTER(type, attr) \
|
|
26
26
|
type *ptr; \
|
|
27
27
|
\
|
|
28
|
-
|
|
28
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
29
29
|
ptr->attr = attr; \
|
|
30
30
|
\
|
|
31
31
|
return attr;
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
#define CURB_OBJECT_GETTER(type, attr) \
|
|
35
35
|
type *ptr; \
|
|
36
36
|
\
|
|
37
|
-
|
|
38
|
-
return ptr->attr;
|
|
37
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
38
|
+
return ptr->attr;
|
|
39
39
|
|
|
40
40
|
/* setter for anything that stores a ruby VALUE in the struct opts hash */
|
|
41
41
|
#define CURB_OBJECT_HSETTER(type, attr) \
|
|
42
42
|
type *ptr; \
|
|
43
43
|
\
|
|
44
|
-
|
|
44
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
45
45
|
rb_hash_aset(ptr->opts, rb_easy_hkey(#attr), attr); \
|
|
46
46
|
\
|
|
47
47
|
return attr;
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
#define CURB_OBJECT_HGETTER(type, attr) \
|
|
51
51
|
type *ptr; \
|
|
52
52
|
\
|
|
53
|
-
|
|
54
|
-
return rb_hash_aref(ptr->opts, rb_easy_hkey(#attr));
|
|
53
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
54
|
+
return rb_hash_aref(ptr->opts, rb_easy_hkey(#attr));
|
|
55
55
|
|
|
56
56
|
/* setter for bool flags */
|
|
57
57
|
#define CURB_BOOLEAN_SETTER(type, attr) \
|
|
58
58
|
type *ptr; \
|
|
59
|
-
|
|
59
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
60
60
|
\
|
|
61
61
|
if (attr == Qnil || attr == Qfalse) { \
|
|
62
62
|
ptr->attr = 0; \
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
/* getter for bool flags */
|
|
70
70
|
#define CURB_BOOLEAN_GETTER(type, attr) \
|
|
71
71
|
type *ptr; \
|
|
72
|
-
|
|
72
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
73
73
|
\
|
|
74
74
|
return((ptr->attr) ? Qtrue : Qfalse);
|
|
75
75
|
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
type *ptr; \
|
|
79
79
|
VALUE oldproc; \
|
|
80
80
|
\
|
|
81
|
-
|
|
81
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
82
82
|
\
|
|
83
83
|
oldproc = ptr->handler; \
|
|
84
84
|
rb_scan_args(argc, argv, "0&", &ptr->handler); \
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
type *ptr; \
|
|
91
91
|
VALUE oldproc, newproc; \
|
|
92
92
|
\
|
|
93
|
-
|
|
93
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
94
94
|
\
|
|
95
95
|
oldproc = rb_hash_aref(ptr->opts, rb_easy_hkey(#handler)); \
|
|
96
96
|
rb_scan_args(argc, argv, "0&", &newproc); \
|
|
@@ -99,39 +99,39 @@
|
|
|
99
99
|
\
|
|
100
100
|
return oldproc;
|
|
101
101
|
|
|
102
|
-
/* setter for numerics that are kept in c
|
|
102
|
+
/* setter for numerics that are kept in c longs */
|
|
103
103
|
#define CURB_IMMED_SETTER(type, attr, nilval) \
|
|
104
104
|
type *ptr; \
|
|
105
105
|
\
|
|
106
|
-
|
|
106
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
107
107
|
if (attr == Qnil) { \
|
|
108
108
|
ptr->attr = nilval; \
|
|
109
109
|
} else { \
|
|
110
|
-
ptr->attr =
|
|
110
|
+
ptr->attr = NUM2LONG(attr); \
|
|
111
111
|
} \
|
|
112
112
|
\
|
|
113
113
|
return attr; \
|
|
114
114
|
|
|
115
|
-
/* setter for numerics that are kept in c
|
|
115
|
+
/* setter for numerics that are kept in c longs */
|
|
116
116
|
#define CURB_IMMED_GETTER(type, attr, nilval) \
|
|
117
117
|
type *ptr; \
|
|
118
118
|
\
|
|
119
|
-
|
|
119
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
120
120
|
if (ptr->attr == nilval) { \
|
|
121
121
|
return Qnil; \
|
|
122
122
|
} else { \
|
|
123
|
-
return
|
|
123
|
+
return LONG2NUM(ptr->attr); \
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/* special setter for port / port ranges */
|
|
127
127
|
#define CURB_IMMED_PORT_SETTER(type, attr, msg) \
|
|
128
128
|
type *ptr; \
|
|
129
129
|
\
|
|
130
|
-
|
|
130
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
131
131
|
if (attr == Qnil) { \
|
|
132
132
|
ptr->attr = 0; \
|
|
133
133
|
} else { \
|
|
134
|
-
int port =
|
|
134
|
+
int port = NUM2INT(attr); \
|
|
135
135
|
\
|
|
136
136
|
if ((port) && ((port & 0xFFFF) == port)) { \
|
|
137
137
|
ptr->attr = port; \
|
|
@@ -146,14 +146,26 @@
|
|
|
146
146
|
#define CURB_IMMED_PORT_GETTER(type, attr) \
|
|
147
147
|
type *ptr; \
|
|
148
148
|
\
|
|
149
|
-
|
|
149
|
+
TypedData_Get_Struct(self, type, &type##_data_type, ptr); \
|
|
150
150
|
if (ptr->attr == 0) { \
|
|
151
151
|
return Qnil; \
|
|
152
152
|
} else { \
|
|
153
|
-
return
|
|
153
|
+
return INT2NUM(ptr->attr); \
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
#define CURB_DEFINE(name) \
|
|
157
|
-
rb_define_const(mCurl, #name,
|
|
157
|
+
rb_define_const(mCurl, #name, LONG2NUM(name))
|
|
158
|
+
|
|
159
|
+
/* copy and raise exception */
|
|
160
|
+
#define CURB_CHECK_RB_CALLBACK_RAISE(did_raise) \
|
|
161
|
+
VALUE exception = rb_hash_aref(did_raise, rb_easy_hkey("error")); \
|
|
162
|
+
if (FIX2INT(rb_hash_size(did_raise)) > 0 && exception != Qnil) { \
|
|
163
|
+
rb_hash_clear(did_raise); \
|
|
164
|
+
VALUE message = rb_funcall(exception, rb_intern("message"), 0); \
|
|
165
|
+
VALUE aborted_exception = rb_exc_new_str(eCurlErrAbortedByCallback, message); \
|
|
166
|
+
VALUE backtrace = rb_funcall(exception, rb_intern("backtrace"), 0); \
|
|
167
|
+
rb_funcall(aborted_exception, rb_intern("set_backtrace"), 1, backtrace); \
|
|
168
|
+
rb_exc_raise(aborted_exception); \
|
|
169
|
+
}
|
|
158
170
|
|
|
159
171
|
#endif
|