curb 0.9.3 → 1.0.1
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 +5 -5
- data/README.markdown +76 -21
- data/Rakefile +33 -20
- data/ext/banned.h +32 -0
- data/ext/curb.c +186 -14
- data/ext/curb.h +18 -5
- data/ext/curb_easy.c +493 -84
- data/ext/curb_easy.h +7 -0
- data/ext/curb_errors.c +86 -0
- data/ext/curb_multi.c +141 -218
- data/ext/curb_multi.h +0 -1
- data/ext/curb_postfield.c +7 -7
- data/ext/extconf.rb +74 -6
- data/lib/curb.rb +1 -0
- data/lib/curl/easy.rb +16 -9
- data/lib/curl/multi.rb +52 -13
- data/lib/curl.rb +20 -12
- data/tests/bug_issue277.rb +32 -0
- data/tests/helper.rb +96 -13
- data/tests/tc_curl.rb +31 -1
- data/tests/tc_curl_download.rb +3 -3
- data/tests/tc_curl_easy.rb +163 -42
- data/tests/tc_curl_easy_resolve.rb +16 -0
- data/tests/tc_curl_maxfilesize.rb +12 -0
- data/tests/tc_curl_multi.rb +118 -15
- data/tests/tc_curl_postfield.rb +29 -29
- data/tests/tc_curl_protocols.rb +37 -0
- data/tests/timeout.rb +21 -5
- metadata +33 -25
data/ext/curb_easy.h
CHANGED
@@ -36,6 +36,9 @@ 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
|
+
|
39
42
|
VALUE opts; /* rather then allocate everything we might need to store, allocate a Hash and only store objects we actually use... */
|
40
43
|
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 */
|
41
44
|
|
@@ -55,6 +58,8 @@ typedef struct {
|
|
55
58
|
unsigned long ftp_response_timeout;
|
56
59
|
long low_speed_limit;
|
57
60
|
long low_speed_time;
|
61
|
+
long max_send_speed_large;
|
62
|
+
long max_recv_speed_large;
|
58
63
|
long ssl_version;
|
59
64
|
long use_ssl;
|
60
65
|
long ftp_filemethod;
|
@@ -76,7 +81,9 @@ typedef struct {
|
|
76
81
|
char callback_active;
|
77
82
|
|
78
83
|
struct curl_slist *curl_headers;
|
84
|
+
struct curl_slist *curl_proxy_headers;
|
79
85
|
struct curl_slist *curl_ftp_commands;
|
86
|
+
struct curl_slist *curl_resolve;
|
80
87
|
|
81
88
|
int last_result; /* last result code from multi loop */
|
82
89
|
|
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 */
|
@@ -127,6 +128,18 @@ VALUE mCurlErrUnknownOption;
|
|
127
128
|
VALUE eCurlErrInvalidPostField;
|
128
129
|
|
129
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
|
+
|
130
143
|
VALUE rb_curl_easy_error(CURLcode code) {
|
131
144
|
VALUE exclz;
|
132
145
|
const char *exmsg = NULL;
|
@@ -294,9 +307,11 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
294
307
|
exclz = eCurlErrObsolete;
|
295
308
|
break;
|
296
309
|
#endif
|
310
|
+
#if LIBCURL_VERSION_NUM < 0x073e00
|
297
311
|
case CURLE_SSL_PEER_CERTIFICATE: /* 51 - peer's certificate wasn't ok */
|
298
312
|
exclz = eCurlErrSSLPeerCertificate;
|
299
313
|
break;
|
314
|
+
#endif
|
300
315
|
case CURLE_GOT_NOTHING: /* 52 - when this is a specific error */
|
301
316
|
exclz = eCurlErrGotNothing;
|
302
317
|
break;
|
@@ -321,8 +336,13 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
321
336
|
case CURLE_SSL_CIPHER: /* 59 - couldn't use specified cipher */
|
322
337
|
exclz = eCurlErrSSLCipher;
|
323
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
|
324
343
|
case CURLE_SSL_CACERT: /* 60 - problem with the CA cert (path?) */
|
325
344
|
exclz = eCurlErrSSLCACertificate;
|
345
|
+
#endif
|
326
346
|
break;
|
327
347
|
case CURLE_BAD_CONTENT_ENCODING: /* 61 - Unrecognized transfer encoding */
|
328
348
|
exclz = eCurlErrBadContentEncoding;
|
@@ -445,6 +465,61 @@ VALUE rb_curl_easy_error(CURLcode code) {
|
|
445
465
|
exclz = eCurlErrSSLIssuerError;
|
446
466
|
break;
|
447
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
|
+
|
448
523
|
default:
|
449
524
|
exclz = eCurlErrError;
|
450
525
|
exmsg = "Unknown error result from libcurl";
|
@@ -532,6 +607,7 @@ void init_curb_errors() {
|
|
532
607
|
eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
|
533
608
|
eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
|
534
609
|
eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
|
610
|
+
eCurlErrRTSPError = rb_define_class_under(mCurlErr, "RTSPError", eCurlErrError);
|
535
611
|
|
536
612
|
eCurlErrOK = rb_define_class_under(mCurlErr, "CurlOK", eCurlErrError);
|
537
613
|
eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
|
@@ -657,4 +733,14 @@ void init_curb_errors() {
|
|
657
733
|
eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);
|
658
734
|
|
659
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);
|
660
746
|
}
|