curb 0.3.7 → 0.4.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of curb might be problematic. Click here for more details.

@@ -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
@@ -17,13 +17,13 @@
17
17
  typedef struct {
18
18
  /* The handler */
19
19
  CURL *curl;
20
-
20
+
21
21
  /* Objects we associate */
22
- VALUE url;
22
+ VALUE url;
23
23
  VALUE proxy_url;
24
-
24
+
25
25
  VALUE body_proc;
26
- VALUE header_proc;
26
+ VALUE header_proc;
27
27
  VALUE body_data; /* Holds the response body from the last call to curl_easy_perform */
28
28
  VALUE header_data; /* unless a block is supplied (they'll be nil) */
29
29
  VALUE progress_proc;
@@ -45,7 +45,7 @@ typedef struct {
45
45
  /* Other opts */
46
46
  unsigned short local_port; // 0 is no port
47
47
  unsigned short local_port_range; // " " " "
48
- unsigned short proxy_port; // " " " "
48
+ unsigned short proxy_port; // " " " "
49
49
  int proxy_type;
50
50
  long http_auth_types;
51
51
  long proxy_auth_types;
@@ -55,7 +55,7 @@ typedef struct {
55
55
  long dns_cache_timeout;
56
56
  unsigned long ftp_response_timeout;
57
57
 
58
- /* bool flags */
58
+ /* bool flags */
59
59
  char proxy_tunnel;
60
60
  char fetch_file_time;
61
61
  char ssl_verify_peer;
@@ -64,15 +64,15 @@ typedef struct {
64
64
  char use_netrc;
65
65
  char follow_location;
66
66
  char unrestricted_auth;
67
- char verbose;
67
+ char verbose;
68
68
  char multipart_form_post;
69
69
  char enable_cookies;
70
-
70
+
71
71
  /* this is sometimes used as a buffer for a form data string,
72
72
  * which we alloc in C and need to hang around for the call,
73
73
  * and in case it's asked for before the next call.
74
74
  */
75
- VALUE postdata_buffer;
75
+ VALUE postdata_buffer;
76
76
 
77
77
  /* when added to a multi handle these buffers are needed
78
78
  * when the easy handle isn't supplied the body proc
@@ -83,6 +83,7 @@ typedef struct {
83
83
  struct curl_slist *curl_headers;
84
84
 
85
85
  VALUE self; /* pointer to self, used by multi interface */
86
+ VALUE upload; /* pointer to an active upload otherwise Qnil */
86
87
 
87
88
  } ruby_curl_easy;
88
89
 
@@ -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"
@@ -125,201 +125,201 @@ VALUE eCurlErrInvalidPostField;
125
125
  void raise_curl_easy_error_exception(CURLcode code) {
126
126
  VALUE exclz;
127
127
  const char *exmsg = NULL;
128
-
128
+
129
129
  switch (code) {
130
130
  case CURLE_UNSUPPORTED_PROTOCOL: /* 1 */
131
131
  exclz = eCurlErrUnsupportedProtocol;
132
- break;
132
+ break;
133
133
  case CURLE_FAILED_INIT: /* 2 */
134
134
  exclz = eCurlErrFailedInit;
135
135
  break;
136
136
  case CURLE_URL_MALFORMAT: /* 3 */
137
137
  exclz = eCurlErrMalformedURL;
138
- break;
138
+ break;
139
139
  case CURLE_URL_MALFORMAT_USER: /* 4 (NOT USED) */
140
140
  exclz = eCurlErrMalformedURLUser;
141
- break;
141
+ break;
142
142
  case CURLE_COULDNT_RESOLVE_PROXY: /* 5 */
143
143
  exclz = eCurlErrProxyResolution;
144
- break;
144
+ break;
145
145
  case CURLE_COULDNT_RESOLVE_HOST: /* 6 */
146
146
  exclz = eCurlErrHostResolution;
147
- break;
147
+ break;
148
148
  case CURLE_COULDNT_CONNECT: /* 7 */
149
149
  exclz = eCurlErrConnectFailed;
150
- break;
150
+ break;
151
151
  case CURLE_FTP_WEIRD_SERVER_REPLY: /* 8 */
152
152
  exclz = eCurlErrFTPWierdReply;
153
- break;
153
+ break;
154
154
  case CURLE_FTP_ACCESS_DENIED: /* 9 denied due to lack of access. */
155
155
  exclz = eCurlErrFTPAccessDenied;
156
- break;
156
+ break;
157
157
  case CURLE_FTP_USER_PASSWORD_INCORRECT: /* 10 */
158
158
  exclz = eCurlErrFTPBadPassword;
159
- break;
159
+ break;
160
160
  case CURLE_FTP_WEIRD_PASS_REPLY: /* 11 */
161
161
  exclz = eCurlErrFTPWierdPassReply;
162
- break;
162
+ break;
163
163
  case CURLE_FTP_WEIRD_USER_REPLY: /* 12 */
164
164
  exclz = eCurlErrFTPWierdUserReply;
165
- break;
165
+ break;
166
166
  case CURLE_FTP_WEIRD_PASV_REPLY: /* 13 */
167
167
  exclz = eCurlErrFTPWierdPasvReply;
168
- break;
168
+ break;
169
169
  case CURLE_FTP_WEIRD_227_FORMAT: /* 14 */
170
170
  exclz = eCurlErrFTPWierd227Format;
171
- break;
171
+ break;
172
172
  case CURLE_FTP_CANT_GET_HOST: /* 15 */
173
173
  exclz = eCurlErrFTPCantGetHost;
174
- break;
174
+ break;
175
175
  case CURLE_FTP_CANT_RECONNECT: /* 16 */
176
176
  exclz = eCurlErrFTPCantReconnect;
177
- break;
177
+ break;
178
178
  case CURLE_FTP_COULDNT_SET_BINARY: /* 17 */
179
179
  exclz = eCurlErrFTPCouldntSetBinary;
180
- break;
180
+ break;
181
181
  case CURLE_PARTIAL_FILE: /* 18 */
182
182
  exclz = eCurlErrPartialFile;
183
- break;
183
+ break;
184
184
  case CURLE_FTP_COULDNT_RETR_FILE: /* 19 */
185
185
  exclz = eCurlErrFTPCouldntRetrFile;
186
- break;
186
+ break;
187
187
  case CURLE_FTP_WRITE_ERROR: /* 20 */
188
188
  exclz = eCurlErrFTPWrite;
189
- break;
189
+ break;
190
190
  case CURLE_FTP_QUOTE_ERROR: /* 21 */
191
191
  exclz = eCurlErrFTPQuote;
192
- break;
192
+ break;
193
193
  case CURLE_HTTP_RETURNED_ERROR: /* 22 */
194
194
  exclz = eCurlErrHTTPFailed;
195
- break;
195
+ break;
196
196
  case CURLE_WRITE_ERROR: /* 23 */
197
197
  exclz = eCurlErrWriteError;
198
- break;
198
+ break;
199
199
  case CURLE_MALFORMAT_USER: /* 24 - NOT USED */
200
200
  exclz = eCurlErrMalformedUser;
201
- break;
201
+ break;
202
202
  case CURLE_FTP_COULDNT_STOR_FILE: /* 25 - failed FTP upload */
203
203
  exclz = eCurlErrFTPCouldntStorFile;
204
- break;
204
+ break;
205
205
  case CURLE_READ_ERROR: /* 26 - could open/read from file */
206
206
  exclz = eCurlErrReadError;
207
- break;
207
+ break;
208
208
  case CURLE_OUT_OF_MEMORY: /* 27 */
209
209
  exclz = eCurlErrOutOfMemory;
210
- break;
210
+ break;
211
211
  case CURLE_OPERATION_TIMEOUTED: /* 28 - the timeout time was reached */
212
212
  exclz = eCurlErrTimeout;
213
- break;
213
+ break;
214
214
  case CURLE_FTP_COULDNT_SET_ASCII: /* 29 - TYPE A failed */
215
215
  exclz = eCurlErrFTPCouldntSetASCII;
216
- break;
216
+ break;
217
217
  case CURLE_FTP_PORT_FAILED: /* 30 - FTP PORT operation failed */
218
218
  exclz = eCurlErrFTPPortFailed;
219
- break;
219
+ break;
220
220
  case CURLE_FTP_COULDNT_USE_REST: /* 31 - the REST command failed */
221
221
  exclz = eCurlErrFTPCouldntUseRest;
222
- break;
222
+ break;
223
223
  case CURLE_FTP_COULDNT_GET_SIZE: /* 32 - the SIZE command failed */
224
224
  exclz = eCurlErrFTPCouldntGetSize;
225
- break;
225
+ break;
226
226
  case CURLE_HTTP_RANGE_ERROR: /* 33 - RANGE "command" didn't work */
227
227
  exclz = eCurlErrHTTPRange;
228
- break;
228
+ break;
229
229
  case CURLE_HTTP_POST_ERROR: /* 34 */
230
230
  exclz = eCurlErrHTTPPost;
231
- break;
231
+ break;
232
232
  case CURLE_SSL_CONNECT_ERROR: /* 35 - wrong when connecting with SSL */
233
233
  exclz = eCurlErrSSLConnectError;
234
- break;
234
+ break;
235
235
  case CURLE_BAD_DOWNLOAD_RESUME: /* 36 - couldn't resume download */
236
236
  exclz = eCurlErrBadResume;
237
- break;
237
+ break;
238
238
  case CURLE_FILE_COULDNT_READ_FILE: /* 37 */
239
239
  exclz = eCurlErrFileCouldntRead;
240
- break;
240
+ break;
241
241
  case CURLE_LDAP_CANNOT_BIND: /* 38 */
242
242
  exclz = eCurlErrLDAPCouldntBind;
243
- break;
243
+ break;
244
244
  case CURLE_LDAP_SEARCH_FAILED: /* 39 */
245
245
  exclz = eCurlErrLDAPSearchFailed;
246
- break;
246
+ break;
247
247
  case CURLE_LIBRARY_NOT_FOUND: /* 40 */
248
248
  exclz = eCurlErrLibraryNotFound;
249
- break;
249
+ break;
250
250
  case CURLE_FUNCTION_NOT_FOUND: /* 41 */
251
251
  exclz = eCurlErrFunctionNotFound;
252
- break;
252
+ break;
253
253
  case CURLE_ABORTED_BY_CALLBACK: /* 42 */
254
254
  exclz = eCurlErrAbortedByCallback;
255
- break;
255
+ break;
256
256
  case CURLE_BAD_FUNCTION_ARGUMENT: /* 43 */
257
257
  exclz = eCurlErrBadFunctionArgument;
258
- break;
258
+ break;
259
259
  case CURLE_BAD_CALLING_ORDER: /* 44 - NOT USED */
260
260
  exclz = eCurlErrBadCallingOrder;
261
- break;
261
+ break;
262
262
  case CURLE_INTERFACE_FAILED: /* 45 - CURLOPT_INTERFACE failed */
263
263
  exclz = eCurlErrInterfaceFailed;
264
- break;
264
+ break;
265
265
  case CURLE_BAD_PASSWORD_ENTERED: /* 46 - NOT USED */
266
266
  exclz = eCurlErrBadPasswordEntered;
267
- break;
267
+ break;
268
268
  case CURLE_TOO_MANY_REDIRECTS: /* 47 - catch endless re-direct loops */
269
269
  exclz = eCurlErrTooManyRedirects;
270
- break;
270
+ break;
271
271
  case CURLE_UNKNOWN_TELNET_OPTION: /* 48 - User specified an unknown option */
272
272
  exclz = eCurlErrTelnetUnknownOption;
273
- break;
273
+ break;
274
274
  case CURLE_TELNET_OPTION_SYNTAX: /* 49 - Malformed telnet option */
275
275
  exclz = eCurlErrTelnetBadOptionSyntax;
276
- break;
276
+ break;
277
277
  case CURLE_OBSOLETE: /* 50 - NOT USED */
278
278
  exclz = eCurlErrObsolete;
279
- break;
279
+ break;
280
280
  case CURLE_SSL_PEER_CERTIFICATE: /* 51 - peer's certificate wasn't ok */
281
281
  exclz = eCurlErrSSLPeerCertificate;
282
- break;
282
+ break;
283
283
  case CURLE_GOT_NOTHING: /* 52 - when this is a specific error */
284
284
  exclz = eCurlErrGotNothing;
285
- break;
285
+ break;
286
286
  case CURLE_SSL_ENGINE_NOTFOUND: /* 53 - SSL crypto engine not found */
287
287
  exclz = eCurlErrSSLEngineNotFound;
288
- break;
288
+ break;
289
289
  case CURLE_SSL_ENGINE_SETFAILED: /* 54 - can not set SSL crypto engine as default */
290
290
  exclz = eCurlErrSSLEngineSetFailed;
291
- break;
291
+ break;
292
292
  case CURLE_SEND_ERROR: /* 55 - failed sending network data */
293
293
  exclz = eCurlErrSendError;
294
- break;
294
+ break;
295
295
  case CURLE_RECV_ERROR: /* 56 - failure in receiving network data */
296
296
  exclz = eCurlErrRecvError;
297
- break;
297
+ break;
298
298
  case CURLE_SHARE_IN_USE: /* 57 - share is in use */
299
299
  exclz = eCurlErrShareInUse;
300
- break;
300
+ break;
301
301
  case CURLE_SSL_CERTPROBLEM: /* 58 - problem with the local certificate */
302
302
  exclz = eCurlErrSSLCertificate;
303
- break;
303
+ break;
304
304
  case CURLE_SSL_CIPHER: /* 59 - couldn't use specified cipher */
305
305
  exclz = eCurlErrSSLCipher;
306
- break;
306
+ break;
307
307
  case CURLE_SSL_CACERT: /* 60 - problem with the CA cert (path?) */
308
308
  exclz = eCurlErrSSLCACertificate;
309
- break;
309
+ break;
310
310
  case CURLE_BAD_CONTENT_ENCODING: /* 61 - Unrecognized transfer encoding */
311
311
  exclz = eCurlErrBadContentEncoding;
312
- break;
312
+ break;
313
313
  case CURLE_LDAP_INVALID_URL: /* 62 - Invalid LDAP URL */
314
314
  exclz = eCurlErrLDAPInvalidURL;
315
- break;
315
+ break;
316
316
  case CURLE_FILESIZE_EXCEEDED: /* 63 - Maximum file size exceeded */
317
317
  exclz = eCurlErrFileSizeExceeded;
318
- break;
318
+ break;
319
319
  case CURLE_FTP_SSL_FAILED: /* 64 - Requested FTP SSL level failed */
320
320
  exclz = eCurlErrFTPSSLFailed;
321
- break;
322
- #ifdef HAVE_CURLE_SEND_FAIL_REWIND
321
+ break;
322
+ #ifdef HAVE_CURLE_SEND_FAIL_REWIND
323
323
  case CURLE_SEND_FAIL_REWIND: /* 65 - Sending the data requires a rewind that failed */
324
324
  exclz = eCurlErrSendFailedRewind;
325
325
  break;
@@ -327,21 +327,21 @@ void raise_curl_easy_error_exception(CURLcode code) {
327
327
  #ifdef HAVE_CURLE_SSL_ENGINE_INITFAILED
328
328
  case CURLE_SSL_ENGINE_INITFAILED: /* 66 - failed to initialise ENGINE */
329
329
  exclz = eCurlErrSSLEngineInitFailed;
330
- break;
330
+ break;
331
331
  #endif
332
332
  #ifdef HAVE_CURLE_LOGIN_DENIED
333
333
  case CURLE_LOGIN_DENIED: /* 67 - user, password or similar was not accepted and we failed to login */
334
334
  exclz = eCurlErrLoginDenied;
335
- break;
335
+ break;
336
336
  #endif
337
-
337
+
338
338
  // recent additions, may not be present in all supported versions
339
339
  #ifdef HAVE_CURLE_TFTP_NOTFOUND
340
340
  case CURLE_TFTP_NOTFOUND: /* 68 - file not found on server */
341
341
  exclz = eCurlErrTFTPNotFound;
342
- break;
342
+ break;
343
343
  #endif
344
- #ifdef HAVE_CURLE_TFTP_PERM
344
+ #ifdef HAVE_CURLE_TFTP_PERM
345
345
  case CURLE_TFTP_PERM: /* 69 - permission problem on server */
346
346
  exclz = eCurlErrTFTPPermission;
347
347
  break;
@@ -349,13 +349,13 @@ void raise_curl_easy_error_exception(CURLcode code) {
349
349
  #ifdef HAVE_CURLE_TFTP_DISKFULL
350
350
  case CURLE_TFTP_DISKFULL: /* 70 - out of disk space on server */
351
351
  exclz = eCurlErrTFTPDiskFull;
352
- break;
352
+ break;
353
353
  #endif
354
354
  #ifdef HAVE_CURLE_TFTP_ILLEGAL
355
355
  case CURLE_TFTP_ILLEGAL: /* 71 - Illegal TFTP operation */
356
356
  exclz = eCurlErrTFTPIllegalOperation;
357
- break;
358
- #endif
357
+ break;
358
+ #endif
359
359
  #ifdef HAVE_CURLE_TFTP_UNKNOWNID
360
360
  case CURLE_TFTP_UNKNOWNID: /* 72 - Unknown transfer ID */
361
361
  exclz = eCurlErrTFTPUnknownID;
@@ -364,7 +364,7 @@ void raise_curl_easy_error_exception(CURLcode code) {
364
364
  #ifdef HAVE_CURLE_TFTP_EXISTS
365
365
  case CURLE_TFTP_EXISTS: /* 73 - File already exists */
366
366
  exclz = eCurlErrTFTPFileExists;
367
- break;
367
+ break;
368
368
  #endif
369
369
  #ifdef HAVE_CURLE_TFTP_NOSUCHUSER
370
370
  case CURLE_TFTP_NOSUCHUSER: /* 74 - No such user */
@@ -432,11 +432,11 @@ void raise_curl_easy_error_exception(CURLcode code) {
432
432
  exclz = eCurlErrError;
433
433
  exmsg = "Unknown error result from libcurl";
434
434
  }
435
-
435
+
436
436
  if (!exmsg) {
437
437
  exmsg = curl_easy_strerror(code);
438
438
  }
439
-
439
+
440
440
  rb_raise(exclz, exmsg);
441
441
  }
442
442
  void raise_curl_multi_error_exception(CURLMcode code) {
@@ -473,7 +473,7 @@ void raise_curl_multi_error_exception(CURLMcode code) {
473
473
  exclz = eCurlErrError;
474
474
  exmsg = "Unknown error result from libcurl";
475
475
  }
476
-
476
+
477
477
  if (!exmsg) {
478
478
  exmsg = curl_multi_strerror(code);
479
479
  }
@@ -491,7 +491,7 @@ void init_curb_errors() {
491
491
  eCurlErrLDAPError = rb_define_class_under(mCurlErr, "LDAPError", eCurlErrError);
492
492
  eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
493
493
  eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
494
-
494
+
495
495
  eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
496
496
  eCurlErrFailedInit = rb_define_class_under(mCurlErr, "FailedInitError", eCurlErrError);
497
497
  eCurlErrMalformedURL = rb_define_class_under(mCurlErr, "MalformedURLError", eCurlErrError);
@@ -535,7 +535,7 @@ void init_curb_errors() {
535
535
 
536
536
  eCurlErrHTTPRange = rb_define_class_under(mCurlErr, "HTTPRangeError", eCurlErrHTTPError);
537
537
  eCurlErrHTTPPost = rb_define_class_under(mCurlErr, "HTTPPostError", eCurlErrHTTPError);
538
-
538
+
539
539
  eCurlErrSSLConnectError = rb_define_class_under(mCurlErr, "SSLConnectError", eCurlErrError);
540
540
  eCurlErrBadResume = rb_define_class_under(mCurlErr, "BadResumeError", eCurlErrError);
541
541
 
@@ -556,7 +556,7 @@ void init_curb_errors() {
556
556
 
557
557
  eCurlErrTelnetUnknownOption = rb_define_class_under(mCurlErr, "UnknownOptionError", eCurlErrTelnetError);
558
558
  eCurlErrTelnetBadOptionSyntax = rb_define_class_under(mCurlErr, "BadOptionSyntaxError", eCurlErrTelnetError);
559
-
559
+
560
560
  eCurlErrObsolete = rb_define_class_under(mCurlErr, "ObsoleteError", eCurlErrError);
561
561
  eCurlErrSSLPeerCertificate = rb_define_class_under(mCurlErr, "SSLPeerCertificateError", eCurlErrError);
562
562
  eCurlErrGotNothing = rb_define_class_under(mCurlErr, "GotNothingError", eCurlErrError);
@@ -600,6 +600,6 @@ void init_curb_errors() {
600
600
  eCurlErrTFTPUnknownID = rb_define_class_under(mCurlErr, "UnknownIDError", eCurlErrTFTPError);
601
601
  eCurlErrTFTPFileExists = rb_define_class_under(mCurlErr, "FileExistsError", eCurlErrTFTPError);
602
602
  eCurlErrTFTPNoSuchUser = rb_define_class_under(mCurlErr, "NoSuchUserError", eCurlErrTFTPError);
603
-
603
+
604
604
  eCurlErrInvalidPostField = rb_define_class_under(mCurlErr, "InvalidPostFieldError", eCurlErrError);
605
- }
605
+ }