curb 0.1.4 → 0.7.15
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 +131 -60
- data/Rakefile +81 -68
- data/doc.rb +1 -1
- data/ext/curb.c +107 -70
- data/ext/curb.h +23 -10
- data/ext/curb_easy.c +2156 -908
- data/ext/curb_easy.h +41 -28
- data/ext/curb_errors.c +258 -92
- data/ext/curb_errors.h +25 -2
- data/ext/curb_macros.h +41 -0
- data/ext/curb_multi.c +565 -0
- data/ext/curb_multi.h +26 -0
- data/ext/curb_postfield.c +68 -44
- data/ext/curb_upload.c +80 -0
- data/ext/curb_upload.h +30 -0
- data/ext/extconf.rb +159 -7
- data/lib/curb.rb +308 -0
- data/{ext → lib}/curl.rb +0 -1
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +52 -0
- data/tests/bug_curb_easy_post_with_string_no_content_length_header.rb +83 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +1 -1
- data/tests/bug_multi_segfault.rb +14 -0
- data/tests/bug_postfields_crash.rb +26 -0
- data/tests/bug_postfields_crash2.rb +57 -0
- data/tests/bugtests.rb +9 -0
- data/tests/helper.rb +168 -0
- data/tests/mem_check.rb +65 -0
- data/tests/require_last_or_segfault_script.rb +2 -2
- data/tests/tc_curl_download.rb +75 -0
- data/tests/tc_curl_easy.rb +464 -9
- data/tests/tc_curl_multi.rb +466 -0
- data/tests/tc_curl_postfield.rb +4 -2
- data/tests/timeout.rb +100 -0
- data/tests/timeout_server.rb +33 -0
- metadata +103 -56
- data/ext/curb.rb +0 -46
- data/samples/gmail.rb +0 -48
data/ext/curb_easy.h
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* curb_easy.h - Curl easy mode
|
|
2
|
-
* Copyright (c)2006 Ross Bamford.
|
|
2
|
+
* Copyright (c)2006 Ross Bamford.
|
|
3
3
|
* Licensed under the Ruby License. See LICENSE for details.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* $Id: curb_easy.h 25 2006-12-07 23:38:25Z roscopeco $
|
|
6
6
|
*/
|
|
7
7
|
#ifndef __CURB_EASY_H
|
|
@@ -11,33 +11,38 @@
|
|
|
11
11
|
|
|
12
12
|
#include <curl/easy.h>
|
|
13
13
|
|
|
14
|
+
#ifdef CURL_VERSION_SSL
|
|
15
|
+
#if LIBCURL_VERSION_NUM >= 0x070b00
|
|
16
|
+
# if LIBCURL_VERSION_NUM <= 0x071004
|
|
17
|
+
# define CURB_FTPSSL CURLOPT_FTP_SSL
|
|
18
|
+
# define CURB_FTPSSL_ALL CURLFTPSSL_ALL
|
|
19
|
+
# define CURB_FTPSSL_TRY CURLFTPSSL_TRY
|
|
20
|
+
# define CURB_FTPSSL_CONTROL CURLFTPSSL_CONTROL
|
|
21
|
+
# define CURB_FTPSSL_NONE CURLFTPSSL_NONE
|
|
22
|
+
# else
|
|
23
|
+
# define CURB_FTPSSL CURLOPT_USE_SSL
|
|
24
|
+
# define CURB_FTPSSL_ALL CURLUSESSL_ALL
|
|
25
|
+
# define CURB_FTPSSL_TRY CURLUSESSL_TRY
|
|
26
|
+
# define CURB_FTPSSL_CONTROL CURLUSESSL_CONTROL
|
|
27
|
+
# define CURB_FTPSSL_NONE CURLUSESSL_NONE
|
|
28
|
+
# endif
|
|
29
|
+
#endif
|
|
30
|
+
#endif
|
|
31
|
+
|
|
14
32
|
/* a lot of this *could* be kept in the handler itself,
|
|
15
33
|
* but then we lose the ability to query it's status.
|
|
16
34
|
*/
|
|
17
35
|
typedef struct {
|
|
18
36
|
/* The handler */
|
|
19
37
|
CURL *curl;
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
VALUE
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
VALUE body_proc;
|
|
26
|
-
VALUE header_proc;
|
|
27
|
-
VALUE body_data; /* These have the result from the last curl_easy_perform */
|
|
28
|
-
VALUE header_data; /* unless a block is supplied (when they'll be nil) */
|
|
29
|
-
VALUE progress_proc;
|
|
30
|
-
VALUE debug_proc;
|
|
31
|
-
VALUE interface;
|
|
32
|
-
VALUE userpwd;
|
|
33
|
-
VALUE proxypwd;
|
|
34
|
-
VALUE headers; /* ruby array of strings with headers to set */
|
|
35
|
-
VALUE cookiejar; /* filename */
|
|
36
|
-
|
|
38
|
+
|
|
39
|
+
VALUE opts; /* rather then allocate everything we might need to store, allocate a Hash and only store objects we actually use... */
|
|
40
|
+
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
|
+
|
|
37
42
|
/* Other opts */
|
|
38
43
|
unsigned short local_port; // 0 is no port
|
|
39
44
|
unsigned short local_port_range; // " " " "
|
|
40
|
-
unsigned short proxy_port; // " " " "
|
|
45
|
+
unsigned short proxy_port; // " " " "
|
|
41
46
|
int proxy_type;
|
|
42
47
|
long http_auth_types;
|
|
43
48
|
long proxy_auth_types;
|
|
@@ -46,8 +51,13 @@ typedef struct {
|
|
|
46
51
|
unsigned long connect_timeout;
|
|
47
52
|
long dns_cache_timeout;
|
|
48
53
|
unsigned long ftp_response_timeout;
|
|
54
|
+
long low_speed_limit;
|
|
55
|
+
long low_speed_time;
|
|
56
|
+
long ssl_version;
|
|
57
|
+
long use_ssl;
|
|
58
|
+
long ftp_filemethod;
|
|
49
59
|
|
|
50
|
-
/* bool flags */
|
|
60
|
+
/* bool flags */
|
|
51
61
|
char proxy_tunnel;
|
|
52
62
|
char fetch_file_time;
|
|
53
63
|
char ssl_verify_peer;
|
|
@@ -56,19 +66,22 @@ typedef struct {
|
|
|
56
66
|
char use_netrc;
|
|
57
67
|
char follow_location;
|
|
58
68
|
char unrestricted_auth;
|
|
59
|
-
char verbose;
|
|
69
|
+
char verbose;
|
|
60
70
|
char multipart_form_post;
|
|
61
71
|
char enable_cookies;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
char ignore_content_length;
|
|
73
|
+
struct curl_slist *curl_headers;
|
|
74
|
+
struct curl_slist *curl_ftp_commands;
|
|
75
|
+
|
|
76
|
+
int last_result; /* last result code from multi loop */
|
|
77
|
+
|
|
68
78
|
} ruby_curl_easy;
|
|
69
79
|
|
|
70
80
|
extern VALUE cCurlEasy;
|
|
71
81
|
|
|
82
|
+
VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce);
|
|
83
|
+
VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce);
|
|
84
|
+
|
|
72
85
|
void init_curb_easy();
|
|
73
86
|
|
|
74
87
|
#endif
|
data/ext/curb_errors.c
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* curb_errors.c - Ruby exception types for curl errors
|
|
2
|
-
* Copyright (c)2006 Ross Bamford.
|
|
2
|
+
* Copyright (c)2006 Ross Bamford.
|
|
3
3
|
* Licensed under the Ruby License. See LICENSE for details.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
5
|
* $Id: curb_errors.c 10 2006-11-20 00:17:30Z roscopeco $
|
|
6
6
|
*/
|
|
7
7
|
#include "curb_errors.h"
|
|
@@ -23,6 +23,7 @@ VALUE eCurlErrTelnetError;
|
|
|
23
23
|
VALUE eCurlErrTFTPError;
|
|
24
24
|
|
|
25
25
|
/* Specific libcurl errors */
|
|
26
|
+
VALUE eCurlErrOK; /* not really an error but a return code */
|
|
26
27
|
VALUE eCurlErrUnsupportedProtocol;
|
|
27
28
|
VALUE eCurlErrFailedInit;
|
|
28
29
|
VALUE eCurlErrMalformedURL;
|
|
@@ -98,263 +99,408 @@ VALUE eCurlErrTFTPUnknownID;
|
|
|
98
99
|
VALUE eCurlErrTFTPFileExists;
|
|
99
100
|
VALUE eCurlErrTFTPNoSuchUser;
|
|
100
101
|
|
|
102
|
+
VALUE eCurlErrConvFailed;
|
|
103
|
+
VALUE eCurlErrConvReqd;
|
|
104
|
+
VALUE eCurlErrSSLCacertBadfile;
|
|
105
|
+
VALUE eCurlErrRemoteFileNotFound;
|
|
106
|
+
VALUE eCurlErrSSH;
|
|
107
|
+
VALUE eCurlErrSSLShutdownFailed;
|
|
108
|
+
VALUE eCurlErrAgain;
|
|
109
|
+
VALUE eCurlErrSSLCRLBadfile;
|
|
110
|
+
VALUE eCurlErrSSLIssuerError;
|
|
111
|
+
|
|
112
|
+
/* multi errors */
|
|
113
|
+
VALUE mCurlErrFailedInit;
|
|
114
|
+
VALUE mCurlErrCallMultiPerform;
|
|
115
|
+
VALUE mCurlErrBadHandle;
|
|
116
|
+
VALUE mCurlErrBadEasyHandle;
|
|
117
|
+
VALUE mCurlErrOutOfMemory;
|
|
118
|
+
VALUE mCurlErrInternalError;
|
|
119
|
+
VALUE mCurlErrBadSocket;
|
|
120
|
+
VALUE mCurlErrUnknownOption;
|
|
121
|
+
|
|
101
122
|
/* binding errors */
|
|
102
123
|
VALUE eCurlErrInvalidPostField;
|
|
103
124
|
|
|
104
|
-
|
|
105
|
-
|
|
125
|
+
|
|
126
|
+
VALUE rb_curl_easy_error(CURLcode code) {
|
|
106
127
|
VALUE exclz;
|
|
107
128
|
const char *exmsg = NULL;
|
|
108
|
-
|
|
129
|
+
VALUE results;
|
|
130
|
+
|
|
109
131
|
switch (code) {
|
|
132
|
+
case CURLE_OK: /* 0 */
|
|
133
|
+
exclz = eCurlErrOK;
|
|
134
|
+
break;
|
|
110
135
|
case CURLE_UNSUPPORTED_PROTOCOL: /* 1 */
|
|
111
136
|
exclz = eCurlErrUnsupportedProtocol;
|
|
112
|
-
break;
|
|
137
|
+
break;
|
|
113
138
|
case CURLE_FAILED_INIT: /* 2 */
|
|
114
139
|
exclz = eCurlErrFailedInit;
|
|
115
140
|
break;
|
|
116
141
|
case CURLE_URL_MALFORMAT: /* 3 */
|
|
117
142
|
exclz = eCurlErrMalformedURL;
|
|
118
|
-
break;
|
|
143
|
+
break;
|
|
119
144
|
case CURLE_URL_MALFORMAT_USER: /* 4 (NOT USED) */
|
|
120
145
|
exclz = eCurlErrMalformedURLUser;
|
|
121
|
-
break;
|
|
146
|
+
break;
|
|
122
147
|
case CURLE_COULDNT_RESOLVE_PROXY: /* 5 */
|
|
123
148
|
exclz = eCurlErrProxyResolution;
|
|
124
|
-
break;
|
|
149
|
+
break;
|
|
125
150
|
case CURLE_COULDNT_RESOLVE_HOST: /* 6 */
|
|
126
151
|
exclz = eCurlErrHostResolution;
|
|
127
|
-
break;
|
|
152
|
+
break;
|
|
128
153
|
case CURLE_COULDNT_CONNECT: /* 7 */
|
|
129
154
|
exclz = eCurlErrConnectFailed;
|
|
130
|
-
break;
|
|
155
|
+
break;
|
|
131
156
|
case CURLE_FTP_WEIRD_SERVER_REPLY: /* 8 */
|
|
132
157
|
exclz = eCurlErrFTPWierdReply;
|
|
133
|
-
break;
|
|
158
|
+
break;
|
|
134
159
|
case CURLE_FTP_ACCESS_DENIED: /* 9 denied due to lack of access. */
|
|
135
160
|
exclz = eCurlErrFTPAccessDenied;
|
|
136
|
-
break;
|
|
161
|
+
break;
|
|
137
162
|
case CURLE_FTP_USER_PASSWORD_INCORRECT: /* 10 */
|
|
138
163
|
exclz = eCurlErrFTPBadPassword;
|
|
139
|
-
break;
|
|
164
|
+
break;
|
|
140
165
|
case CURLE_FTP_WEIRD_PASS_REPLY: /* 11 */
|
|
141
166
|
exclz = eCurlErrFTPWierdPassReply;
|
|
142
|
-
break;
|
|
167
|
+
break;
|
|
143
168
|
case CURLE_FTP_WEIRD_USER_REPLY: /* 12 */
|
|
144
169
|
exclz = eCurlErrFTPWierdUserReply;
|
|
145
|
-
break;
|
|
170
|
+
break;
|
|
146
171
|
case CURLE_FTP_WEIRD_PASV_REPLY: /* 13 */
|
|
147
172
|
exclz = eCurlErrFTPWierdPasvReply;
|
|
148
|
-
break;
|
|
173
|
+
break;
|
|
149
174
|
case CURLE_FTP_WEIRD_227_FORMAT: /* 14 */
|
|
150
175
|
exclz = eCurlErrFTPWierd227Format;
|
|
151
|
-
break;
|
|
176
|
+
break;
|
|
152
177
|
case CURLE_FTP_CANT_GET_HOST: /* 15 */
|
|
153
178
|
exclz = eCurlErrFTPCantGetHost;
|
|
154
|
-
break;
|
|
179
|
+
break;
|
|
155
180
|
case CURLE_FTP_CANT_RECONNECT: /* 16 */
|
|
156
181
|
exclz = eCurlErrFTPCantReconnect;
|
|
157
|
-
break;
|
|
182
|
+
break;
|
|
158
183
|
case CURLE_FTP_COULDNT_SET_BINARY: /* 17 */
|
|
159
184
|
exclz = eCurlErrFTPCouldntSetBinary;
|
|
160
|
-
break;
|
|
185
|
+
break;
|
|
161
186
|
case CURLE_PARTIAL_FILE: /* 18 */
|
|
162
187
|
exclz = eCurlErrPartialFile;
|
|
163
|
-
break;
|
|
188
|
+
break;
|
|
164
189
|
case CURLE_FTP_COULDNT_RETR_FILE: /* 19 */
|
|
165
190
|
exclz = eCurlErrFTPCouldntRetrFile;
|
|
166
|
-
break;
|
|
191
|
+
break;
|
|
167
192
|
case CURLE_FTP_WRITE_ERROR: /* 20 */
|
|
168
193
|
exclz = eCurlErrFTPWrite;
|
|
169
|
-
break;
|
|
194
|
+
break;
|
|
170
195
|
case CURLE_FTP_QUOTE_ERROR: /* 21 */
|
|
171
196
|
exclz = eCurlErrFTPQuote;
|
|
172
|
-
break;
|
|
197
|
+
break;
|
|
173
198
|
case CURLE_HTTP_RETURNED_ERROR: /* 22 */
|
|
174
199
|
exclz = eCurlErrHTTPFailed;
|
|
175
|
-
break;
|
|
200
|
+
break;
|
|
176
201
|
case CURLE_WRITE_ERROR: /* 23 */
|
|
177
202
|
exclz = eCurlErrWriteError;
|
|
178
|
-
break;
|
|
203
|
+
break;
|
|
179
204
|
case CURLE_MALFORMAT_USER: /* 24 - NOT USED */
|
|
180
205
|
exclz = eCurlErrMalformedUser;
|
|
181
|
-
break;
|
|
206
|
+
break;
|
|
182
207
|
case CURLE_FTP_COULDNT_STOR_FILE: /* 25 - failed FTP upload */
|
|
183
208
|
exclz = eCurlErrFTPCouldntStorFile;
|
|
184
|
-
break;
|
|
209
|
+
break;
|
|
185
210
|
case CURLE_READ_ERROR: /* 26 - could open/read from file */
|
|
186
211
|
exclz = eCurlErrReadError;
|
|
187
|
-
break;
|
|
212
|
+
break;
|
|
188
213
|
case CURLE_OUT_OF_MEMORY: /* 27 */
|
|
189
214
|
exclz = eCurlErrOutOfMemory;
|
|
190
|
-
break;
|
|
215
|
+
break;
|
|
191
216
|
case CURLE_OPERATION_TIMEOUTED: /* 28 - the timeout time was reached */
|
|
192
217
|
exclz = eCurlErrTimeout;
|
|
193
|
-
break;
|
|
218
|
+
break;
|
|
194
219
|
case CURLE_FTP_COULDNT_SET_ASCII: /* 29 - TYPE A failed */
|
|
195
220
|
exclz = eCurlErrFTPCouldntSetASCII;
|
|
196
|
-
break;
|
|
221
|
+
break;
|
|
197
222
|
case CURLE_FTP_PORT_FAILED: /* 30 - FTP PORT operation failed */
|
|
198
223
|
exclz = eCurlErrFTPPortFailed;
|
|
199
|
-
break;
|
|
224
|
+
break;
|
|
200
225
|
case CURLE_FTP_COULDNT_USE_REST: /* 31 - the REST command failed */
|
|
201
226
|
exclz = eCurlErrFTPCouldntUseRest;
|
|
202
|
-
break;
|
|
227
|
+
break;
|
|
203
228
|
case CURLE_FTP_COULDNT_GET_SIZE: /* 32 - the SIZE command failed */
|
|
204
229
|
exclz = eCurlErrFTPCouldntGetSize;
|
|
205
|
-
break;
|
|
230
|
+
break;
|
|
206
231
|
case CURLE_HTTP_RANGE_ERROR: /* 33 - RANGE "command" didn't work */
|
|
207
232
|
exclz = eCurlErrHTTPRange;
|
|
208
|
-
break;
|
|
233
|
+
break;
|
|
209
234
|
case CURLE_HTTP_POST_ERROR: /* 34 */
|
|
210
235
|
exclz = eCurlErrHTTPPost;
|
|
211
|
-
break;
|
|
236
|
+
break;
|
|
212
237
|
case CURLE_SSL_CONNECT_ERROR: /* 35 - wrong when connecting with SSL */
|
|
213
238
|
exclz = eCurlErrSSLConnectError;
|
|
214
|
-
break;
|
|
239
|
+
break;
|
|
215
240
|
case CURLE_BAD_DOWNLOAD_RESUME: /* 36 - couldn't resume download */
|
|
216
241
|
exclz = eCurlErrBadResume;
|
|
217
|
-
break;
|
|
242
|
+
break;
|
|
218
243
|
case CURLE_FILE_COULDNT_READ_FILE: /* 37 */
|
|
219
244
|
exclz = eCurlErrFileCouldntRead;
|
|
220
|
-
break;
|
|
245
|
+
break;
|
|
221
246
|
case CURLE_LDAP_CANNOT_BIND: /* 38 */
|
|
222
247
|
exclz = eCurlErrLDAPCouldntBind;
|
|
223
|
-
break;
|
|
248
|
+
break;
|
|
224
249
|
case CURLE_LDAP_SEARCH_FAILED: /* 39 */
|
|
225
250
|
exclz = eCurlErrLDAPSearchFailed;
|
|
226
|
-
break;
|
|
251
|
+
break;
|
|
227
252
|
case CURLE_LIBRARY_NOT_FOUND: /* 40 */
|
|
228
253
|
exclz = eCurlErrLibraryNotFound;
|
|
229
|
-
break;
|
|
254
|
+
break;
|
|
230
255
|
case CURLE_FUNCTION_NOT_FOUND: /* 41 */
|
|
231
256
|
exclz = eCurlErrFunctionNotFound;
|
|
232
|
-
break;
|
|
257
|
+
break;
|
|
233
258
|
case CURLE_ABORTED_BY_CALLBACK: /* 42 */
|
|
234
259
|
exclz = eCurlErrAbortedByCallback;
|
|
235
|
-
break;
|
|
260
|
+
break;
|
|
236
261
|
case CURLE_BAD_FUNCTION_ARGUMENT: /* 43 */
|
|
237
262
|
exclz = eCurlErrBadFunctionArgument;
|
|
238
|
-
break;
|
|
263
|
+
break;
|
|
239
264
|
case CURLE_BAD_CALLING_ORDER: /* 44 - NOT USED */
|
|
240
265
|
exclz = eCurlErrBadCallingOrder;
|
|
241
|
-
break;
|
|
266
|
+
break;
|
|
242
267
|
case CURLE_INTERFACE_FAILED: /* 45 - CURLOPT_INTERFACE failed */
|
|
243
268
|
exclz = eCurlErrInterfaceFailed;
|
|
244
|
-
break;
|
|
269
|
+
break;
|
|
245
270
|
case CURLE_BAD_PASSWORD_ENTERED: /* 46 - NOT USED */
|
|
246
271
|
exclz = eCurlErrBadPasswordEntered;
|
|
247
|
-
break;
|
|
272
|
+
break;
|
|
248
273
|
case CURLE_TOO_MANY_REDIRECTS: /* 47 - catch endless re-direct loops */
|
|
249
274
|
exclz = eCurlErrTooManyRedirects;
|
|
250
|
-
break;
|
|
275
|
+
break;
|
|
251
276
|
case CURLE_UNKNOWN_TELNET_OPTION: /* 48 - User specified an unknown option */
|
|
252
277
|
exclz = eCurlErrTelnetUnknownOption;
|
|
253
|
-
break;
|
|
278
|
+
break;
|
|
254
279
|
case CURLE_TELNET_OPTION_SYNTAX: /* 49 - Malformed telnet option */
|
|
255
280
|
exclz = eCurlErrTelnetBadOptionSyntax;
|
|
256
|
-
break;
|
|
281
|
+
break;
|
|
257
282
|
case CURLE_OBSOLETE: /* 50 - NOT USED */
|
|
258
283
|
exclz = eCurlErrObsolete;
|
|
259
|
-
break;
|
|
284
|
+
break;
|
|
260
285
|
case CURLE_SSL_PEER_CERTIFICATE: /* 51 - peer's certificate wasn't ok */
|
|
261
286
|
exclz = eCurlErrSSLPeerCertificate;
|
|
262
|
-
break;
|
|
287
|
+
break;
|
|
263
288
|
case CURLE_GOT_NOTHING: /* 52 - when this is a specific error */
|
|
264
289
|
exclz = eCurlErrGotNothing;
|
|
265
|
-
break;
|
|
290
|
+
break;
|
|
266
291
|
case CURLE_SSL_ENGINE_NOTFOUND: /* 53 - SSL crypto engine not found */
|
|
267
292
|
exclz = eCurlErrSSLEngineNotFound;
|
|
268
|
-
break;
|
|
293
|
+
break;
|
|
269
294
|
case CURLE_SSL_ENGINE_SETFAILED: /* 54 - can not set SSL crypto engine as default */
|
|
270
295
|
exclz = eCurlErrSSLEngineSetFailed;
|
|
271
|
-
break;
|
|
296
|
+
break;
|
|
272
297
|
case CURLE_SEND_ERROR: /* 55 - failed sending network data */
|
|
273
298
|
exclz = eCurlErrSendError;
|
|
274
|
-
break;
|
|
299
|
+
break;
|
|
275
300
|
case CURLE_RECV_ERROR: /* 56 - failure in receiving network data */
|
|
276
301
|
exclz = eCurlErrRecvError;
|
|
277
|
-
break;
|
|
302
|
+
break;
|
|
278
303
|
case CURLE_SHARE_IN_USE: /* 57 - share is in use */
|
|
279
304
|
exclz = eCurlErrShareInUse;
|
|
280
|
-
break;
|
|
305
|
+
break;
|
|
281
306
|
case CURLE_SSL_CERTPROBLEM: /* 58 - problem with the local certificate */
|
|
282
307
|
exclz = eCurlErrSSLCertificate;
|
|
283
|
-
break;
|
|
308
|
+
break;
|
|
284
309
|
case CURLE_SSL_CIPHER: /* 59 - couldn't use specified cipher */
|
|
285
310
|
exclz = eCurlErrSSLCipher;
|
|
286
|
-
break;
|
|
311
|
+
break;
|
|
287
312
|
case CURLE_SSL_CACERT: /* 60 - problem with the CA cert (path?) */
|
|
288
313
|
exclz = eCurlErrSSLCACertificate;
|
|
289
|
-
break;
|
|
314
|
+
break;
|
|
290
315
|
case CURLE_BAD_CONTENT_ENCODING: /* 61 - Unrecognized transfer encoding */
|
|
291
316
|
exclz = eCurlErrBadContentEncoding;
|
|
292
|
-
break;
|
|
317
|
+
break;
|
|
293
318
|
case CURLE_LDAP_INVALID_URL: /* 62 - Invalid LDAP URL */
|
|
294
319
|
exclz = eCurlErrLDAPInvalidURL;
|
|
295
|
-
break;
|
|
320
|
+
break;
|
|
296
321
|
case CURLE_FILESIZE_EXCEEDED: /* 63 - Maximum file size exceeded */
|
|
297
322
|
exclz = eCurlErrFileSizeExceeded;
|
|
298
|
-
break;
|
|
323
|
+
break;
|
|
299
324
|
case CURLE_FTP_SSL_FAILED: /* 64 - Requested FTP SSL level failed */
|
|
300
325
|
exclz = eCurlErrFTPSSLFailed;
|
|
301
|
-
break;
|
|
326
|
+
break;
|
|
327
|
+
#ifdef HAVE_CURLE_SEND_FAIL_REWIND
|
|
302
328
|
case CURLE_SEND_FAIL_REWIND: /* 65 - Sending the data requires a rewind that failed */
|
|
303
329
|
exclz = eCurlErrSendFailedRewind;
|
|
304
|
-
break;
|
|
330
|
+
break;
|
|
331
|
+
#endif
|
|
332
|
+
#ifdef HAVE_CURLE_SSL_ENGINE_INITFAILED
|
|
305
333
|
case CURLE_SSL_ENGINE_INITFAILED: /* 66 - failed to initialise ENGINE */
|
|
306
334
|
exclz = eCurlErrSSLEngineInitFailed;
|
|
307
|
-
break;
|
|
335
|
+
break;
|
|
336
|
+
#endif
|
|
337
|
+
#ifdef HAVE_CURLE_LOGIN_DENIED
|
|
308
338
|
case CURLE_LOGIN_DENIED: /* 67 - user, password or similar was not accepted and we failed to login */
|
|
309
339
|
exclz = eCurlErrLoginDenied;
|
|
310
|
-
break;
|
|
311
|
-
|
|
340
|
+
break;
|
|
341
|
+
#endif
|
|
342
|
+
|
|
312
343
|
// recent additions, may not be present in all supported versions
|
|
313
|
-
#ifdef
|
|
344
|
+
#ifdef HAVE_CURLE_TFTP_NOTFOUND
|
|
314
345
|
case CURLE_TFTP_NOTFOUND: /* 68 - file not found on server */
|
|
315
346
|
exclz = eCurlErrTFTPNotFound;
|
|
316
|
-
break;
|
|
347
|
+
break;
|
|
317
348
|
#endif
|
|
318
|
-
#ifdef
|
|
349
|
+
#ifdef HAVE_CURLE_TFTP_PERM
|
|
319
350
|
case CURLE_TFTP_PERM: /* 69 - permission problem on server */
|
|
320
351
|
exclz = eCurlErrTFTPPermission;
|
|
321
352
|
break;
|
|
322
353
|
#endif
|
|
323
|
-
#ifdef
|
|
354
|
+
#ifdef HAVE_CURLE_TFTP_DISKFULL
|
|
324
355
|
case CURLE_TFTP_DISKFULL: /* 70 - out of disk space on server */
|
|
325
356
|
exclz = eCurlErrTFTPDiskFull;
|
|
326
|
-
break;
|
|
357
|
+
break;
|
|
327
358
|
#endif
|
|
328
|
-
#ifdef
|
|
359
|
+
#ifdef HAVE_CURLE_TFTP_ILLEGAL
|
|
329
360
|
case CURLE_TFTP_ILLEGAL: /* 71 - Illegal TFTP operation */
|
|
330
361
|
exclz = eCurlErrTFTPIllegalOperation;
|
|
331
|
-
break;
|
|
332
|
-
#endif
|
|
333
|
-
#ifdef
|
|
362
|
+
break;
|
|
363
|
+
#endif
|
|
364
|
+
#ifdef HAVE_CURLE_TFTP_UNKNOWNID
|
|
334
365
|
case CURLE_TFTP_UNKNOWNID: /* 72 - Unknown transfer ID */
|
|
335
366
|
exclz = eCurlErrTFTPUnknownID;
|
|
336
367
|
break;
|
|
337
368
|
#endif
|
|
338
|
-
#ifdef
|
|
369
|
+
#ifdef HAVE_CURLE_TFTP_EXISTS
|
|
339
370
|
case CURLE_TFTP_EXISTS: /* 73 - File already exists */
|
|
340
371
|
exclz = eCurlErrTFTPFileExists;
|
|
341
|
-
break;
|
|
372
|
+
break;
|
|
342
373
|
#endif
|
|
343
|
-
#ifdef
|
|
374
|
+
#ifdef HAVE_CURLE_TFTP_NOSUCHUSER
|
|
344
375
|
case CURLE_TFTP_NOSUCHUSER: /* 74 - No such user */
|
|
345
376
|
exclz = eCurlErrTFTPNotFound;
|
|
346
377
|
break;
|
|
378
|
+
#endif
|
|
379
|
+
#ifdef HAVE_CURLE_CONV_FAILED
|
|
380
|
+
case CURLE_CONV_FAILED: /* 75 - conversion failed */
|
|
381
|
+
exclz = eCurlErrConvFailed;
|
|
382
|
+
break;
|
|
383
|
+
#endif
|
|
384
|
+
#ifdef HAVE_CURLE_CONV_REQD
|
|
385
|
+
case CURLE_CONV_REQD: /* 76 - caller must register conversion
|
|
386
|
+
callbacks using curl_easy_setopt options
|
|
387
|
+
CURLOPT_CONV_FROM_NETWORK_FUNCTION,
|
|
388
|
+
CURLOPT_CONV_TO_NETWORK_FUNCTION, and
|
|
389
|
+
CURLOPT_CONV_FROM_UTF8_FUNCTION */
|
|
390
|
+
exclz = eCurlErrConvReqd;
|
|
391
|
+
break;
|
|
392
|
+
#endif
|
|
393
|
+
#ifdef HAVE_CURLE_SSL_CACERT_BADFILE
|
|
394
|
+
case CURLE_SSL_CACERT_BADFILE: /* 77 - could not load CACERT file, missing
|
|
395
|
+
or wrong format */
|
|
396
|
+
exclz = eCurlErrSSLCacertBadfile;
|
|
397
|
+
break;
|
|
398
|
+
#endif
|
|
399
|
+
#ifdef HAVE_CURLE_REMOTE_FILE_NOT_FOUND
|
|
400
|
+
case CURLE_REMOTE_FILE_NOT_FOUND: /* 78 - remote file not found */
|
|
401
|
+
exclz = eCurlErrRemoteFileNotFound;
|
|
402
|
+
break;
|
|
403
|
+
#endif
|
|
404
|
+
#ifdef HAVE_CURLE_SSH
|
|
405
|
+
case CURLE_SSH: /* 79 - error from the SSH layer, somewhat
|
|
406
|
+
generic so the error message will be of
|
|
407
|
+
interest when this has happened */
|
|
408
|
+
exclz = eCurlErrSSH;
|
|
409
|
+
break;
|
|
410
|
+
#endif
|
|
411
|
+
#ifdef HAVE_CURLE_SSL_SHUTDOWN_FAILED
|
|
412
|
+
case CURLE_SSL_SHUTDOWN_FAILED: /* 80 - Failed to shut down the SSL
|
|
413
|
+
connection */
|
|
414
|
+
exclz = eCurlErrSSLShutdownFailed;
|
|
415
|
+
break;
|
|
416
|
+
#endif
|
|
417
|
+
#ifdef HAVE_CURLE_AGAIN
|
|
418
|
+
case CURLE_AGAIN: /* 81 - socket is not ready for send/recv,
|
|
419
|
+
wait till it's ready and try again (Added
|
|
420
|
+
in 7.18.2) */
|
|
421
|
+
exclz = eCurlErrAgain;
|
|
422
|
+
break;
|
|
423
|
+
#endif
|
|
424
|
+
#ifdef HAVE_CURLE_SSL_CRL_BADFILE
|
|
425
|
+
case CURLE_SSL_CRL_BADFILE: /* 82 - could not load CRL file, missing or
|
|
426
|
+
wrong format (Added in 7.19.0) */
|
|
427
|
+
exclz = eCurlErrSSLCRLBadfile;
|
|
428
|
+
break;
|
|
429
|
+
#endif
|
|
430
|
+
#ifdef HAVE_CURLE_SSL_ISSUER_ERROR
|
|
431
|
+
case CURLE_SSL_ISSUER_ERROR: /* 83 - Issuer check failed. (Added in
|
|
432
|
+
7.19.0) */
|
|
433
|
+
exclz = eCurlErrSSLIssuerError;
|
|
434
|
+
break;
|
|
347
435
|
#endif
|
|
348
436
|
default:
|
|
349
437
|
exclz = eCurlErrError;
|
|
350
438
|
exmsg = "Unknown error result from libcurl";
|
|
351
439
|
}
|
|
352
|
-
|
|
440
|
+
|
|
353
441
|
if (!exmsg) {
|
|
354
442
|
exmsg = curl_easy_strerror(code);
|
|
355
443
|
}
|
|
356
|
-
|
|
357
|
-
|
|
444
|
+
|
|
445
|
+
results = rb_ary_new2(2);
|
|
446
|
+
rb_ary_push(results, exclz);
|
|
447
|
+
rb_ary_push(results, rb_str_new2(exmsg));
|
|
448
|
+
return results;
|
|
449
|
+
}
|
|
450
|
+
/* rb_raise an approriate exception for the supplied CURLcode */
|
|
451
|
+
void raise_curl_easy_error_exception(CURLcode code) {
|
|
452
|
+
VALUE obj = rb_curl_easy_error(code);
|
|
453
|
+
rb_raise(rb_ary_entry(obj,0), RSTRING_PTR(rb_ary_entry(obj,1)));
|
|
454
|
+
}
|
|
455
|
+
VALUE rb_curl_multi_error(CURLMcode code) {
|
|
456
|
+
VALUE exclz;
|
|
457
|
+
const char *exmsg = NULL;
|
|
458
|
+
VALUE results;
|
|
459
|
+
|
|
460
|
+
switch(code) {
|
|
461
|
+
case CURLM_CALL_MULTI_PERFORM: /* -1 */
|
|
462
|
+
exclz = mCurlErrCallMultiPerform;
|
|
463
|
+
break;
|
|
464
|
+
case CURLM_BAD_HANDLE: /* 1 */
|
|
465
|
+
exclz = mCurlErrBadHandle;
|
|
466
|
+
break;
|
|
467
|
+
case CURLM_BAD_EASY_HANDLE: /* 2 */
|
|
468
|
+
exclz = mCurlErrBadEasyHandle;
|
|
469
|
+
break;
|
|
470
|
+
case CURLM_OUT_OF_MEMORY: /* 3 */
|
|
471
|
+
exclz = mCurlErrOutOfMemory;
|
|
472
|
+
break;
|
|
473
|
+
case CURLM_INTERNAL_ERROR: /* 4 */
|
|
474
|
+
exclz = mCurlErrInternalError;
|
|
475
|
+
break;
|
|
476
|
+
#if HAVE_CURLM_BAD_SOCKET
|
|
477
|
+
case CURLM_BAD_SOCKET: /* 5 */
|
|
478
|
+
exclz = mCurlErrBadSocket;
|
|
479
|
+
break;
|
|
480
|
+
#endif
|
|
481
|
+
#if HAVE_CURLM_UNKNOWN_OPTION
|
|
482
|
+
case CURLM_UNKNOWN_OPTION: /* 6 */
|
|
483
|
+
exclz = mCurlErrUnknownOption;
|
|
484
|
+
break;
|
|
485
|
+
#endif
|
|
486
|
+
default:
|
|
487
|
+
exclz = eCurlErrError;
|
|
488
|
+
exmsg = "Unknown error result from libcurl";
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (!exmsg) {
|
|
492
|
+
exmsg = curl_multi_strerror(code);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
results = rb_ary_new2(2);
|
|
496
|
+
rb_ary_push(results, exclz);
|
|
497
|
+
rb_ary_push(results, rb_str_new2(exmsg));
|
|
498
|
+
|
|
499
|
+
return results;
|
|
500
|
+
}
|
|
501
|
+
void raise_curl_multi_error_exception(CURLMcode code) {
|
|
502
|
+
VALUE obj = rb_curl_multi_error(code);
|
|
503
|
+
rb_raise(rb_ary_entry(obj,0), RSTRING_PTR(rb_ary_entry(obj,1)));
|
|
358
504
|
}
|
|
359
505
|
|
|
360
506
|
void init_curb_errors() {
|
|
@@ -367,7 +513,8 @@ void init_curb_errors() {
|
|
|
367
513
|
eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
|
|
368
514
|
eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
|
|
369
515
|
eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
|
|
370
|
-
|
|
516
|
+
|
|
517
|
+
eCurlErrOK = rb_define_class_under(mCurlErr, "CurlOK", eCurlErrError);
|
|
371
518
|
eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
|
|
372
519
|
eCurlErrFailedInit = rb_define_class_under(mCurlErr, "FailedInitError", eCurlErrError);
|
|
373
520
|
eCurlErrMalformedURL = rb_define_class_under(mCurlErr, "MalformedURLError", eCurlErrError);
|
|
@@ -411,7 +558,7 @@ void init_curb_errors() {
|
|
|
411
558
|
|
|
412
559
|
eCurlErrHTTPRange = rb_define_class_under(mCurlErr, "HTTPRangeError", eCurlErrHTTPError);
|
|
413
560
|
eCurlErrHTTPPost = rb_define_class_under(mCurlErr, "HTTPPostError", eCurlErrHTTPError);
|
|
414
|
-
|
|
561
|
+
|
|
415
562
|
eCurlErrSSLConnectError = rb_define_class_under(mCurlErr, "SSLConnectError", eCurlErrError);
|
|
416
563
|
eCurlErrBadResume = rb_define_class_under(mCurlErr, "BadResumeError", eCurlErrError);
|
|
417
564
|
|
|
@@ -432,7 +579,7 @@ void init_curb_errors() {
|
|
|
432
579
|
|
|
433
580
|
eCurlErrTelnetUnknownOption = rb_define_class_under(mCurlErr, "UnknownOptionError", eCurlErrTelnetError);
|
|
434
581
|
eCurlErrTelnetBadOptionSyntax = rb_define_class_under(mCurlErr, "BadOptionSyntaxError", eCurlErrTelnetError);
|
|
435
|
-
|
|
582
|
+
|
|
436
583
|
eCurlErrObsolete = rb_define_class_under(mCurlErr, "ObsoleteError", eCurlErrError);
|
|
437
584
|
eCurlErrSSLPeerCertificate = rb_define_class_under(mCurlErr, "SSLPeerCertificateError", eCurlErrError);
|
|
438
585
|
eCurlErrGotNothing = rb_define_class_under(mCurlErr, "GotNothingError", eCurlErrError);
|
|
@@ -444,10 +591,29 @@ void init_curb_errors() {
|
|
|
444
591
|
eCurlErrRecvError = rb_define_class_under(mCurlErr, "RecvError", eCurlErrError);
|
|
445
592
|
eCurlErrShareInUse = rb_define_class_under(mCurlErr, "ShareInUseError", eCurlErrError);
|
|
446
593
|
|
|
594
|
+
eCurlErrConvFailed = rb_define_class_under(mCurlErr, "ConvFailed", eCurlErrError);
|
|
595
|
+
eCurlErrConvReqd = rb_define_class_under(mCurlErr, "ConvReqd", eCurlErrError);
|
|
596
|
+
eCurlErrRemoteFileNotFound = rb_define_class_under(mCurlErr, "RemoteFileNotFound", eCurlErrError);
|
|
597
|
+
eCurlErrAgain = rb_define_class_under(mCurlErr, "Again", eCurlErrError);
|
|
598
|
+
|
|
447
599
|
eCurlErrSSLCertificate = rb_define_class_under(mCurlErr, "SSLCertificateError", eCurlErrError);
|
|
448
600
|
eCurlErrSSLCipher = rb_define_class_under(mCurlErr, "SSLCypherError", eCurlErrError);
|
|
449
601
|
eCurlErrSSLCACertificate = rb_define_class_under(mCurlErr, "SSLCACertificateError", eCurlErrError);
|
|
450
602
|
eCurlErrBadContentEncoding = rb_define_class_under(mCurlErr, "BadContentEncodingError", eCurlErrError);
|
|
603
|
+
eCurlErrSSLCacertBadfile = rb_define_class_under(mCurlErr, "SSLCaertBadFile", eCurlErrError);
|
|
604
|
+
eCurlErrSSLCRLBadfile = rb_define_class_under(mCurlErr, "SSLCRLBadfile", eCurlErrError);
|
|
605
|
+
eCurlErrSSLIssuerError = rb_define_class_under(mCurlErr, "SSLIssuerError", eCurlErrError);
|
|
606
|
+
eCurlErrSSLShutdownFailed = rb_define_class_under(mCurlErr, "SSLShutdownFailed", eCurlErrError);
|
|
607
|
+
eCurlErrSSH = rb_define_class_under(mCurlErr, "SSH", eCurlErrError);
|
|
608
|
+
|
|
609
|
+
mCurlErrFailedInit = rb_define_class_under(mCurlErr, "MultiInitError", eCurlErrError);
|
|
610
|
+
mCurlErrCallMultiPerform = rb_define_class_under(mCurlErr, "MultiPerform", eCurlErrError);
|
|
611
|
+
mCurlErrBadHandle = rb_define_class_under(mCurlErr, "MultiBadHandle", eCurlErrError);
|
|
612
|
+
mCurlErrBadEasyHandle = rb_define_class_under(mCurlErr, "MultiBadEasyHandle", eCurlErrError);
|
|
613
|
+
mCurlErrOutOfMemory = rb_define_class_under(mCurlErr, "MultiOutOfMemory", eCurlErrError);
|
|
614
|
+
mCurlErrInternalError = rb_define_class_under(mCurlErr, "MultiInternalError", eCurlErrError);
|
|
615
|
+
mCurlErrBadSocket = rb_define_class_under(mCurlErr, "MultiBadSocket", eCurlErrError);
|
|
616
|
+
mCurlErrUnknownOption = rb_define_class_under(mCurlErr, "MultiUnknownOption", eCurlErrError);
|
|
451
617
|
|
|
452
618
|
eCurlErrLDAPInvalidURL = rb_define_class_under(mCurlErr, "InvalidLDAPURLError", eCurlErrLDAPError);
|
|
453
619
|
|
|
@@ -466,6 +632,6 @@ void init_curb_errors() {
|
|
|
466
632
|
eCurlErrTFTPUnknownID = rb_define_class_under(mCurlErr, "UnknownIDError", eCurlErrTFTPError);
|
|
467
633
|
eCurlErrTFTPFileExists = rb_define_class_under(mCurlErr, "FileExistsError", eCurlErrTFTPError);
|
|
468
634
|
eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);
|
|
469
|
-
|
|
635
|
+
|
|
470
636
|
eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError);
|
|
471
|
-
}
|
|
637
|
+
}
|