curb 0.8.4 → 1.3.5
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 +522 -0
- data/Rakefile +79 -26
- data/ext/banned.h +32 -0
- data/ext/curb.c +549 -230
- data/ext/curb.h +19 -10
- data/ext/curb_easy.c +1935 -366
- data/ext/curb_easy.h +16 -0
- data/ext/curb_errors.c +115 -18
- data/ext/curb_errors.h +8 -5
- data/ext/curb_macros.h +33 -21
- data/ext/curb_multi.c +1858 -272
- data/ext/curb_multi.h +10 -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 +353 -35
- data/lib/curb.rb +1 -0
- data/lib/curl/easy.rb +314 -78
- data/lib/curl/multi.rb +134 -28
- data/lib/curl.rb +217 -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 +1 -1
- 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_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 +12 -7
- data/tests/tc_curl_easy.rb +911 -63
- 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 +12 -0
- data/tests/tc_curl_multi.rb +855 -53
- data/tests/tc_curl_native_coverage.rb +145 -0
- data/tests/tc_curl_postfield.rb +207 -30
- data/tests/tc_curl_protocols.rb +37 -0
- data/tests/tc_fiber_scheduler.rb +543 -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 +59 -36
- data/README +0 -194
data/ext/curb_easy.h
CHANGED
|
@@ -36,8 +36,13 @@ typedef struct {
|
|
|
36
36
|
/* The handler */
|
|
37
37
|
CURL *curl;
|
|
38
38
|
|
|
39
|
+
/* Buffer for error details from CURLOPT_ERRORBUFFER */
|
|
40
|
+
char err_buf[CURL_ERROR_SIZE];
|
|
41
|
+
|
|
42
|
+
VALUE self; /* owning Ruby object */
|
|
39
43
|
VALUE opts; /* rather then allocate everything we might need to store, allocate a Hash and only store objects we actually use... */
|
|
40
44
|
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 */
|
|
45
|
+
VALUE callback_error; /* preserves body/header callback exceptions without mutating the Ruby object */
|
|
41
46
|
|
|
42
47
|
/* Other opts */
|
|
43
48
|
unsigned short local_port; // 0 is no port
|
|
@@ -48,14 +53,19 @@ typedef struct {
|
|
|
48
53
|
long proxy_auth_types;
|
|
49
54
|
long max_redirs;
|
|
50
55
|
unsigned long timeout;
|
|
56
|
+
unsigned long timeout_ms;
|
|
51
57
|
unsigned long connect_timeout;
|
|
58
|
+
unsigned long connect_timeout_ms;
|
|
52
59
|
long dns_cache_timeout;
|
|
53
60
|
unsigned long ftp_response_timeout;
|
|
54
61
|
long low_speed_limit;
|
|
55
62
|
long low_speed_time;
|
|
63
|
+
long max_send_speed_large;
|
|
64
|
+
long max_recv_speed_large;
|
|
56
65
|
long ssl_version;
|
|
57
66
|
long use_ssl;
|
|
58
67
|
long ftp_filemethod;
|
|
68
|
+
long http_version;
|
|
59
69
|
unsigned short resolve_mode;
|
|
60
70
|
|
|
61
71
|
/* bool flags */
|
|
@@ -70,20 +80,26 @@ typedef struct {
|
|
|
70
80
|
char verbose;
|
|
71
81
|
char multipart_form_post;
|
|
72
82
|
char enable_cookies;
|
|
83
|
+
char cookielist_engine_enabled; /* track if CURLOPT_COOKIELIST was used with a non-command to enable engine */
|
|
73
84
|
char ignore_content_length;
|
|
74
85
|
char callback_active;
|
|
75
86
|
|
|
76
87
|
struct curl_slist *curl_headers;
|
|
88
|
+
struct curl_slist *curl_proxy_headers;
|
|
77
89
|
struct curl_slist *curl_ftp_commands;
|
|
90
|
+
struct curl_slist *curl_resolve;
|
|
78
91
|
|
|
92
|
+
unsigned long multi_attachment_generation;
|
|
79
93
|
int last_result; /* last result code from multi loop */
|
|
80
94
|
|
|
81
95
|
} ruby_curl_easy;
|
|
82
96
|
|
|
83
97
|
extern VALUE cCurlEasy;
|
|
98
|
+
extern const rb_data_type_t ruby_curl_easy_data_type;
|
|
84
99
|
|
|
85
100
|
VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce);
|
|
86
101
|
VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce);
|
|
102
|
+
VALUE rb_curl_easy_take_callback_error(ruby_curl_easy *rbce);
|
|
87
103
|
|
|
88
104
|
void init_curb_easy();
|
|
89
105
|
|
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;
|
|
@@ -118,12 +119,27 @@ VALUE mCurlErrBadEasyHandle;
|
|
|
118
119
|
VALUE mCurlErrOutOfMemory;
|
|
119
120
|
VALUE mCurlErrInternalError;
|
|
120
121
|
VALUE mCurlErrBadSocket;
|
|
122
|
+
#ifdef HAVE_CURLM_ADDED_ALREADY
|
|
123
|
+
VALUE mCurlErrAddedAlready;
|
|
124
|
+
#endif
|
|
121
125
|
VALUE mCurlErrUnknownOption;
|
|
122
126
|
|
|
123
127
|
/* binding errors */
|
|
124
128
|
VALUE eCurlErrInvalidPostField;
|
|
125
129
|
|
|
126
130
|
|
|
131
|
+
/* new errors */
|
|
132
|
+
VALUE eCurlErrFTPPRETFailed;
|
|
133
|
+
VALUE eCurlErrRTSPCseqError;
|
|
134
|
+
VALUE eCurlErrRTSPSessionError;
|
|
135
|
+
VALUE eCurlErrFTPBadFileList;
|
|
136
|
+
VALUE eCurlErrChunkFailed;
|
|
137
|
+
VALUE eCurlErrNoConnectionAvailable;
|
|
138
|
+
VALUE eCurlErrSSLPinnedPubKeyNotMatch;
|
|
139
|
+
VALUE eCurlErrSSLInvalidCertStatus;
|
|
140
|
+
VALUE eCurlErrHTTP2Stream;
|
|
141
|
+
|
|
142
|
+
|
|
127
143
|
VALUE rb_curl_easy_error(CURLcode code) {
|
|
128
144
|
VALUE exclz;
|
|
129
145
|
const char *exmsg = NULL;
|
|
@@ -161,7 +177,7 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
161
177
|
exclz = eCurlErrConnectFailed;
|
|
162
178
|
break;
|
|
163
179
|
case CURLE_FTP_WEIRD_SERVER_REPLY: /* 8 */
|
|
164
|
-
exclz =
|
|
180
|
+
exclz = eCurlErrFTPWeirdReply;
|
|
165
181
|
break;
|
|
166
182
|
case CURLE_FTP_ACCESS_DENIED: /* 9 denied due to lack of access. */
|
|
167
183
|
exclz = eCurlErrFTPAccessDenied;
|
|
@@ -170,16 +186,16 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
170
186
|
exclz = eCurlErrFTPBadPassword;
|
|
171
187
|
break;
|
|
172
188
|
case CURLE_FTP_WEIRD_PASS_REPLY: /* 11 */
|
|
173
|
-
exclz =
|
|
189
|
+
exclz = eCurlErrFTPWeirdPassReply;
|
|
174
190
|
break;
|
|
175
191
|
case CURLE_FTP_WEIRD_USER_REPLY: /* 12 */
|
|
176
|
-
exclz =
|
|
192
|
+
exclz = eCurlErrFTPWeirdUserReply;
|
|
177
193
|
break;
|
|
178
194
|
case CURLE_FTP_WEIRD_PASV_REPLY: /* 13 */
|
|
179
|
-
exclz =
|
|
195
|
+
exclz = eCurlErrFTPWeirdPasvReply;
|
|
180
196
|
break;
|
|
181
197
|
case CURLE_FTP_WEIRD_227_FORMAT: /* 14 */
|
|
182
|
-
exclz =
|
|
198
|
+
exclz = eCurlErrFTPWeird227Format;
|
|
183
199
|
break;
|
|
184
200
|
case CURLE_FTP_CANT_GET_HOST: /* 15 */
|
|
185
201
|
exclz = eCurlErrFTPCantGetHost;
|
|
@@ -291,9 +307,11 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
291
307
|
exclz = eCurlErrObsolete;
|
|
292
308
|
break;
|
|
293
309
|
#endif
|
|
310
|
+
#if LIBCURL_VERSION_NUM < 0x073e00
|
|
294
311
|
case CURLE_SSL_PEER_CERTIFICATE: /* 51 - peer's certificate wasn't ok */
|
|
295
312
|
exclz = eCurlErrSSLPeerCertificate;
|
|
296
313
|
break;
|
|
314
|
+
#endif
|
|
297
315
|
case CURLE_GOT_NOTHING: /* 52 - when this is a specific error */
|
|
298
316
|
exclz = eCurlErrGotNothing;
|
|
299
317
|
break;
|
|
@@ -318,8 +336,13 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
318
336
|
case CURLE_SSL_CIPHER: /* 59 - couldn't use specified cipher */
|
|
319
337
|
exclz = eCurlErrSSLCipher;
|
|
320
338
|
break;
|
|
339
|
+
#if LIBCURL_VERSION_NUM >= 0x073e00
|
|
340
|
+
case CURLE_PEER_FAILED_VERIFICATION: /* 60 - problem with the CA cert (path?) */
|
|
341
|
+
exclz = eCurlErrSSLPeerCertificate;
|
|
342
|
+
#else
|
|
321
343
|
case CURLE_SSL_CACERT: /* 60 - problem with the CA cert (path?) */
|
|
322
344
|
exclz = eCurlErrSSLCACertificate;
|
|
345
|
+
#endif
|
|
323
346
|
break;
|
|
324
347
|
case CURLE_BAD_CONTENT_ENCODING: /* 61 - Unrecognized transfer encoding */
|
|
325
348
|
exclz = eCurlErrBadContentEncoding;
|
|
@@ -442,6 +465,61 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
|
442
465
|
exclz = eCurlErrSSLIssuerError;
|
|
443
466
|
break;
|
|
444
467
|
#endif
|
|
468
|
+
|
|
469
|
+
#ifdef HAVE_CURLE_FTP_PRET_FAILED
|
|
470
|
+
case CURLE_FTP_PRET_FAILED: /* 84 */
|
|
471
|
+
exclz = eCurlErrFTPPRETFailed;
|
|
472
|
+
break;
|
|
473
|
+
#endif
|
|
474
|
+
|
|
475
|
+
#ifdef HAVE_CURLE_RTSP_CSEQ_ERROR
|
|
476
|
+
case CURLE_RTSP_CSEQ_ERROR: /* 85 */
|
|
477
|
+
exclz = eCurlErrRTSPCseqError;
|
|
478
|
+
break;
|
|
479
|
+
#endif
|
|
480
|
+
|
|
481
|
+
#ifdef HAVE_CURLE_RTSP_SESSION_ERROR
|
|
482
|
+
case CURLE_RTSP_SESSION_ERROR: /* 86 */
|
|
483
|
+
exclz = eCurlErrRTSPSessionError;
|
|
484
|
+
break;
|
|
485
|
+
#endif
|
|
486
|
+
|
|
487
|
+
#ifdef HAVE_CURLE_FTP_BAD_FILE_LIST
|
|
488
|
+
case CURLE_FTP_BAD_FILE_LIST: /* 87 */
|
|
489
|
+
exclz = eCurlErrFTPBadFileList;
|
|
490
|
+
break;
|
|
491
|
+
#endif
|
|
492
|
+
|
|
493
|
+
#ifdef HAVE_CURLE_CHUNK_FAILED
|
|
494
|
+
case CURLE_CHUNK_FAILED: /* 88 */
|
|
495
|
+
exclz = eCurlErrChunkFailed;
|
|
496
|
+
break;
|
|
497
|
+
#endif
|
|
498
|
+
|
|
499
|
+
#ifdef HAVE_CURLE_NO_CONNECTION_AVAILABLE
|
|
500
|
+
case CURLE_NO_CONNECTION_AVAILABLE: /* 89 */
|
|
501
|
+
exclz = eCurlErrNoConnectionAvailable;
|
|
502
|
+
break;
|
|
503
|
+
#endif
|
|
504
|
+
|
|
505
|
+
#ifdef HAVE_CURLE_SSL_PINNEDPUBKEYNOTMATCH
|
|
506
|
+
case CURLE_SSL_PINNEDPUBKEYNOTMATCH: /* 90 */
|
|
507
|
+
exclz = eCurlErrSSLPinnedPubKeyNotMatch;
|
|
508
|
+
break;
|
|
509
|
+
#endif
|
|
510
|
+
|
|
511
|
+
#ifdef HAVE_CURLE_SSL_INVALIDCERTSTATUS
|
|
512
|
+
case CURLE_SSL_INVALIDCERTSTATUS: /* 91 */
|
|
513
|
+
exclz = eCurlErrSSLInvalidCertStatus;
|
|
514
|
+
break;
|
|
515
|
+
#endif
|
|
516
|
+
|
|
517
|
+
#ifdef HAVE_CURLE_HTTP2_STREAM
|
|
518
|
+
case CURLE_HTTP2_STREAM: /* 92 */
|
|
519
|
+
exclz = eCurlErrHTTP2Stream;
|
|
520
|
+
break;
|
|
521
|
+
#endif
|
|
522
|
+
|
|
445
523
|
default:
|
|
446
524
|
exclz = eCurlErrError;
|
|
447
525
|
exmsg = "Unknown error result from libcurl";
|
|
@@ -483,15 +561,20 @@ VALUE rb_curl_multi_error(CURLMcode code) {
|
|
|
483
561
|
case CURLM_INTERNAL_ERROR: /* 4 */
|
|
484
562
|
exclz = mCurlErrInternalError;
|
|
485
563
|
break;
|
|
486
|
-
#
|
|
564
|
+
#ifdef HAVE_CURLM_BAD_SOCKET
|
|
487
565
|
case CURLM_BAD_SOCKET: /* 5 */
|
|
488
566
|
exclz = mCurlErrBadSocket;
|
|
489
567
|
break;
|
|
490
568
|
#endif
|
|
491
|
-
#
|
|
569
|
+
#ifdef HAVE_CURLM_UNKNOWN_OPTION
|
|
492
570
|
case CURLM_UNKNOWN_OPTION: /* 6 */
|
|
493
571
|
exclz = mCurlErrUnknownOption;
|
|
494
572
|
break;
|
|
573
|
+
#endif
|
|
574
|
+
#ifdef HAVE_CURLM_ADDED_ALREADY
|
|
575
|
+
case CURLM_ADDED_ALREADY: /* 7 */
|
|
576
|
+
exclz = mCurlErrAddedAlready;
|
|
577
|
+
break;
|
|
495
578
|
#endif
|
|
496
579
|
default:
|
|
497
580
|
exclz = eCurlErrError;
|
|
@@ -524,6 +607,7 @@ void init_curb_errors() {
|
|
|
524
607
|
eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
|
|
525
608
|
eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
|
|
526
609
|
eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
|
|
610
|
+
eCurlErrRTSPError = rb_define_class_under(mCurlErr, "RTSPError", eCurlErrError);
|
|
527
611
|
|
|
528
612
|
eCurlErrOK = rb_define_class_under(mCurlErr, "CurlOK", eCurlErrError);
|
|
529
613
|
eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
|
|
@@ -535,13 +619,13 @@ void init_curb_errors() {
|
|
|
535
619
|
eCurlErrHostResolution = rb_define_class_under(mCurlErr, "HostResolutionError", eCurlErrError);
|
|
536
620
|
eCurlErrConnectFailed = rb_define_class_under(mCurlErr, "ConnectionFailedError", eCurlErrError);
|
|
537
621
|
|
|
538
|
-
|
|
622
|
+
eCurlErrFTPWeirdReply = rb_define_class_under(mCurlErr, "WeirdReplyError", eCurlErrFTPError);
|
|
539
623
|
eCurlErrFTPAccessDenied = rb_define_class_under(mCurlErr, "AccessDeniedError", eCurlErrFTPError);
|
|
540
|
-
eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
624
|
+
eCurlErrFTPBadPassword = rb_define_class_under(mCurlErr, "BadPasswordError", eCurlErrFTPError);
|
|
625
|
+
eCurlErrFTPWeirdPassReply = rb_define_class_under(mCurlErr, "WeirdPassReplyError", eCurlErrFTPError);
|
|
626
|
+
eCurlErrFTPWeirdUserReply = rb_define_class_under(mCurlErr, "WeirdUserReplyError", eCurlErrFTPError);
|
|
627
|
+
eCurlErrFTPWeirdPasvReply = rb_define_class_under(mCurlErr, "WeirdPasvReplyError", eCurlErrFTPError);
|
|
628
|
+
eCurlErrFTPWeird227Format = rb_define_class_under(mCurlErr, "Weird227FormatError", eCurlErrFTPError);
|
|
545
629
|
eCurlErrFTPCantGetHost = rb_define_class_under(mCurlErr, "CantGetHostError", eCurlErrFTPError);
|
|
546
630
|
eCurlErrFTPCantReconnect = rb_define_class_under(mCurlErr, "CantReconnectError", eCurlErrFTPError);
|
|
547
631
|
eCurlErrFTPCouldntSetBinary = rb_define_class_under(mCurlErr, "CouldntSetBinaryError", eCurlErrFTPError);
|
|
@@ -625,6 +709,9 @@ void init_curb_errors() {
|
|
|
625
709
|
mCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "MultiOutOfMemory", eCurlErrError);
|
|
626
710
|
mCurlErrInternalError = rb_define_class_under(mCurlErr, "MultiInternalError", eCurlErrError);
|
|
627
711
|
mCurlErrBadSocket = rb_define_class_under(mCurlErr, "MultiBadSocket", eCurlErrError);
|
|
712
|
+
#ifdef HAVE_CURLM_ADDED_ALREADY
|
|
713
|
+
mCurlErrAddedAlready = rb_define_class_under(mCurlErr, "MultiAddedAlready", eCurlErrError);
|
|
714
|
+
#endif
|
|
628
715
|
mCurlErrUnknownOption = rb_define_class_under(mCurlErr, "MultiUnknownOption", eCurlErrError);
|
|
629
716
|
|
|
630
717
|
eCurlErrLDAPInvalidURL = rb_define_class_under(mCurlErr, "InvalidLDAPURLError", eCurlErrLDAPError);
|
|
@@ -646,4 +733,14 @@ void init_curb_errors() {
|
|
|
646
733
|
eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);
|
|
647
734
|
|
|
648
735
|
eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError);
|
|
736
|
+
|
|
737
|
+
eCurlErrFTPPRETFailed = rb_define_class_under(mCurlErr, "PPRETFailedError", eCurlErrFTPError);
|
|
738
|
+
eCurlErrRTSPCseqError = rb_define_class_under(mCurlErr, "CseqError", eCurlErrRTSPError);
|
|
739
|
+
eCurlErrRTSPSessionError = rb_define_class_under(mCurlErr, "SessionError", eCurlErrRTSPError);
|
|
740
|
+
eCurlErrFTPBadFileList = rb_define_class_under(mCurlErr, "BadFileListError", eCurlErrFTPError);
|
|
741
|
+
eCurlErrChunkFailed = rb_define_class_under(mCurlErr, "ChunkFailedError", eCurlErrError);
|
|
742
|
+
eCurlErrNoConnectionAvailable = rb_define_class_under(mCurlErr, "NoConnectionAvailableError", eCurlErrError);
|
|
743
|
+
eCurlErrSSLPinnedPubKeyNotMatch = rb_define_class_under(mCurlErr, "SSLPinnedPubKeyNotMatchError", eCurlErrError);
|
|
744
|
+
eCurlErrSSLInvalidCertStatus = rb_define_class_under(mCurlErr, "SSLInvalidCertStatusError", eCurlErrError);
|
|
745
|
+
eCurlErrHTTP2Stream = rb_define_class_under(mCurlErr, "HTTP2StreamError", eCurlErrHTTPError);
|
|
649
746
|
}
|
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;
|
|
@@ -116,6 +116,9 @@ extern VALUE mCurlErrOutOfMemory;
|
|
|
116
116
|
extern VALUE mCurlErrInternalError;
|
|
117
117
|
extern VALUE mCurlErrBadSocket;
|
|
118
118
|
extern VALUE mCurlErrUnknownOption;
|
|
119
|
+
#ifdef HAVE_CURLM_ADDED_ALREADY
|
|
120
|
+
extern VALUE mCurlErrAddedAlready;
|
|
121
|
+
#endif
|
|
119
122
|
|
|
120
123
|
/* binding errors */
|
|
121
124
|
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
|