taf2-curb 0.4.0.0 → 0.4.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/curb.c CHANGED
@@ -1,10 +1,10 @@
1
1
  /* Curb - Libcurl(3) bindings for Ruby.
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.c 35 2006-12-23 15:22:19Z roscopeco $
6
6
  */
7
-
7
+
8
8
  #include "curb.h"
9
9
 
10
10
  VALUE mCurl;
@@ -14,36 +14,36 @@ VALUE mCurl;
14
14
  /*
15
15
  * call-seq:
16
16
  * Curl.ipv6? => true or false
17
- *
18
- * Returns true if the installed libcurl supports IPv6.
17
+ *
18
+ * Returns true if the installed libcurl supports IPv6.
19
19
  */
20
20
  static VALUE ruby_curl_ipv6_q(VALUE mod) {
21
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
21
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
22
22
  return((ver->features & CURL_VERSION_IPV6) ? Qtrue : Qfalse);
23
23
  }
24
24
 
25
25
  /*
26
26
  * call-seq:
27
27
  * Curl.kerberos4? => true or false
28
- *
28
+ *
29
29
  * Returns true if the installed libcurl supports Kerberos4 authentication
30
- * with FTP connections.
30
+ * with FTP connections.
31
31
  */
32
32
  static VALUE ruby_curl_kerberos4_q(VALUE mod) {
33
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
33
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
34
34
  return((ver->features & CURL_VERSION_KERBEROS4) ? Qtrue : Qfalse);
35
35
  }
36
36
 
37
37
  /*
38
38
  * call-seq:
39
39
  * Curl.ssl? => true or false
40
- *
40
+ *
41
41
  * Returns true if the installed libcurl supports SSL connections.
42
42
  * For libcurl versions < 7.10, always returns false.
43
43
  */
44
44
  static VALUE ruby_curl_ssl_q(VALUE mod) {
45
45
  #ifdef HAVE_CURL_VERSION_SSL
46
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
46
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
47
47
  return((ver->features & CURL_VERSION_SSL) ? Qtrue : Qfalse);
48
48
  #else
49
49
  return Qfalse;
@@ -53,13 +53,13 @@ static VALUE ruby_curl_ssl_q(VALUE mod) {
53
53
  /*
54
54
  * call-seq:
55
55
  * Curl.libz? => true or false
56
- *
56
+ *
57
57
  * Returns true if the installed libcurl supports HTTP deflate
58
58
  * using libz. For libcurl versions < 7.10, always returns false.
59
59
  */
60
60
  static VALUE ruby_curl_libz_q(VALUE mod) {
61
61
  #ifdef HAVE_CURL_VERSION_LIBZ
62
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
62
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
63
63
  return((ver->features & CURL_VERSION_LIBZ) ? Qtrue : Qfalse);
64
64
  #else
65
65
  return Qfalse;
@@ -69,13 +69,13 @@ static VALUE ruby_curl_libz_q(VALUE mod) {
69
69
  /*
70
70
  * call-seq:
71
71
  * Curl.ntlm? => true or false
72
- *
72
+ *
73
73
  * Returns true if the installed libcurl supports HTTP NTLM.
74
74
  * For libcurl versions < 7.10.6, always returns false.
75
75
  */
76
76
  static VALUE ruby_curl_ntlm_q(VALUE mod) {
77
77
  #ifdef HAVE_CURL_VERSION_NTLM
78
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
78
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
79
79
  return((ver->features & CURL_VERSION_NTLM) ? Qtrue : Qfalse);
80
80
  #else
81
81
  return Qfalse;
@@ -85,13 +85,13 @@ static VALUE ruby_curl_ntlm_q(VALUE mod) {
85
85
  /*
86
86
  * call-seq:
87
87
  * Curl.gssnegotiate? => true or false
88
- *
88
+ *
89
89
  * Returns true if the installed libcurl supports HTTP GSS-Negotiate.
90
90
  * For libcurl versions < 7.10.6, always returns false.
91
91
  */
92
92
  static VALUE ruby_curl_gssnegotiate_q(VALUE mod) {
93
93
  #ifdef HAVE_CURL_VERSION_GSSNEGOTIATE
94
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
94
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
95
95
  return((ver->features & CURL_VERSION_GSSNEGOTIATE) ? Qtrue : Qfalse);
96
96
  #else
97
97
  return Qfalse;
@@ -101,14 +101,14 @@ static VALUE ruby_curl_gssnegotiate_q(VALUE mod) {
101
101
  /*
102
102
  * call-seq:
103
103
  * Curl.debug? => true or false
104
- *
105
- * Returns true if the installed libcurl was built with extra debug
104
+ *
105
+ * Returns true if the installed libcurl was built with extra debug
106
106
  * capabilities built-in. For libcurl versions < 7.10.6, always returns
107
107
  * false.
108
108
  */
109
109
  static VALUE ruby_curl_debug_q(VALUE mod) {
110
110
  #ifdef HAVE_CURL_VERSION_DEBUG
111
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
111
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
112
112
  return((ver->features & CURL_VERSION_DEBUG) ? Qtrue : Qfalse);
113
113
  #else
114
114
  return Qfalse;
@@ -118,7 +118,7 @@ static VALUE ruby_curl_debug_q(VALUE mod) {
118
118
  /*
119
119
  * call-seq:
120
120
  * Curl.asyncdns? => true or false
121
- *
121
+ *
122
122
  * Returns true if the installed libcurl was built with support for
123
123
  * asynchronous name lookups, which allows more exact timeouts (even
124
124
  * on Windows) and less blocking when using the multi interface.
@@ -126,7 +126,7 @@ static VALUE ruby_curl_debug_q(VALUE mod) {
126
126
  */
127
127
  static VALUE ruby_curl_asyncdns_q(VALUE mod) {
128
128
  #ifdef HAVE_CURL_VERSION_ASYNCHDNS
129
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
129
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
130
130
  return((ver->features & CURL_VERSION_ASYNCHDNS) ? Qtrue : Qfalse);
131
131
  #else
132
132
  return Qfalse;
@@ -136,14 +136,14 @@ static VALUE ruby_curl_asyncdns_q(VALUE mod) {
136
136
  /*
137
137
  * call-seq:
138
138
  * Curl.spnego? => true or false
139
- *
139
+ *
140
140
  * Returns true if the installed libcurl was built with support for SPNEGO
141
141
  * authentication (Simple and Protected GSS-API Negotiation Mechanism, defined
142
142
  * in RFC 2478). For libcurl versions < 7.10.8, always returns false.
143
143
  */
144
144
  static VALUE ruby_curl_spnego_q(VALUE mod) {
145
145
  #ifdef HAVE_CURL_VERSION_SPNEGO
146
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
146
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
147
147
  return((ver->features & CURL_VERSION_SPNEGO) ? Qtrue : Qfalse);
148
148
  #else
149
149
  return Qfalse;
@@ -153,13 +153,13 @@ static VALUE ruby_curl_spnego_q(VALUE mod) {
153
153
  /*
154
154
  * call-seq:
155
155
  * Curl.largefile? => true or false
156
- *
156
+ *
157
157
  * Returns true if the installed libcurl was built with support for large
158
158
  * files. For libcurl versions < 7.11.1, always returns false.
159
159
  */
160
160
  static VALUE ruby_curl_largefile_q(VALUE mod) {
161
161
  #ifdef HAVE_CURL_VERSION_LARGEFILE
162
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
162
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
163
163
  return((ver->features & CURL_VERSION_LARGEFILE) ? Qtrue : Qfalse);
164
164
  #else
165
165
  return Qfalse;
@@ -169,14 +169,14 @@ static VALUE ruby_curl_largefile_q(VALUE mod) {
169
169
  /*
170
170
  * call-seq:
171
171
  * Curl.idn? => true or false
172
- *
173
- * Returns true if the installed libcurl was built with support for IDNA,
174
- * domain names with international letters. For libcurl versions < 7.12.0,
172
+ *
173
+ * Returns true if the installed libcurl was built with support for IDNA,
174
+ * domain names with international letters. For libcurl versions < 7.12.0,
175
175
  * always returns false.
176
176
  */
177
177
  static VALUE ruby_curl_idn_q(VALUE mod) {
178
178
  #ifdef HAVE_CURL_VERSION_IDN
179
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
179
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
180
180
  return((ver->features & CURL_VERSION_IDN) ? Qtrue : Qfalse);
181
181
  #else
182
182
  return Qfalse;
@@ -186,16 +186,16 @@ static VALUE ruby_curl_idn_q(VALUE mod) {
186
186
  /*
187
187
  * call-seq:
188
188
  * Curl.sspi? => true or false
189
- *
189
+ *
190
190
  * Returns true if the installed libcurl was built with support for SSPI.
191
191
  * This is only available on Windows and makes libcurl use Windows-provided
192
192
  * functions for NTLM authentication. It also allows libcurl to use the current
193
- * user and the current user's password without the app having to pass them on.
193
+ * user and the current user's password without the app having to pass them on.
194
194
  * For libcurl versions < 7.13.2, always returns false.
195
195
  */
196
196
  static VALUE ruby_curl_sspi_q(VALUE mod) {
197
197
  #ifdef HAVE_CURL_VERSION_SSPI
198
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
198
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
199
199
  return((ver->features & CURL_VERSION_SSPI) ? Qtrue : Qfalse);
200
200
  #else
201
201
  return Qfalse;
@@ -205,13 +205,13 @@ static VALUE ruby_curl_sspi_q(VALUE mod) {
205
205
  /*
206
206
  * call-seq:
207
207
  * Curl.conv? => true or false
208
- *
209
- * Returns true if the installed libcurl was built with support for character
208
+ *
209
+ * Returns true if the installed libcurl was built with support for character
210
210
  * conversions. For libcurl versions < 7.15.4, always returns false.
211
211
  */
212
212
  static VALUE ruby_curl_conv_q(VALUE mod) {
213
213
  #ifdef HAVE_CURL_VERSION_CONV
214
- curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
214
+ curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
215
215
  return((ver->features & CURL_VERSION_CONV) ? Qtrue : Qfalse);
216
216
  #else
217
217
  return Qfalse;
@@ -224,32 +224,32 @@ void Init_curb_core() {
224
224
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
225
225
  VALUE curlver, curllongver, curlvernum;
226
226
 
227
- mCurl = rb_define_module("Curl");
228
-
227
+ mCurl = rb_define_module("Curl");
228
+
229
229
  curlver = rb_str_new2(ver->version);
230
230
  curllongver = rb_str_new2(curl_version());
231
231
  curlvernum = LONG2NUM(LIBCURL_VERSION_NUM);
232
-
233
- rb_define_const(mCurl, "CURB_VERSION", rb_str_new2(CURB_VERSION));
232
+
233
+ rb_define_const(mCurl, "CURB_VERSION", rb_str_new2(CURB_VERSION));
234
234
  rb_define_const(mCurl, "VERSION", curlver);
235
235
  rb_define_const(mCurl, "CURL_VERSION", curlver);
236
236
  rb_define_const(mCurl, "VERNUM", curlvernum);
237
237
  rb_define_const(mCurl, "CURL_VERNUM", curlvernum);
238
- rb_define_const(mCurl, "LONG_VERSION", curllongver);
239
- rb_define_const(mCurl, "CURL_LONG_VERSION", curllongver);
238
+ rb_define_const(mCurl, "LONG_VERSION", curllongver);
239
+ rb_define_const(mCurl, "CURL_LONG_VERSION", curllongver);
240
240
 
241
241
  /* Passed to on_debug handler to indicate that the data is informational text. */
242
242
  rb_define_const(mCurl, "CURLINFO_TEXT", INT2FIX(CURLINFO_TEXT));
243
-
243
+
244
244
  /* Passed to on_debug handler to indicate that the data is header (or header-like) data received from the peer. */
245
245
  rb_define_const(mCurl, "CURLINFO_HEADER_IN", INT2FIX(CURLINFO_HEADER_IN));
246
-
246
+
247
247
  /* Passed to on_debug handler to indicate that the data is header (or header-like) data sent to the peer. */
248
248
  rb_define_const(mCurl, "CURLINFO_HEADER_OUT", INT2FIX(CURLINFO_HEADER_OUT));
249
-
249
+
250
250
  /* Passed to on_debug handler to indicate that the data is protocol data received from the peer. */
251
251
  rb_define_const(mCurl, "CURLINFO_DATA_IN", INT2FIX(CURLINFO_DATA_IN));
252
-
252
+
253
253
  /* Passed to on_debug handler to indicate that the data is protocol data sent to the peer. */
254
254
  rb_define_const(mCurl, "CURLINFO_DATA_OUT", INT2FIX(CURLINFO_DATA_OUT));
255
255
 
@@ -261,14 +261,14 @@ void Init_curb_core() {
261
261
  #endif
262
262
 
263
263
  /* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS4 proxy. (libcurl >= 7.15.2) */
264
- #ifdef HAVE_CURLPROXY_SOCKS4
264
+ #ifdef HAVE_CURLPROXY_SOCKS4
265
265
  rb_define_const(mCurl, "CURLPROXY_SOCKS4", INT2FIX(CURLPROXY_SOCKS4));
266
266
  #else
267
267
  rb_define_const(mCurl, "CURLPROXY_SOCKS4", INT2FIX(-2));
268
268
  #endif
269
269
 
270
270
  /* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS5 proxy. (libcurl >= 7.10) */
271
- #ifdef HAVE_CURLPROXY_SOCKS5
271
+ #ifdef HAVE_CURLPROXY_SOCKS5
272
272
  rb_define_const(mCurl, "CURLPROXY_SOCKS5", INT2FIX(CURLPROXY_SOCKS5));
273
273
  #else
274
274
  rb_define_const(mCurl, "CURLPROXY_SOCKS5", INT2FIX(-2));
@@ -296,14 +296,14 @@ void Init_curb_core() {
296
296
  #endif
297
297
 
298
298
  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use HTTP NTLM authentication. Requires MS Windows or OpenSSL support. */
299
- #ifdef HAVE_CURLAUTH_NTLM
299
+ #ifdef HAVE_CURLAUTH_NTLM
300
300
  rb_define_const(mCurl, "CURLAUTH_NTLM", INT2FIX(CURLAUTH_NTLM));
301
301
  #else
302
302
  rb_define_const(mCurl, "CURLAUTH_NTLM", INT2FIX(0));
303
303
  #endif
304
304
 
305
305
  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, allows libcurl to select any suitable authentication method except basic. */
306
- #ifdef HAVE_CURLAUTH_ANYSAFE
306
+ #ifdef HAVE_CURLAUTH_ANYSAFE
307
307
  rb_define_const(mCurl, "CURLAUTH_ANYSAFE", INT2FIX(CURLAUTH_ANYSAFE));
308
308
  #else
309
309
  rb_define_const(mCurl, "CURLAUTH_ANYSAFE", INT2FIX(0));
@@ -315,7 +315,7 @@ void Init_curb_core() {
315
315
  #else
316
316
  rb_define_const(mCurl, "CURLAUTH_ANY", INT2FIX(0));
317
317
  #endif
318
-
318
+
319
319
  rb_define_singleton_method(mCurl, "ipv6?", ruby_curl_ipv6_q, 0);
320
320
  rb_define_singleton_method(mCurl, "kerberos4?", ruby_curl_kerberos4_q, 0);
321
321
  rb_define_singleton_method(mCurl, "ssl?", ruby_curl_ssl_q, 0);
data/ext/curb.h CHANGED
@@ -1,7 +1,7 @@
1
1
  /* Curb - Libcurl(3) bindings for Ruby.
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.h 39 2006-12-23 15:28:45Z roscopeco $
6
6
  */
7
7
 
@@ -20,17 +20,17 @@
20
20
  #include "curb_macros.h"
21
21
 
22
22
  // These should be managed from the Rake 'release' task.
23
- #define CURB_VERSION "0.4.0.0"
24
- #define CURB_VER_NUM 400
23
+ #define CURB_VERSION "0.4.1.0"
24
+ #define CURB_VER_NUM 410
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 4
27
- #define CURB_VER_MIC 0
27
+ #define CURB_VER_MIC 1
28
28
  #define CURB_VER_PATCH 0
29
29
 
30
30
 
31
31
  // Maybe not yet defined in Ruby
32
- #ifndef RSTRING_LEN
33
- #define RSTRING_LEN(x) RSTRING(x)->len
32
+ #ifndef RSTRING_LEN
33
+ #define RSTRING_LEN(x) RSTRING(x)->len
34
34
  #endif
35
35
  #ifndef RSTRING_PTR
36
36
  #define RSTRING_PTR(x) RSTRING(x)->ptr
@@ -47,4 +47,3 @@ extern VALUE mCurl;
47
47
  extern void Init_curb_core();
48
48
 
49
49
  #endif
50
-
data/ext/curb_easy.c CHANGED
@@ -1,12 +1,13 @@
1
1
  /* curb_easy.c - 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.c 30 2006-12-09 12:30:24Z roscopeco $
6
6
  */
7
7
  #include "curb_easy.h"
8
8
  #include "curb_errors.h"
9
9
  #include "curb_postfield.h"
10
+ #include "curb_upload.h"
10
11
 
11
12
  #include <errno.h>
12
13
  #include <string.h>
@@ -27,27 +28,63 @@ VALUE cCurlEasy;
27
28
  /* ================== CURL HANDLER FUNCS ==============*/
28
29
 
29
30
  /* These handle both body and header data */
30
- static size_t default_data_handler(char *stream,
31
- size_t size,
32
- size_t nmemb,
31
+ static size_t default_data_handler(char *stream,
32
+ size_t size,
33
+ size_t nmemb,
33
34
  VALUE out) {
34
35
  rb_str_buf_cat(out, stream, size * nmemb);
35
36
  return size * nmemb;
36
37
  }
37
- typedef struct _PutStream {
38
- char *buffer;
39
- size_t offset, len;
40
- } PutStream;
41
38
 
42
39
  // size_t function( void *ptr, size_t size, size_t nmemb, void *stream);
43
40
  static size_t read_data_handler(void *ptr,
44
- size_t size,
45
- size_t nmemb,
46
- void *stream) {
41
+ size_t size,
42
+ size_t nmemb,
43
+ ruby_curl_easy *rbce) {
44
+ size_t read_bytes = (size*nmemb);
45
+ VALUE stream = ruby_curl_upload_stream_get(rbce->upload);
46
+
47
+ if (rb_respond_to(stream, rb_intern("read"))) {//if (rb_respond_to(stream, rb_intern("to_s"))) {
48
+ /* copy read_bytes from stream into ptr */
49
+ VALUE str = rb_funcall(stream, rb_intern("read"), 1, rb_int_new(read_bytes) );
50
+ if( str != Qnil ) {
51
+ memcpy(ptr, RSTRING_PTR(str), RSTRING_LEN(str));
52
+ return RSTRING_LEN(str);
53
+ }
54
+ else {
55
+ return 0;
56
+ }
57
+ }
58
+ else {
59
+ ruby_curl_upload *rbcu;
60
+ Data_Get_Struct(rbce->upload, ruby_curl_upload, rbcu);
61
+ VALUE str = rb_funcall(stream, rb_intern("to_s"), 0);
62
+ size_t len = RSTRING_LEN(str);
63
+ size_t remaining = len - rbcu->offset;
64
+ char *str_ptr = RSTRING_PTR(str);
65
+ if( remaining < read_bytes ) {
66
+ if( remaining > 0 ) {
67
+ memcpy(ptr, str_ptr+rbcu->offset, remaining);
68
+ read_bytes = remaining;
69
+ rbcu->offset += remaining;
70
+ }
71
+ return remaining;
72
+ }
73
+ else if( remaining > read_bytes ) { // read_bytes <= remaining - send what we can fit in the buffer(ptr)
74
+ memcpy(ptr, str_ptr+rbcu->offset, read_bytes);
75
+ rbcu->offset += read_bytes;
76
+ }
77
+ else { // they're equal
78
+ memcpy(ptr, str_ptr+rbcu->offset, --read_bytes);
79
+ rbcu->offset += read_bytes;
80
+ }
81
+ return read_bytes;
82
+ }
47
83
 
48
- PutStream *pstream = (PutStream*)stream;
49
- size_t sent_bytes = (size * nmemb);
50
- size_t remaining = pstream->len - pstream->offset;
84
+ // PutStream *pstream = (PutStream*)stream;
85
+ // size_t sent_bytes = (size * nmemb);
86
+ // size_t remaining = pstream->len - pstream->offset;
87
+ /*
51
88
 
52
89
  // amount remaining is less then the buffer to send - can send it all
53
90
  if( remaining < sent_bytes ) {
@@ -66,20 +103,21 @@ static size_t read_data_handler(void *ptr,
66
103
  if (sent_bytes == 0) {
67
104
  free(pstream);
68
105
  }
106
+ */
69
107
 
70
108
  //printf("sent_bytes: %ld of %ld\n", sent_bytes, remaining);
71
- return sent_bytes;
109
+ //return sent_bytes;
72
110
  }
73
111
 
74
- static size_t proc_data_handler(char *stream,
75
- size_t size,
76
- size_t nmemb,
112
+ static size_t proc_data_handler(char *stream,
113
+ size_t size,
114
+ size_t nmemb,
77
115
  VALUE proc) {
78
116
  VALUE procret;
79
-
117
+
80
118
  procret = rb_funcall(proc, idCall, 1, rb_str_new(stream, size * nmemb));
81
-
82
- switch (rb_type(procret)) {
119
+
120
+ switch (rb_type(procret)) {
83
121
  case T_FIXNUM:
84
122
  return FIX2LONG(procret);
85
123
  case T_BIGNUM:
@@ -96,22 +134,22 @@ static int proc_progress_handler(VALUE proc,
96
134
  double ultotal,
97
135
  double ulnow) {
98
136
  VALUE procret;
99
-
100
- procret = rb_funcall(proc, idCall, 4, rb_float_new(dltotal),
101
- rb_float_new(dlnow),
137
+
138
+ procret = rb_funcall(proc, idCall, 4, rb_float_new(dltotal),
139
+ rb_float_new(dlnow),
102
140
  rb_float_new(ultotal),
103
141
  rb_float_new(ulnow));
104
142
 
105
143
  return(((procret == Qfalse) || (procret == Qnil)) ? -1 : 0);
106
- }
144
+ }
107
145
 
108
- static int proc_debug_handler(CURL *curl,
146
+ static int proc_debug_handler(CURL *curl,
109
147
  curl_infotype type,
110
- char *data,
111
- size_t data_len,
148
+ char *data,
149
+ size_t data_len,
112
150
  VALUE proc) {
113
151
  rb_funcall(proc, idCall, 2, INT2FIX(type), rb_str_new(data, data_len));
114
- return 0;
152
+ return 0;
115
153
  }
116
154
 
117
155
  /* ================== MARK/FREE FUNC ==================*/
@@ -126,7 +164,7 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
126
164
  rb_gc_mark(rbce->debug_proc);
127
165
  rb_gc_mark(rbce->interface);
128
166
  rb_gc_mark(rbce->userpwd);
129
- rb_gc_mark(rbce->proxypwd);
167
+ rb_gc_mark(rbce->proxypwd);
130
168
  rb_gc_mark(rbce->headers);
131
169
  rb_gc_mark(rbce->cookies);
132
170
  rb_gc_mark(rbce->cookiefile);
@@ -144,6 +182,10 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
144
182
  if( rbce->self != Qnil ) {
145
183
  rb_gc_mark(rbce->self);
146
184
  }
185
+
186
+ if( rbce->upload != Qnil ) {
187
+ rb_gc_mark(rbce->upload);
188
+ }
147
189
  }
148
190
 
149
191
  void curl_easy_free(ruby_curl_easy *rbce) {
@@ -162,7 +204,7 @@ void curl_easy_free(ruby_curl_easy *rbce) {
162
204
  * Curl::Easy.new => #&lt;Curl::Easy...&gt;
163
205
  * Curl::Easy.new(url = nil) => #&lt;Curl::Easy...&gt;
164
206
  * Curl::Easy.new(url = nil) { |self| ... } => #&lt;Curl::Easy...&gt;
165
- *
207
+ *
166
208
  * Create a new Curl::Easy instance, optionally supplying the URL.
167
209
  * The block form allows further configuration to be supplied before
168
210
  * the instance is returned.
@@ -172,13 +214,13 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
172
214
  VALUE url, blk;
173
215
  VALUE new_curl;
174
216
 
175
- rb_scan_args(argc, argv, "01&", &url, &blk);
217
+ rb_scan_args(argc, argv, "01&", &url, &blk);
176
218
 
177
219
  ruby_curl_easy *rbce = ALLOC(ruby_curl_easy);
178
-
179
- /* handler */
180
- rbce->curl = curl_easy_init();
181
-
220
+
221
+ /* handler */
222
+ rbce->curl = curl_easy_init();
223
+
182
224
  /* assoc objects */
183
225
  rbce->url = url;
184
226
  rbce->proxy_url = Qnil;
@@ -200,15 +242,15 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
200
242
  rbce->success_proc = Qnil;
201
243
  rbce->failure_proc = Qnil;
202
244
  rbce->complete_proc = Qnil;
203
-
245
+
204
246
  /* various-typed opts */
205
247
  rbce->local_port = 0;
206
248
  rbce->local_port_range = 0;
207
- rbce->proxy_port = 0;
208
- rbce->proxy_type = -1;
249
+ rbce->proxy_port = 0;
250
+ rbce->proxy_type = -1;
209
251
  rbce->http_auth_types = 0;
210
- rbce->proxy_auth_types = 0;
211
- rbce->max_redirs = -1;
252
+ rbce->proxy_auth_types = 0;
253
+ rbce->max_redirs = -1;
212
254
  rbce->timeout = 0;
213
255
  rbce->connect_timeout = 0;
214
256
  rbce->dns_cache_timeout = 60;
@@ -226,7 +268,7 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
226
268
  rbce->verbose = 0;
227
269
  rbce->multipart_form_post = 0;
228
270
  rbce->enable_cookies = 0;
229
-
271
+
230
272
  /* buffers */
231
273
  rbce->postdata_buffer = Qnil;
232
274
  rbce->bodybuf = Qnil;
@@ -234,9 +276,10 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
234
276
  rbce->curl_headers = NULL;
235
277
 
236
278
  rbce->self = Qnil;
237
-
238
- new_curl = Data_Wrap_Struct(cCurlEasy, curl_easy_mark, curl_easy_free, rbce);
239
-
279
+ rbce->upload = Qnil;
280
+
281
+ new_curl = Data_Wrap_Struct(klass, curl_easy_mark, curl_easy_free, rbce);
282
+
240
283
  if (blk != Qnil) {
241
284
  rb_funcall(blk, idCall, 1, new_curl);
242
285
  }
@@ -247,14 +290,14 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
247
290
  raise_curl_easy_error_exception(ecode);
248
291
  }
249
292
 
250
- return new_curl;
293
+ return new_curl;
251
294
  }
252
295
 
253
296
  /*
254
297
  * call-seq:
255
298
  * easy.clone => #&lt;easy clone&gt;
256
299
  * easy.dup => #&lt;easy clone&gt;
257
- *
300
+ *
258
301
  * Clone this Curl::Easy instance, creating a new instance.
259
302
  * This method duplicates the underlying CURL* handle.
260
303
  */
@@ -262,12 +305,12 @@ static VALUE ruby_curl_easy_clone(VALUE self) {
262
305
  ruby_curl_easy *rbce, *newrbce;
263
306
 
264
307
  Data_Get_Struct(self, ruby_curl_easy, rbce);
265
-
308
+
266
309
  newrbce = ALLOC(ruby_curl_easy);
267
- memcpy(newrbce, rbce, sizeof(ruby_curl_easy));
310
+ memcpy(newrbce, rbce, sizeof(ruby_curl_easy));
268
311
  newrbce->curl = curl_easy_duphandle(rbce->curl);
269
312
  newrbce->curl_headers = NULL;
270
-
313
+
271
314
  return Data_Wrap_Struct(cCurlEasy, curl_easy_mark, curl_easy_free, newrbce);
272
315
  }
273
316
 
@@ -277,7 +320,7 @@ static VALUE ruby_curl_easy_clone(VALUE self) {
277
320
  /*
278
321
  * call-seq:
279
322
  * easy.url = "http://some.url/" => "http://some.url/"
280
- *
323
+ *
281
324
  * Set the URL for subsequent calls to +perform+. It is acceptable
282
325
  * (and even recommended) to reuse Curl::Easy instances by reassigning
283
326
  * the URL between calls to +perform+.
@@ -289,9 +332,9 @@ static VALUE ruby_curl_easy_url_set(VALUE self, VALUE url) {
289
332
  /*
290
333
  * call-seq:
291
334
  * easy.url => "http://some.url/"
292
- *
335
+ *
293
336
  * Obtain the URL that will be used by subsequent calls to +perform+.
294
- */
337
+ */
295
338
  static VALUE ruby_curl_easy_url_get(VALUE self) {
296
339
  CURB_OBJECT_GETTER(ruby_curl_easy, url);
297
340
  }
@@ -299,26 +342,26 @@ static VALUE ruby_curl_easy_url_get(VALUE self) {
299
342
  /*
300
343
  * call-seq:
301
344
  * easy.proxy_url = "some.url" => "some.url"
302
- *
345
+ *
303
346
  * Set the URL of the HTTP proxy to use for subsequent calls to +perform+.
304
- * The URL should specify the the host name or dotted IP address. To specify
305
- * port number in this string, append :[port] to the end of the host name.
347
+ * The URL should specify the the host name or dotted IP address. To specify
348
+ * port number in this string, append :[port] to the end of the host name.
306
349
  * The proxy string may be prefixed with [protocol]:// since any such prefix
307
- * will be ignored. The proxy's port number may optionally be specified with
350
+ * will be ignored. The proxy's port number may optionally be specified with
308
351
  * the separate option proxy_port .
309
- *
310
- * When you tell the library to use an HTTP proxy, libcurl will transparently
352
+ *
353
+ * When you tell the library to use an HTTP proxy, libcurl will transparently
311
354
  * convert operations to HTTP even if you specify an FTP URL etc. This may have
312
- * an impact on what other features of the library you can use, such as
313
- * FTP specifics that don't work unless you tunnel through the HTTP proxy. Such
355
+ * an impact on what other features of the library you can use, such as
356
+ * FTP specifics that don't work unless you tunnel through the HTTP proxy. Such
314
357
  * tunneling is activated with proxy_tunnel = true.
315
- *
316
- * libcurl respects the environment variables *http_proxy*, *ftp_proxy*,
317
- * *all_proxy* etc, if any of those is set. The proxy_url option does however
318
- * override any possibly set environment variables.
319
- *
320
- * Starting with libcurl 7.14.1, the proxy host string given in environment
321
- * variables can be specified the exact same way as the proxy can be set with
358
+ *
359
+ * libcurl respects the environment variables *http_proxy*, *ftp_proxy*,
360
+ * *all_proxy* etc, if any of those is set. The proxy_url option does however
361
+ * override any possibly set environment variables.
362
+ *
363
+ * Starting with libcurl 7.14.1, the proxy host string given in environment
364
+ * variables can be specified the exact same way as the proxy can be set with
322
365
  * proxy_url, including protocol prefix (http://) and embedded user + password.
323
366
  */
324
367
  static VALUE ruby_curl_easy_proxy_url_set(VALUE self, VALUE proxy_url) {
@@ -328,9 +371,9 @@ static VALUE ruby_curl_easy_proxy_url_set(VALUE self, VALUE proxy_url) {
328
371
  /*
329
372
  * call-seq:
330
373
  * easy.proxy_url => "some.url"
331
- *
374
+ *
332
375
  * Obtain the HTTP Proxy URL that will be used by subsequent calls to +perform+.
333
- */
376
+ */
334
377
  static VALUE ruby_curl_easy_proxy_url_get(VALUE self) {
335
378
  CURB_OBJECT_GETTER(ruby_curl_easy, proxy_url);
336
379
  }
@@ -340,20 +383,20 @@ static VALUE ruby_curl_easy_proxy_url_get(VALUE self) {
340
383
  * easy.headers = "Header: val" => ["Header: val", ...]
341
384
  * easy.headers = {"Header" => "val" ..., "Header" => "val"} => ["Header: val", ...]
342
385
  * easy.headers = ["Header: val" ..., "Header: val"] => ["Header: val", ...]
343
- *
386
+ *
344
387
  * Set custom HTTP headers for following requests. This can be used to add
345
388
  * custom headers, or override standard headers used by libcurl. It defaults to a
346
- * Hash.
347
- *
389
+ * Hash.
390
+ *
348
391
  * For example to set a standard or custom header:
349
- *
392
+ *
350
393
  * easy.headers["MyHeader"] = "myval"
351
- *
394
+ *
352
395
  * To remove a standard header (this is useful when removing libcurls default
353
396
  * 'Expect: 100-Continue' header when using HTTP form posts):
354
- *
397
+ *
355
398
  * easy.headers["Expect:"] = ''
356
- *
399
+ *
357
400
  * Anything passed to libcurl as a header will be converted to a string during
358
401
  * the perform step.
359
402
  */
@@ -364,9 +407,9 @@ static VALUE ruby_curl_easy_headers_set(VALUE self, VALUE headers) {
364
407
  /*
365
408
  * call-seq:
366
409
  * easy.headers => Hash, Array or Str
367
- *
410
+ *
368
411
  * Obtain the custom HTTP headers for following requests.
369
- */
412
+ */
370
413
  static VALUE ruby_curl_easy_headers_get(VALUE self) {
371
414
  CURB_OBJECT_GETTER(ruby_curl_easy, headers);
372
415
  }
@@ -374,8 +417,8 @@ static VALUE ruby_curl_easy_headers_get(VALUE self) {
374
417
  /*
375
418
  * call-seq:
376
419
  * easy.interface = "interface" => "interface"
377
- *
378
- * Set the interface name to use as the outgoing network interface.
420
+ *
421
+ * Set the interface name to use as the outgoing network interface.
379
422
  * The name can be an interface name, an IP address or a host name.
380
423
  */
381
424
  static VALUE ruby_curl_easy_interface_set(VALUE self, VALUE interface) {
@@ -385,10 +428,10 @@ static VALUE ruby_curl_easy_interface_set(VALUE self, VALUE interface) {
385
428
  /*
386
429
  * call-seq:
387
430
  * easy.interface => "interface"
388
- *
389
- * Obtain the interface name that is used as the outgoing network interface.
431
+ *
432
+ * Obtain the interface name that is used as the outgoing network interface.
390
433
  * The name can be an interface name, an IP address or a host name.
391
- */
434
+ */
392
435
  static VALUE ruby_curl_easy_interface_get(VALUE self) {
393
436
  CURB_OBJECT_GETTER(ruby_curl_easy, interface);
394
437
  }
@@ -396,7 +439,7 @@ static VALUE ruby_curl_easy_interface_get(VALUE self) {
396
439
  /*
397
440
  * call-seq:
398
441
  * easy.userpwd = "pwd string" => "pwd string"
399
- *
442
+ *
400
443
  * Set the username/password string to use for subsequent calls to +perform+.
401
444
  * The supplied string should have the form "username:password"
402
445
  */
@@ -407,10 +450,10 @@ static VALUE ruby_curl_easy_userpwd_set(VALUE self, VALUE userpwd) {
407
450
  /*
408
451
  * call-seq:
409
452
  * easy.userpwd => "pwd string"
410
- *
411
- * Obtain the username/password string that will be used for subsequent
453
+ *
454
+ * Obtain the username/password string that will be used for subsequent
412
455
  * calls to +perform+.
413
- */
456
+ */
414
457
  static VALUE ruby_curl_easy_userpwd_get(VALUE self) {
415
458
  CURB_OBJECT_GETTER(ruby_curl_easy, userpwd);
416
459
  }
@@ -418,9 +461,9 @@ static VALUE ruby_curl_easy_userpwd_get(VALUE self) {
418
461
  /*
419
462
  * call-seq:
420
463
  * easy.proxypwd = "pwd string" => "pwd string"
421
- *
422
- * Set the username/password string to use for proxy connection during
423
- * subsequent calls to +perform+. The supplied string should have the
464
+ *
465
+ * Set the username/password string to use for proxy connection during
466
+ * subsequent calls to +perform+. The supplied string should have the
424
467
  * form "username:password"
425
468
  */
426
469
  static VALUE ruby_curl_easy_proxypwd_set(VALUE self, VALUE proxypwd) {
@@ -430,11 +473,11 @@ static VALUE ruby_curl_easy_proxypwd_set(VALUE self, VALUE proxypwd) {
430
473
  /*
431
474
  * call-seq:
432
475
  * easy.proxypwd => "pwd string"
433
- *
434
- * Obtain the username/password string that will be used for proxy
435
- * connection during subsequent calls to +perform+. The supplied string
476
+ *
477
+ * Obtain the username/password string that will be used for proxy
478
+ * connection during subsequent calls to +perform+. The supplied string
436
479
  * should have the form "username:password"
437
- */
480
+ */
438
481
  static VALUE ruby_curl_easy_proxypwd_get(VALUE self) {
439
482
  CURB_OBJECT_GETTER(ruby_curl_easy, proxypwd);
440
483
  }
@@ -445,8 +488,8 @@ static VALUE ruby_curl_easy_proxypwd_get(VALUE self) {
445
488
  * easy.cookies = "name1=content1; name2=content2;" => "pwd string"
446
489
  *
447
490
  * Set cookies to be sent by this Curl::Easy instance. The format of the string should
448
- * be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
449
- * Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
491
+ * be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
492
+ * Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
450
493
  */
451
494
  static VALUE ruby_curl_easy_cookies_set(VALUE self, VALUE cookies) {
452
495
  CURB_OBJECT_SETTER(ruby_curl_easy, cookies);
@@ -455,9 +498,9 @@ static VALUE ruby_curl_easy_cookies_set(VALUE self, VALUE cookies) {
455
498
  /*
456
499
  * call-seq:
457
500
  * easy.cookies => "name1=content1; name2=content2;"
458
- *
459
- * Obtain the cookies for this Curl::Easy instance.
460
- */
501
+ *
502
+ * Obtain the cookies for this Curl::Easy instance.
503
+ */
461
504
  static VALUE ruby_curl_easy_cookies_get(VALUE self) {
462
505
  CURB_OBJECT_GETTER(ruby_curl_easy, cookies);
463
506
  }
@@ -467,7 +510,7 @@ static VALUE ruby_curl_easy_cookies_get(VALUE self) {
467
510
  * easy.cookiefile = "cookies.txt" => "pwd string"
468
511
  *
469
512
  * Set a file that contains cookies to be sent in subsequent requests by this Curl::Easy instance.
470
- *
513
+ *
471
514
  * *Note* that you must set enable_cookies true to enable the cookie
472
515
  * engine, or this option will be ignored.
473
516
  */
@@ -478,9 +521,9 @@ static VALUE ruby_curl_easy_cookiefile_set(VALUE self, VALUE cookiefile) {
478
521
  /*
479
522
  * call-seq:
480
523
  * easy.cookiefile => "cookies.txt"
481
- *
482
- * Obtain the cookiefile file for this Curl::Easy instance.
483
- */
524
+ *
525
+ * Obtain the cookiefile file for this Curl::Easy instance.
526
+ */
484
527
  static VALUE ruby_curl_easy_cookiefile_get(VALUE self) {
485
528
  CURB_OBJECT_GETTER(ruby_curl_easy, cookiefile);
486
529
  }
@@ -488,10 +531,10 @@ static VALUE ruby_curl_easy_cookiefile_get(VALUE self) {
488
531
  /*
489
532
  * call-seq:
490
533
  * easy.cookiejar = "cookiejar.file" => "pwd string"
491
- *
534
+ *
492
535
  * Set a cookiejar file to use for this Curl::Easy instance.
493
536
  * Cookies from the response will be written into this file.
494
- *
537
+ *
495
538
  * *Note* that you must set enable_cookies true to enable the cookie
496
539
  * engine, or this option will be ignored.
497
540
  */
@@ -502,9 +545,9 @@ static VALUE ruby_curl_easy_cookiejar_set(VALUE self, VALUE cookiejar) {
502
545
  /*
503
546
  * call-seq:
504
547
  * easy.cookiejar => "cookiejar.file"
505
- *
506
- * Obtain the cookiejar file to use for this Curl::Easy instance.
507
- */
548
+ *
549
+ * Obtain the cookiejar file to use for this Curl::Easy instance.
550
+ */
508
551
  static VALUE ruby_curl_easy_cookiejar_get(VALUE self) {
509
552
  CURB_OBJECT_GETTER(ruby_curl_easy, cookiejar);
510
553
  }
@@ -512,10 +555,10 @@ static VALUE ruby_curl_easy_cookiejar_get(VALUE self) {
512
555
  /*
513
556
  * call-seq:
514
557
  * easy.cert = "cert.file" => ""
515
- *
558
+ *
516
559
  * Set a cert file to use for this Curl::Easy instance. This file
517
560
  * will be used to validate SSL connections.
518
- *
561
+ *
519
562
  */
520
563
  static VALUE ruby_curl_easy_cert_set(VALUE self, VALUE cert) {
521
564
  CURB_OBJECT_SETTER(ruby_curl_easy, cert);
@@ -524,9 +567,9 @@ static VALUE ruby_curl_easy_cert_set(VALUE self, VALUE cert) {
524
567
  /*
525
568
  * call-seq:
526
569
  * easy.cert => "cert.file"
527
- *
528
- * Obtain the cert file to use for this Curl::Easy instance.
529
- */
570
+ *
571
+ * Obtain the cert file to use for this Curl::Easy instance.
572
+ */
530
573
  static VALUE ruby_curl_easy_cert_get(VALUE self) {
531
574
  CURB_OBJECT_GETTER(ruby_curl_easy, cert);
532
575
  }
@@ -534,20 +577,20 @@ static VALUE ruby_curl_easy_cert_get(VALUE self) {
534
577
  /*
535
578
  * call-seq:
536
579
  * easy.encoding= => "string"
537
- *
580
+ *
538
581
  * Set the accepted encoding types, curl will handle all of the decompression
539
- *
540
- */
582
+ *
583
+ */
541
584
  static VALUE ruby_curl_easy_encoding_set(VALUE self, VALUE encoding) {
542
585
  CURB_OBJECT_SETTER(ruby_curl_easy, encoding);
543
586
  }
544
587
  /*
545
588
  * call-seq:
546
589
  * easy.encoding => "string"
547
- *
590
+ *
548
591
  * Get the set encoding types
549
- *
550
- */
592
+ *
593
+ */
551
594
  static VALUE ruby_curl_easy_encoding_get(VALUE self) {
552
595
  CURB_OBJECT_GETTER(ruby_curl_easy, encoding);
553
596
  }
@@ -557,14 +600,14 @@ static VALUE ruby_curl_easy_encoding_get(VALUE self) {
557
600
  /*
558
601
  * call-seq:
559
602
  * easy.local_port = fixnum or nil => fixnum or nil
560
- *
561
- * Set the local port that will be used for the following +perform+ calls.
562
- *
563
- * Passing +nil+ will return to the default behaviour (no local port
603
+ *
604
+ * Set the local port that will be used for the following +perform+ calls.
605
+ *
606
+ * Passing +nil+ will return to the default behaviour (no local port
564
607
  * preference).
565
- *
608
+ *
566
609
  * This option is ignored if compiled against libcurl < 7.15.2.
567
- */
610
+ */
568
611
  static VALUE ruby_curl_easy_local_port_set(VALUE self, VALUE local_port) {
569
612
  CURB_IMMED_PORT_SETTER(ruby_curl_easy, local_port, "port");
570
613
  }
@@ -572,11 +615,11 @@ static VALUE ruby_curl_easy_local_port_set(VALUE self, VALUE local_port) {
572
615
  /*
573
616
  * call-seq:
574
617
  * easy.local_port => fixnum or nil
575
- *
618
+ *
576
619
  * Obtain the local port that will be used for the following +perform+ calls.
577
- *
620
+ *
578
621
  * This option is ignored if compiled against libcurl < 7.15.2.
579
- */
622
+ */
580
623
  static VALUE ruby_curl_easy_local_port_get(VALUE self) {
581
624
  CURB_IMMED_PORT_GETTER(ruby_curl_easy, local_port);
582
625
  }
@@ -584,17 +627,17 @@ static VALUE ruby_curl_easy_local_port_get(VALUE self) {
584
627
  /*
585
628
  * call-seq:
586
629
  * easy.local_port_range = fixnum or nil => fixnum or nil
587
- *
588
- * Set the local port range that will be used for the following +perform+
589
- * calls. This is a number (between 0 and 65535) that determines how far
630
+ *
631
+ * Set the local port range that will be used for the following +perform+
632
+ * calls. This is a number (between 0 and 65535) that determines how far
590
633
  * libcurl may deviate from the supplied +local_port+ in order to find
591
- * an available port.
592
- *
634
+ * an available port.
635
+ *
593
636
  * If you set +local_port+ it's also recommended that you set this, since
594
637
  * it is fairly likely that your specified port will be unavailable.
595
- *
638
+ *
596
639
  * This option is ignored if compiled against libcurl < 7.15.2.
597
- */
640
+ */
598
641
  static VALUE ruby_curl_easy_local_port_range_set(VALUE self, VALUE local_port_range) {
599
642
  CURB_IMMED_PORT_SETTER(ruby_curl_easy, local_port_range, "port range");
600
643
  }
@@ -602,12 +645,12 @@ static VALUE ruby_curl_easy_local_port_range_set(VALUE self, VALUE local_port_ra
602
645
  /*
603
646
  * call-seq:
604
647
  * easy.local_port_range => fixnum or nil
605
- *
648
+ *
606
649
  * Obtain the local port range that will be used for the following +perform+
607
650
  * calls.
608
- *
651
+ *
609
652
  * This option is ignored if compiled against libcurl < 7.15.2.
610
- */
653
+ */
611
654
  static VALUE ruby_curl_easy_local_port_range_get(VALUE self) {
612
655
  CURB_IMMED_PORT_GETTER(ruby_curl_easy, local_port_range);
613
656
  }
@@ -615,9 +658,9 @@ static VALUE ruby_curl_easy_local_port_range_get(VALUE self) {
615
658
  /*
616
659
  * call-seq:
617
660
  * easy.proxy_port = fixnum or nil => fixnum or nil
618
- *
619
- * Set the proxy port that will be used for the following +perform+ calls.
620
- */
661
+ *
662
+ * Set the proxy port that will be used for the following +perform+ calls.
663
+ */
621
664
  static VALUE ruby_curl_easy_proxy_port_set(VALUE self, VALUE proxy_port) {
622
665
  CURB_IMMED_PORT_SETTER(ruby_curl_easy, proxy_port, "port");
623
666
  }
@@ -625,9 +668,9 @@ static VALUE ruby_curl_easy_proxy_port_set(VALUE self, VALUE proxy_port) {
625
668
  /*
626
669
  * call-seq:
627
670
  * easy.proxy_port => fixnum or nil
628
- *
671
+ *
629
672
  * Obtain the proxy port that will be used for the following +perform+ calls.
630
- */
673
+ */
631
674
  static VALUE ruby_curl_easy_proxy_port_get(VALUE self) {
632
675
  CURB_IMMED_PORT_GETTER(ruby_curl_easy, proxy_port);
633
676
  }
@@ -635,10 +678,10 @@ static VALUE ruby_curl_easy_proxy_port_get(VALUE self) {
635
678
  /*
636
679
  * call-seq:
637
680
  * easy.proxy_type = fixnum or nil => fixnum or nil
638
- *
639
- * Set the proxy type that will be used for the following +perform+ calls.
681
+ *
682
+ * Set the proxy type that will be used for the following +perform+ calls.
640
683
  * This should be one of the Curl::CURLPROXY constants.
641
- */
684
+ */
642
685
  static VALUE ruby_curl_easy_proxy_type_set(VALUE self, VALUE proxy_type) {
643
686
  CURB_IMMED_SETTER(ruby_curl_easy, proxy_type, -1);
644
687
  }
@@ -646,9 +689,9 @@ static VALUE ruby_curl_easy_proxy_type_set(VALUE self, VALUE proxy_type) {
646
689
  /*
647
690
  * call-seq:
648
691
  * easy.proxy_type => fixnum or nil
649
- *
692
+ *
650
693
  * Obtain the proxy type that will be used for the following +perform+ calls.
651
- */
694
+ */
652
695
  static VALUE ruby_curl_easy_proxy_type_get(VALUE self) {
653
696
  CURB_IMMED_GETTER(ruby_curl_easy, proxy_type, -1);
654
697
  }
@@ -656,11 +699,11 @@ static VALUE ruby_curl_easy_proxy_type_get(VALUE self) {
656
699
  /*
657
700
  * call-seq:
658
701
  * easy.http_auth_types = fixnum or nil => fixnum or nil
659
- *
660
- * Set the HTTP authentication types that may be used for the following
702
+ *
703
+ * Set the HTTP authentication types that may be used for the following
661
704
  * +perform+ calls. This is a bitmap made by ORing together the
662
705
  * Curl::CURLAUTH constants.
663
- */
706
+ */
664
707
  static VALUE ruby_curl_easy_http_auth_types_set(VALUE self, VALUE http_auth_types) {
665
708
  CURB_IMMED_SETTER(ruby_curl_easy, http_auth_types, 0);
666
709
  }
@@ -668,10 +711,10 @@ static VALUE ruby_curl_easy_http_auth_types_set(VALUE self, VALUE http_auth_type
668
711
  /*
669
712
  * call-seq:
670
713
  * easy.http_auth_types => fixnum or nil
671
- *
672
- * Obtain the HTTP authentication types that may be used for the following
714
+ *
715
+ * Obtain the HTTP authentication types that may be used for the following
673
716
  * +perform+ calls.
674
- */
717
+ */
675
718
  static VALUE ruby_curl_easy_http_auth_types_get(VALUE self) {
676
719
  CURB_IMMED_GETTER(ruby_curl_easy, http_auth_types, 0);
677
720
  }
@@ -679,11 +722,11 @@ static VALUE ruby_curl_easy_http_auth_types_get(VALUE self) {
679
722
  /*
680
723
  * call-seq:
681
724
  * easy.proxy_auth_types = fixnum or nil => fixnum or nil
682
- *
683
- * Set the proxy authentication types that may be used for the following
684
- * +perform+ calls. This is a bitmap made by ORing together the
725
+ *
726
+ * Set the proxy authentication types that may be used for the following
727
+ * +perform+ calls. This is a bitmap made by ORing together the
685
728
  * Curl::CURLAUTH constants.
686
- */
729
+ */
687
730
  static VALUE ruby_curl_easy_proxy_auth_types_set(VALUE self, VALUE proxy_auth_types) {
688
731
  CURB_IMMED_SETTER(ruby_curl_easy, proxy_auth_types, 0);
689
732
  }
@@ -691,10 +734,10 @@ static VALUE ruby_curl_easy_proxy_auth_types_set(VALUE self, VALUE proxy_auth_ty
691
734
  /*
692
735
  * call-seq:
693
736
  * easy.proxy_auth_types => fixnum or nil
694
- *
695
- * Obtain the proxy authentication types that may be used for the following
737
+ *
738
+ * Obtain the proxy authentication types that may be used for the following
696
739
  * +perform+ calls.
697
- */
740
+ */
698
741
  static VALUE ruby_curl_easy_proxy_auth_types_get(VALUE self) {
699
742
  CURB_IMMED_GETTER(ruby_curl_easy, proxy_auth_types, 0);
700
743
  }
@@ -702,14 +745,14 @@ static VALUE ruby_curl_easy_proxy_auth_types_get(VALUE self) {
702
745
  /*
703
746
  * call-seq:
704
747
  * easy.max_redirects = fixnum or nil => fixnum or nil
705
- *
748
+ *
706
749
  * Set the maximum number of redirections to follow in the following +perform+
707
750
  * calls. Set to nil or -1 allow an infinite number (the default). Setting this
708
751
  * option only makes sense if +follow_location+ is also set true.
709
- *
752
+ *
710
753
  * With libcurl >= 7.15.1, setting this to 0 will cause libcurl to refuse any
711
754
  * redirect.
712
- */
755
+ */
713
756
  static VALUE ruby_curl_easy_max_redirects_set(VALUE self, VALUE max_redirs) {
714
757
  CURB_IMMED_SETTER(ruby_curl_easy, max_redirs, -1);
715
758
  }
@@ -717,10 +760,10 @@ static VALUE ruby_curl_easy_max_redirects_set(VALUE self, VALUE max_redirs) {
717
760
  /*
718
761
  * call-seq:
719
762
  * easy.max_redirects => fixnum or nil
720
- *
721
- * Obtain the maximum number of redirections to follow in the following
763
+ *
764
+ * Obtain the maximum number of redirections to follow in the following
722
765
  * +perform+ calls.
723
- */
766
+ */
724
767
  static VALUE ruby_curl_easy_max_redirects_get(VALUE self) {
725
768
  CURB_IMMED_GETTER(ruby_curl_easy, max_redirs, -1);
726
769
  }
@@ -728,15 +771,15 @@ static VALUE ruby_curl_easy_max_redirects_get(VALUE self) {
728
771
  /*
729
772
  * call-seq:
730
773
  * easy.timeout = fixnum or nil => fixnum or nil
731
- *
732
- * Set the maximum time in seconds that you allow the libcurl transfer
733
- * operation to take. Normally, name lookups can take a considerable time
734
- * and limiting operations to less than a few minutes risk aborting
774
+ *
775
+ * Set the maximum time in seconds that you allow the libcurl transfer
776
+ * operation to take. Normally, name lookups can take a considerable time
777
+ * and limiting operations to less than a few minutes risk aborting
735
778
  * perfectly normal operations.
736
- *
737
- * Set to nil (or zero) to disable timeout (it will then only timeout
779
+ *
780
+ * Set to nil (or zero) to disable timeout (it will then only timeout
738
781
  * on the system's internal timeouts).
739
- */
782
+ */
740
783
  static VALUE ruby_curl_easy_timeout_set(VALUE self, VALUE timeout) {
741
784
  CURB_IMMED_SETTER(ruby_curl_easy, timeout, 0);
742
785
  }
@@ -744,10 +787,10 @@ static VALUE ruby_curl_easy_timeout_set(VALUE self, VALUE timeout) {
744
787
  /*
745
788
  * call-seq:
746
789
  * easy.timeout => fixnum or nil
747
- *
748
- * Obtain the maximum time in seconds that you allow the libcurl transfer
790
+ *
791
+ * Obtain the maximum time in seconds that you allow the libcurl transfer
749
792
  * operation to take.
750
- */
793
+ */
751
794
  static VALUE ruby_curl_easy_timeout_get(VALUE self, VALUE timeout) {
752
795
  CURB_IMMED_GETTER(ruby_curl_easy, timeout, 0);
753
796
  }
@@ -755,14 +798,14 @@ static VALUE ruby_curl_easy_timeout_get(VALUE self, VALUE timeout) {
755
798
  /*
756
799
  * call-seq:
757
800
  * easy.connect_timeout = fixnum or nil => fixnum or nil
758
- *
801
+ *
759
802
  * Set the maximum time in seconds that you allow the connection to the
760
- * server to take. This only limits the connection phase, once it has
761
- * connected, this option is of no more use.
762
- *
803
+ * server to take. This only limits the connection phase, once it has
804
+ * connected, this option is of no more use.
805
+ *
763
806
  * Set to nil (or zero) to disable connection timeout (it will then only
764
807
  * timeout on the system's internal timeouts).
765
- */
808
+ */
766
809
  static VALUE ruby_curl_easy_connect_timeout_set(VALUE self, VALUE connect_timeout) {
767
810
  CURB_IMMED_SETTER(ruby_curl_easy, connect_timeout, 0);
768
811
  }
@@ -770,10 +813,10 @@ static VALUE ruby_curl_easy_connect_timeout_set(VALUE self, VALUE connect_timeou
770
813
  /*
771
814
  * call-seq:
772
815
  * easy.connect_timeout => fixnum or nil
773
- *
816
+ *
774
817
  * Obtain the maximum time in seconds that you allow the connection to the
775
818
  * server to take.
776
- */
819
+ */
777
820
  static VALUE ruby_curl_easy_connect_timeout_get(VALUE self, VALUE connect_timeout) {
778
821
  CURB_IMMED_GETTER(ruby_curl_easy, connect_timeout, 0);
779
822
  }
@@ -781,12 +824,12 @@ static VALUE ruby_curl_easy_connect_timeout_get(VALUE self, VALUE connect_timeou
781
824
  /*
782
825
  * call-seq:
783
826
  * easy.dns_cache_timeout = fixnum or nil => fixnum or nil
784
- *
785
- * Set the dns cache timeout in seconds. Name resolves will be kept in
786
- * memory for this number of seconds. Set to zero (0) to completely disable
827
+ *
828
+ * Set the dns cache timeout in seconds. Name resolves will be kept in
829
+ * memory for this number of seconds. Set to zero (0) to completely disable
787
830
  * caching, or set to nil (or -1) to make the cached entries remain forever.
788
831
  * By default, libcurl caches this info for 60 seconds.
789
- */
832
+ */
790
833
  static VALUE ruby_curl_easy_dns_cache_timeout_set(VALUE self, VALUE dns_cache_timeout) {
791
834
  CURB_IMMED_SETTER(ruby_curl_easy, dns_cache_timeout, -1);
792
835
  }
@@ -794,26 +837,26 @@ static VALUE ruby_curl_easy_dns_cache_timeout_set(VALUE self, VALUE dns_cache_ti
794
837
  /*
795
838
  * call-seq:
796
839
  * easy.dns_cache_timeout => fixnum or nil
797
- *
840
+ *
798
841
  * Obtain the dns cache timeout in seconds.
799
- */
842
+ */
800
843
  static VALUE ruby_curl_easy_dns_cache_timeout_get(VALUE self, VALUE dns_cache_timeout) {
801
- CURB_IMMED_GETTER(ruby_curl_easy, dns_cache_timeout, -1);
844
+ CURB_IMMED_GETTER(ruby_curl_easy, dns_cache_timeout, -1);
802
845
  }
803
846
 
804
847
  /*
805
848
  * call-seq:
806
849
  * easy.ftp_response_timeout = fixnum or nil => fixnum or nil
807
- *
808
- * Set a timeout period (in seconds) on the amount of time that the server
809
- * is allowed to take in order to generate a response message for a command
810
- * before the session is considered hung. While curl is waiting for a
850
+ *
851
+ * Set a timeout period (in seconds) on the amount of time that the server
852
+ * is allowed to take in order to generate a response message for a command
853
+ * before the session is considered hung. While curl is waiting for a
811
854
  * response, this value overrides +timeout+. It is recommended that if used
812
- * in conjunction with +timeout+, you set +ftp_response_timeout+ to a value
813
- * smaller than +timeout+.
814
- *
855
+ * in conjunction with +timeout+, you set +ftp_response_timeout+ to a value
856
+ * smaller than +timeout+.
857
+ *
815
858
  * Ignored if libcurl version is < 7.10.8.
816
- */
859
+ */
817
860
  static VALUE ruby_curl_easy_ftp_response_timeout_set(VALUE self, VALUE ftp_response_timeout) {
818
861
  CURB_IMMED_SETTER(ruby_curl_easy, ftp_response_timeout, 0);
819
862
  }
@@ -821,11 +864,11 @@ static VALUE ruby_curl_easy_ftp_response_timeout_set(VALUE self, VALUE ftp_respo
821
864
  /*
822
865
  * call-seq:
823
866
  * easy.ftp_response_timeout => fixnum or nil
824
- *
867
+ *
825
868
  * Obtain the maximum time that libcurl will wait for FTP command responses.
826
- */
869
+ */
827
870
  static VALUE ruby_curl_easy_ftp_response_timeout_get(VALUE self, VALUE ftp_response_timeout) {
828
- CURB_IMMED_GETTER(ruby_curl_easy, ftp_response_timeout, 0);
871
+ CURB_IMMED_GETTER(ruby_curl_easy, ftp_response_timeout, 0);
829
872
  }
830
873
 
831
874
  /* ================== BOOL ATTRS ===================*/
@@ -833,7 +876,7 @@ static VALUE ruby_curl_easy_ftp_response_timeout_get(VALUE self, VALUE ftp_respo
833
876
  /*
834
877
  * call-seq:
835
878
  * proxy_tunnel = boolean => boolean
836
- *
879
+ *
837
880
  * Configure whether this Curl instance will use proxy tunneling.
838
881
  */
839
882
  static VALUE ruby_curl_easy_proxy_tunnel_set(VALUE self, VALUE proxy_tunnel) {
@@ -843,7 +886,7 @@ static VALUE ruby_curl_easy_proxy_tunnel_set(VALUE self, VALUE proxy_tunnel) {
843
886
  /*
844
887
  * call-seq:
845
888
  * proxy_tunnel? => boolean
846
- *
889
+ *
847
890
  * Determine whether this Curl instance will use proxy tunneling.
848
891
  */
849
892
  static VALUE ruby_curl_easy_proxy_tunnel_q(VALUE self) {
@@ -853,7 +896,7 @@ static VALUE ruby_curl_easy_proxy_tunnel_q(VALUE self) {
853
896
  /*
854
897
  * call-seq:
855
898
  * fetch_file_time = boolean => boolean
856
- *
899
+ *
857
900
  * Configure whether this Curl instance will fetch remote file
858
901
  * times, if available.
859
902
  */
@@ -864,7 +907,7 @@ static VALUE ruby_curl_easy_fetch_file_time_set(VALUE self, VALUE fetch_file_tim
864
907
  /*
865
908
  * call-seq:
866
909
  * fetch_file_time? => boolean
867
- *
910
+ *
868
911
  * Determine whether this Curl instance will fetch remote file
869
912
  * times, if available.
870
913
  */
@@ -875,15 +918,15 @@ static VALUE ruby_curl_easy_fetch_file_time_q(VALUE self) {
875
918
  /*
876
919
  * call-seq:
877
920
  * ssl_verify_peer = boolean => boolean
878
- *
921
+ *
879
922
  * Configure whether this Curl instance will verify the SSL peer
880
- * certificate. When true (the default), and the verification fails to
881
- * prove that the certificate is authentic, the connection fails. When
923
+ * certificate. When true (the default), and the verification fails to
924
+ * prove that the certificate is authentic, the connection fails. When
882
925
  * false, the connection succeeds regardless.
883
- *
884
- * Authenticating the certificate is not by itself very useful. You
885
- * typically want to ensure that the server, as authentically identified
886
- * by its certificate, is the server you mean to be talking to.
926
+ *
927
+ * Authenticating the certificate is not by itself very useful. You
928
+ * typically want to ensure that the server, as authentically identified
929
+ * by its certificate, is the server you mean to be talking to.
887
930
  * The ssl_verify_host? options controls that.
888
931
  */
889
932
  static VALUE ruby_curl_easy_ssl_verify_peer_set(VALUE self, VALUE ssl_verify_peer) {
@@ -893,7 +936,7 @@ static VALUE ruby_curl_easy_ssl_verify_peer_set(VALUE self, VALUE ssl_verify_pee
893
936
  /*
894
937
  * call-seq:
895
938
  * ssl_verify_peer? => boolean
896
- *
939
+ *
897
940
  * Determine whether this Curl instance will verify the SSL peer
898
941
  * certificate.
899
942
  */
@@ -904,14 +947,14 @@ static VALUE ruby_curl_easy_ssl_verify_peer_q(VALUE self) {
904
947
  /*
905
948
  * call-seq:
906
949
  * ssl_verify_host = boolean => boolean
907
- *
908
- * Configure whether this Curl instance will verify that the server cert
909
- * is for the server it is known as. When true (the default) the server
910
- * certificate must indicate that the server is the server to which you
950
+ *
951
+ * Configure whether this Curl instance will verify that the server cert
952
+ * is for the server it is known as. When true (the default) the server
953
+ * certificate must indicate that the server is the server to which you
911
954
  * meant to connect, or the connection fails. When false, the connection
912
955
  * will succeed regardless of the names in the certificate.
913
- *
914
- * this option controls is of the identity that the server claims.
956
+ *
957
+ * this option controls is of the identity that the server claims.
915
958
  * The server could be lying. To control lying, see ssl_verify_peer? .
916
959
  */
917
960
  static VALUE ruby_curl_easy_ssl_verify_host_set(VALUE self, VALUE ssl_verify_host) {
@@ -921,8 +964,8 @@ static VALUE ruby_curl_easy_ssl_verify_host_set(VALUE self, VALUE ssl_verify_hos
921
964
  /*
922
965
  * call-seq:
923
966
  * ssl_verify_host? => boolean
924
- *
925
- * Determine whether this Curl instance will verify that the server cert
967
+ *
968
+ * Determine whether this Curl instance will verify that the server cert
926
969
  * is for the server it is known as.
927
970
  */
928
971
  static VALUE ruby_curl_easy_ssl_verify_host_q(VALUE self) {
@@ -932,8 +975,8 @@ static VALUE ruby_curl_easy_ssl_verify_host_q(VALUE self) {
932
975
  /*
933
976
  * call-seq:
934
977
  * header_in_body = boolean => boolean
935
- *
936
- * Configure whether this Curl instance will return HTTP headers
978
+ *
979
+ * Configure whether this Curl instance will return HTTP headers
937
980
  * combined with body data. If this option is set true, both header
938
981
  * and body data will go to +body_str+ (or the configured +on_body+ handler).
939
982
  */
@@ -944,7 +987,7 @@ static VALUE ruby_curl_easy_header_in_body_set(VALUE self, VALUE header_in_body)
944
987
  /*
945
988
  * call-seq:
946
989
  * header_in_body? => boolean
947
- *
990
+ *
948
991
  * Determine whether this Curl instance will verify the SSL peer
949
992
  * certificate.
950
993
  */
@@ -955,7 +998,7 @@ static VALUE ruby_curl_easy_header_in_body_q(VALUE self) {
955
998
  /*
956
999
  * call-seq:
957
1000
  * use_netrc = boolean => boolean
958
- *
1001
+ *
959
1002
  * Configure whether this Curl instance will use data from the user's
960
1003
  * .netrc file for FTP connections.
961
1004
  */
@@ -966,7 +1009,7 @@ static VALUE ruby_curl_easy_use_netrc_set(VALUE self, VALUE use_netrc) {
966
1009
  /*
967
1010
  * call-seq:
968
1011
  * use_netrc? => boolean
969
- *
1012
+ *
970
1013
  * Determine whether this Curl instance will use data from the user's
971
1014
  * .netrc file for FTP connections.
972
1015
  */
@@ -977,7 +1020,7 @@ static VALUE ruby_curl_easy_use_netrc_q(VALUE self) {
977
1020
  /*
978
1021
  * call-seq:
979
1022
  * follow_location = boolean => boolean
980
- *
1023
+ *
981
1024
  * Configure whether this Curl instance will follow Location: headers
982
1025
  * in HTTP responses. Redirects will only be followed to the extent
983
1026
  * specified by +max_redirects+.
@@ -989,7 +1032,7 @@ static VALUE ruby_curl_easy_follow_location_set(VALUE self, VALUE follow_locatio
989
1032
  /*
990
1033
  * call-seq:
991
1034
  * follow_location? => boolean
992
- *
1035
+ *
993
1036
  * Determine whether this Curl instance will follow Location: headers
994
1037
  * in HTTP responses.
995
1038
  */
@@ -1000,7 +1043,7 @@ static VALUE ruby_curl_easy_follow_location_q(VALUE self) {
1000
1043
  /*
1001
1044
  * call-seq:
1002
1045
  * unrestricted_auth = boolean => boolean
1003
- *
1046
+ *
1004
1047
  * Configure whether this Curl instance may use any HTTP authentication
1005
1048
  * method available when necessary.
1006
1049
  */
@@ -1011,7 +1054,7 @@ static VALUE ruby_curl_easy_unrestricted_auth_set(VALUE self, VALUE unrestricted
1011
1054
  /*
1012
1055
  * call-seq:
1013
1056
  * unrestricted_auth? => boolean
1014
- *
1057
+ *
1015
1058
  * Determine whether this Curl instance may use any HTTP authentication
1016
1059
  * method available when necessary.
1017
1060
  */
@@ -1022,7 +1065,7 @@ static VALUE ruby_curl_easy_unrestricted_auth_q(VALUE self) {
1022
1065
  /*
1023
1066
  * call-seq:
1024
1067
  * easy.verbose = boolean => boolean
1025
- *
1068
+ *
1026
1069
  * Configure whether this Curl instance gives verbose output to STDERR
1027
1070
  * during transfers. Ignored if this instance has an on_debug handler.
1028
1071
  */
@@ -1033,7 +1076,7 @@ static VALUE ruby_curl_easy_verbose_set(VALUE self, VALUE verbose) {
1033
1076
  /*
1034
1077
  * call-seq:
1035
1078
  * easy.verbose? => boolean
1036
- *
1079
+ *
1037
1080
  * Determine whether this Curl instance gives verbose output to STDERR
1038
1081
  * during transfers.
1039
1082
  */
@@ -1044,12 +1087,12 @@ static VALUE ruby_curl_easy_verbose_q(VALUE self) {
1044
1087
  /*
1045
1088
  * call-seq:
1046
1089
  * easy.multipart_form_post = boolean => boolean
1047
- *
1048
- * Configure whether this Curl instance uses multipart/formdata content
1090
+ *
1091
+ * Configure whether this Curl instance uses multipart/formdata content
1049
1092
  * type for HTTP POST requests. If this is false (the default), then the
1050
- * application/x-www-form-urlencoded content type is used for the form
1051
- * data.
1052
- *
1093
+ * application/x-www-form-urlencoded content type is used for the form
1094
+ * data.
1095
+ *
1053
1096
  * If this is set true, you must pass one or more PostField instances
1054
1097
  * to the http_post method - no support for posting multipart forms from
1055
1098
  * a string is provided.
@@ -1062,8 +1105,8 @@ static VALUE ruby_curl_easy_multipart_form_post_set(VALUE self, VALUE multipart_
1062
1105
  /*
1063
1106
  * call-seq:
1064
1107
  * easy.multipart_form_post? => boolean
1065
- *
1066
- * Determine whether this Curl instance uses multipart/formdata content
1108
+ *
1109
+ * Determine whether this Curl instance uses multipart/formdata content
1067
1110
  * type for HTTP POST requests.
1068
1111
  */
1069
1112
  static VALUE ruby_curl_easy_multipart_form_post_q(VALUE self) {
@@ -1073,7 +1116,7 @@ static VALUE ruby_curl_easy_multipart_form_post_q(VALUE self) {
1073
1116
  /*
1074
1117
  * call-seq:
1075
1118
  * easy.enable_cookies = boolean => boolean
1076
- *
1119
+ *
1077
1120
  * Configure whether the libcurl cookie engine is enabled for this Curl::Easy
1078
1121
  * instance.
1079
1122
  */
@@ -1085,8 +1128,8 @@ static VALUE ruby_curl_easy_enable_cookies_set(VALUE self, VALUE enable_cookies)
1085
1128
  /*
1086
1129
  * call-seq:
1087
1130
  * easy.enable_cookies? => boolean
1088
- *
1089
- * Determine whether the libcurl cookie engine is enabled for this
1131
+ *
1132
+ * Determine whether the libcurl cookie engine is enabled for this
1090
1133
  * Curl::Easy instance.
1091
1134
  */
1092
1135
  static VALUE ruby_curl_easy_enable_cookies_q(VALUE self) {
@@ -1098,14 +1141,14 @@ static VALUE ruby_curl_easy_enable_cookies_q(VALUE self) {
1098
1141
  /*
1099
1142
  * call-seq:
1100
1143
  * easy.on_body { |body_data| ... } => &lt;old handler&gt;
1101
- *
1144
+ *
1102
1145
  * Assign or remove the +on_body+ handler for this Curl::Easy instance.
1103
1146
  * To remove a previously-supplied handler, call this method with no
1104
1147
  * attached block.
1105
- *
1148
+ *
1106
1149
  * The +on_body+ handler is called for each chunk of response body passed back
1107
1150
  * by libcurl during +perform+. It should perform any processing necessary,
1108
- * and return the actual number of bytes handled. Normally, this will
1151
+ * and return the actual number of bytes handled. Normally, this will
1109
1152
  * equal the length of the data string, and CURL will continue processing.
1110
1153
  * If the returned length does not equal the input length, CURL will abort
1111
1154
  * the processing with a Curl::Err::AbortedByCallbackError.
@@ -1117,11 +1160,11 @@ static VALUE ruby_curl_easy_on_body_set(int argc, VALUE *argv, VALUE self) {
1117
1160
  /*
1118
1161
  * call-seq:
1119
1162
  * easy.on_success { ... } => &lt;old handler&gt;
1120
- *
1163
+ *
1121
1164
  * Assign or remove the +on_success+ handler for this Curl::Easy instance.
1122
1165
  * To remove a previously-supplied handler, call this method with no
1123
1166
  * attached block.
1124
- *
1167
+ *
1125
1168
  * The +on_success+ handler is called when the request is finished with a
1126
1169
  * status of 20x
1127
1170
  */
@@ -1132,11 +1175,11 @@ static VALUE ruby_curl_easy_on_success_set(int argc, VALUE *argv, VALUE self) {
1132
1175
  /*
1133
1176
  * call-seq:
1134
1177
  * easy.on_failure { ... } => &lt;old handler&gt;
1135
- *
1178
+ *
1136
1179
  * Assign or remove the +on_failure+ handler for this Curl::Easy instance.
1137
1180
  * To remove a previously-supplied handler, call this method with no
1138
1181
  * attached block.
1139
- *
1182
+ *
1140
1183
  * The +on_failure+ handler is called when the request is finished with a
1141
1184
  * status of 50x
1142
1185
  */
@@ -1147,11 +1190,11 @@ static VALUE ruby_curl_easy_on_failure_set(int argc, VALUE *argv, VALUE self) {
1147
1190
  /*
1148
1191
  * call-seq:
1149
1192
  * easy.on_complete { ... } => &lt;old handler&gt;
1150
- *
1193
+ *
1151
1194
  * Assign or remove the +on_complete+ handler for this Curl::Easy instance.
1152
1195
  * To remove a previously-supplied handler, call this method with no
1153
1196
  * attached block.
1154
- *
1197
+ *
1155
1198
  * The +on_complete+ handler is called when the request is finished.
1156
1199
  */
1157
1200
  static VALUE ruby_curl_easy_on_complete_set(int argc, VALUE *argv, VALUE self) {
@@ -1161,12 +1204,12 @@ static VALUE ruby_curl_easy_on_complete_set(int argc, VALUE *argv, VALUE self) {
1161
1204
  /*
1162
1205
  * call-seq:
1163
1206
  * easy.on_header { |header_data| ... } => &lt;old handler&gt;
1164
- *
1207
+ *
1165
1208
  * Assign or remove the +on_header+ handler for this Curl::Easy instance.
1166
1209
  * To remove a previously-supplied handler, call this method with no
1167
1210
  * attached block.
1168
- *
1169
- * The +on_header+ handler is called for each chunk of response header passed
1211
+ *
1212
+ * The +on_header+ handler is called for each chunk of response header passed
1170
1213
  * back by libcurl during +perform+. The semantics are the same as for the
1171
1214
  * block supplied to +on_body+.
1172
1215
  */
@@ -1177,16 +1220,16 @@ static VALUE ruby_curl_easy_on_header_set(int argc, VALUE *argv, VALUE self) {
1177
1220
  /*
1178
1221
  * call-seq:
1179
1222
  * easy.on_progress { |dl_total, dl_now, ul_total, ul_now| ... } => &lt;old handler&gt;
1180
- *
1223
+ *
1181
1224
  * Assign or remove the +on_progress+ handler for this Curl::Easy instance.
1182
1225
  * To remove a previously-supplied handler, call this method with no
1183
1226
  * attached block.
1184
- *
1227
+ *
1185
1228
  * The +on_progress+ handler is called regularly by libcurl (approximately once
1186
1229
  * per second) during transfers to allow the application to receive progress
1187
1230
  * information. There is no guarantee that the reported progress will change
1188
1231
  * between calls.
1189
- *
1232
+ *
1190
1233
  * The result of the block call determines whether libcurl continues the transfer.
1191
1234
  * Returning a non-true value (i.e. nil or false) will cause the transfer to abort,
1192
1235
  * throwing a Curl::Err::AbortedByCallbackError.
@@ -1198,16 +1241,16 @@ static VALUE ruby_curl_easy_on_progress_set(int argc, VALUE *argv, VALUE self) {
1198
1241
  /*
1199
1242
  * call-seq:
1200
1243
  * easy.on_debug { |type, data| ... } => &lt;old handler&gt;
1201
- *
1244
+ *
1202
1245
  * Assign or remove the +on_debug+ handler for this Curl::Easy instance.
1203
1246
  * To remove a previously-supplied handler, call this method with no
1204
1247
  * attached block.
1205
- *
1248
+ *
1206
1249
  * The +on_debug+ handler, if configured, will receive detailed information
1207
1250
  * from libcurl during the perform call. This can be useful for debugging.
1208
1251
  * Setting a debug handler overrides libcurl's internal handler, disabling
1209
1252
  * any output from +verbose+, if set.
1210
- *
1253
+ *
1211
1254
  * The type argument will match one of the Curl::Easy::CURLINFO_XXXX
1212
1255
  * constants, and specifies the kind of information contained in the
1213
1256
  * data. The data is passed as a String.
@@ -1224,16 +1267,16 @@ static VALUE ruby_curl_easy_on_debug_set(int argc, VALUE *argv, VALUE self) {
1224
1267
  */
1225
1268
  static VALUE cb_each_http_header(VALUE header, struct curl_slist **list) {
1226
1269
  VALUE header_str = Qnil;
1227
-
1270
+
1228
1271
  //rb_p(header);
1229
-
1272
+
1230
1273
  if (rb_type(header) == T_ARRAY) {
1231
1274
  // we're processing a hash, header is [name, val]
1232
1275
  VALUE name, value;
1233
-
1276
+
1234
1277
  name = rb_obj_as_string(rb_ary_entry(header, 0));
1235
1278
  value = rb_obj_as_string(rb_ary_entry(header, 1));
1236
-
1279
+
1237
1280
  // This is a bit inefficient, but we don't want to be modifying
1238
1281
  // the actual values in the original hash.
1239
1282
  header_str = rb_str_plus(name, rb_str_new2(": "));
@@ -1241,11 +1284,11 @@ static VALUE cb_each_http_header(VALUE header, struct curl_slist **list) {
1241
1284
  } else {
1242
1285
  header_str = rb_obj_as_string(header);
1243
1286
  }
1244
-
1287
+
1245
1288
  //rb_p(header_str);
1246
-
1289
+
1247
1290
  *list = curl_slist_append(*list, StringValuePtr(header_str));
1248
- return header_str;
1291
+ return header_str;
1249
1292
  }
1250
1293
 
1251
1294
  /***********************************************
@@ -1259,8 +1302,8 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1259
1302
  CURL *curl;
1260
1303
 
1261
1304
  curl = rbce->curl;
1262
-
1263
- if (rbce->url == Qnil) {
1305
+
1306
+ if (rbce->url == Qnil) {
1264
1307
  rb_raise(eCurlErrError, "No URL supplied");
1265
1308
  }
1266
1309
 
@@ -1268,35 +1311,35 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1268
1311
 
1269
1312
  // Need to configure the handler as per settings in rbce
1270
1313
  curl_easy_setopt(curl, CURLOPT_URL, StringValuePtr(url));
1271
-
1314
+
1272
1315
  // network stuff and auth
1273
1316
  if (rbce->interface != Qnil) {
1274
1317
  curl_easy_setopt(curl, CURLOPT_INTERFACE, StringValuePtr(rbce->interface));
1275
1318
  } else {
1276
1319
  curl_easy_setopt(curl, CURLOPT_INTERFACE, NULL);
1277
- }
1278
-
1320
+ }
1321
+
1279
1322
  if (rbce->userpwd != Qnil) {
1280
1323
  curl_easy_setopt(curl, CURLOPT_USERPWD, StringValuePtr(rbce->userpwd));
1281
1324
  } else {
1282
1325
  curl_easy_setopt(curl, CURLOPT_USERPWD, NULL);
1283
- }
1284
-
1326
+ }
1327
+
1285
1328
  if (rbce->proxy_url != Qnil) {
1286
1329
  curl_easy_setopt(curl, CURLOPT_PROXY, StringValuePtr(rbce->proxy_url));
1287
1330
  } else {
1288
1331
  curl_easy_setopt(curl, CURLOPT_PROXY, NULL);
1289
- }
1290
-
1332
+ }
1333
+
1291
1334
  if (rbce->proxypwd != Qnil) {
1292
1335
  curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, StringValuePtr(rbce->proxypwd));
1293
1336
  } else {
1294
1337
  curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, NULL);
1295
- }
1296
-
1338
+ }
1339
+
1297
1340
  // body/header procs
1298
- if (rbce->body_proc != Qnil) {
1299
- *body_buffer = Qnil;
1341
+ if (rbce->body_proc != Qnil) {
1342
+ *body_buffer = Qnil;
1300
1343
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)&proc_data_handler);
1301
1344
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, rbce->body_proc);
1302
1345
  } else {
@@ -1304,23 +1347,23 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1304
1347
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)&default_data_handler);
1305
1348
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, *body_buffer);
1306
1349
  }
1307
-
1350
+
1308
1351
  if (rbce->header_proc != Qnil) {
1309
- *header_buffer = Qnil;
1352
+ *header_buffer = Qnil;
1310
1353
  curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)&proc_data_handler);
1311
1354
  curl_easy_setopt(curl, CURLOPT_HEADERDATA, rbce->header_proc);
1312
1355
  } else {
1313
- *header_buffer = rb_str_buf_new(32768);
1356
+ *header_buffer = rb_str_buf_new(32768);
1314
1357
  curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)&default_data_handler);
1315
1358
  curl_easy_setopt(curl, CURLOPT_HEADERDATA, *header_buffer);
1316
1359
  }
1317
1360
 
1318
1361
  /* encoding */
1319
1362
  if (rbce->encoding != Qnil) {
1320
- curl_easy_setopt(curl, CURLOPT_ENCODING, StringValuePtr(rbce->encoding));
1363
+ curl_easy_setopt(curl, CURLOPT_ENCODING, StringValuePtr(rbce->encoding));
1321
1364
  }
1322
1365
 
1323
- // progress and debug procs
1366
+ // progress and debug procs
1324
1367
  if (rbce->progress_proc != Qnil) {
1325
1368
  curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, (curl_progress_callback)&proc_progress_handler);
1326
1369
  curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, rbce->progress_proc);
@@ -1328,7 +1371,7 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1328
1371
  } else {
1329
1372
  curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
1330
1373
  }
1331
-
1374
+
1332
1375
  if (rbce->debug_proc != Qnil) {
1333
1376
  curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, (curl_debug_callback)&proc_debug_handler);
1334
1377
  curl_easy_setopt(curl, CURLOPT_DEBUGDATA, rbce->debug_proc);
@@ -1338,10 +1381,10 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1338
1381
  curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, NULL);
1339
1382
  curl_easy_setopt(curl, CURLOPT_DEBUGDATA, NULL);
1340
1383
  curl_easy_setopt(curl, CURLOPT_VERBOSE, rbce->verbose);
1341
- }
1342
-
1384
+ }
1385
+
1343
1386
  /* general opts */
1344
-
1387
+
1345
1388
  curl_easy_setopt(curl, CURLOPT_HEADER, rbce->header_in_body);
1346
1389
 
1347
1390
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, rbce->follow_location);
@@ -1351,15 +1394,15 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1351
1394
  curl_easy_setopt(curl, CURLOPT_FILETIME, rbce->fetch_file_time);
1352
1395
  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, rbce->ssl_verify_peer);
1353
1396
  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, rbce->ssl_verify_peer);
1354
-
1397
+
1355
1398
  if ((rbce->use_netrc != Qnil) && (rbce->use_netrc != Qfalse)) {
1356
1399
  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, CURL_NETRC_OPTIONAL);
1357
1400
  } else {
1358
1401
  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, CURL_NETRC_IGNORED);
1359
- }
1402
+ }
1360
1403
 
1361
1404
  curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, rbce->unrestricted_auth);
1362
-
1405
+
1363
1406
  curl_easy_setopt(curl, CURLOPT_TIMEOUT, rbce->timeout);
1364
1407
  curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, rbce->connect_timeout);
1365
1408
  curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, rbce->dns_cache_timeout);
@@ -1371,25 +1414,25 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1371
1414
  rb_warn("Installed libcurl is too old to support ftp_response_timeout");
1372
1415
  }
1373
1416
  #endif
1374
-
1417
+
1375
1418
  // Set up localport / proxy port
1376
1419
  // FIXME these won't get returned to default if they're unset Ruby
1377
1420
  if (rbce->proxy_port > 0) {
1378
- curl_easy_setopt(curl, CURLOPT_PROXYPORT, rbce->proxy_port);
1421
+ curl_easy_setopt(curl, CURLOPT_PROXYPORT, rbce->proxy_port);
1379
1422
  }
1380
-
1423
+
1381
1424
  if (rbce->local_port > 0) {
1382
1425
  #if LIBCURL_VERSION_NUM >= 0x070f02
1383
1426
  curl_easy_setopt(curl, CURLOPT_LOCALPORT, rbce->local_port);
1384
-
1427
+
1385
1428
  if (rbce->local_port_range > 0) {
1386
1429
  curl_easy_setopt(curl, CURLOPT_LOCALPORTRANGE, rbce->local_port_range);
1387
1430
  }
1388
1431
  #else
1389
1432
  rb_warn("Installed libcurl is too old to support local_port");
1390
- #endif
1391
- }
1392
-
1433
+ #endif
1434
+ }
1435
+
1393
1436
  if (rbce->proxy_type != -1) {
1394
1437
  #if LIBCURL_VERSION_NUM >= 0x070a00
1395
1438
  if (rbce->proxy_type == -2) {
@@ -1400,8 +1443,8 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1400
1443
  } else {
1401
1444
  curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
1402
1445
  #else
1403
- rb_warn("Installed libcurl is too old to support proxy_type");
1404
- #endif
1446
+ rb_warn("Installed libcurl is too old to support proxy_type");
1447
+ #endif
1405
1448
  }
1406
1449
 
1407
1450
  if (rbce->http_auth_types > 0) {
@@ -1410,8 +1453,8 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1410
1453
  } else {
1411
1454
  curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
1412
1455
  #else
1413
- rb_warn("Installed libcurl is too old to support http_auth_types");
1414
- #endif
1456
+ rb_warn("Installed libcurl is too old to support http_auth_types");
1457
+ #endif
1415
1458
  }
1416
1459
 
1417
1460
  if (rbce->proxy_auth_types > 0) {
@@ -1420,10 +1463,10 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1420
1463
  } else {
1421
1464
  curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
1422
1465
  #else
1423
- rb_warn("Installed libcurl is too old to support proxy_auth_types");
1424
- #endif
1466
+ rb_warn("Installed libcurl is too old to support proxy_auth_types");
1467
+ #endif
1425
1468
  }
1426
-
1469
+
1427
1470
  /* Set up HTTP cookie handling if necessary
1428
1471
  FIXME this may not get disabled if it's enabled, the disabled again from ruby.
1429
1472
  */
@@ -1448,18 +1491,18 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1448
1491
  curl_easy_setopt(curl, CURLOPT_SSLCERT, StringValuePtr(rbce->cert));
1449
1492
  curl_easy_setopt(curl, CURLOPT_CAINFO, "/usr/local/share/curl/curl-ca-bundle.crt");
1450
1493
  }
1451
-
1494
+
1452
1495
  /* Setup HTTP headers if necessary */
1453
1496
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL); // XXX: maybe we shouldn't be clearing this?
1454
-
1455
- if (rbce->headers != Qnil) {
1497
+
1498
+ if (rbce->headers != Qnil) {
1456
1499
  if ((rb_type(rbce->headers) == T_ARRAY) || (rb_type(rbce->headers) == T_HASH)) {
1457
- rb_iterate(rb_each, rbce->headers, cb_each_http_header, (VALUE)hdrs);
1500
+ rb_iterate(rb_each, rbce->headers, cb_each_http_header, (VALUE)hdrs);
1458
1501
  } else {
1459
1502
  VALUE headers_str = rb_obj_as_string(rbce->headers);
1460
1503
  *hdrs = curl_slist_append(*hdrs, StringValuePtr(headers_str));
1461
1504
  }
1462
-
1505
+
1463
1506
  if (*hdrs) {
1464
1507
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, *hdrs);
1465
1508
  }
@@ -1480,7 +1523,7 @@ VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce, VALUE bodybuf, V
1480
1523
  curl_slist_free_all(headers);
1481
1524
  rbce->curl_headers = NULL;
1482
1525
  }
1483
-
1526
+
1484
1527
  // Sort out the built-in body/header data.
1485
1528
  if (bodybuf != Qnil) {
1486
1529
  if (TYPE(bodybuf) == T_STRING) {
@@ -1514,16 +1557,16 @@ VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce, VALUE bodybuf, V
1514
1557
  }
1515
1558
 
1516
1559
  /***********************************************
1517
- *
1560
+ *
1518
1561
  * This is the main worker for the perform methods (get, post, head, put).
1519
1562
  * It's not surfaced as a Ruby method - instead, the individual request
1520
1563
  * methods are responsible for setting up stuff specific to that type,
1521
1564
  * then calling this to handle common stuff and do the perform.
1522
- *
1565
+ *
1523
1566
  * Always returns Qtrue, rb_raise on error.
1524
- *
1567
+ *
1525
1568
  */
1526
- static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1569
+ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1527
1570
 
1528
1571
  int msgs;
1529
1572
  int still_running = 1;
@@ -1532,6 +1575,10 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1532
1575
  CURLM *multi_handle = curl_multi_init();
1533
1576
  struct curl_slist *headers = NULL;
1534
1577
  VALUE bodybuf = Qnil, headerbuf = Qnil;
1578
+ long timeout;
1579
+ struct timeval tv = {0, 0};
1580
+ int rc; /* select() return code */
1581
+ int maxfd;
1535
1582
  // char errors[CURL_ERROR_SIZE*2];
1536
1583
 
1537
1584
  ruby_curl_easy_setup(rbce, &bodybuf, &headerbuf, &headers);
@@ -1544,7 +1591,7 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1544
1591
  // else {
1545
1592
 
1546
1593
  /* NOTE:
1547
- * We create an Curl multi handle here and use rb_thread_select allowing other ruby threads to
1594
+ * We create an Curl multi handle here and use rb_thread_select allowing other ruby threads to
1548
1595
  * perform actions... ideally we'd have just 1 shared multi handle per all curl easy handles globally
1549
1596
  */
1550
1597
  mcode = curl_multi_add_handle(multi_handle, rbce->curl);
@@ -1558,10 +1605,8 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1558
1605
  raise_curl_multi_error_exception(mcode);
1559
1606
  }
1560
1607
 
1608
+
1561
1609
  while(still_running) {
1562
- struct timeval timeout;
1563
- int rc; /* select() return code */
1564
- int maxfd;
1565
1610
 
1566
1611
  fd_set fdread;
1567
1612
  fd_set fdwrite;
@@ -1578,14 +1623,33 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1578
1623
  raise_curl_multi_error_exception(mcode);
1579
1624
  }
1580
1625
 
1626
+ #ifdef HAVE_CURL_MULTI_TIMEOUT
1627
+ /* get the curl suggested time out */
1628
+ mcode = curl_multi_timeout(multi_handle, &timeout);
1629
+ if (mcode != CURLM_OK) {
1630
+ raise_curl_multi_error_exception(mcode);
1631
+ }
1632
+ #else
1633
+ /* libcurl doesn't have a timeout method defined... make a wild guess */
1634
+ timeout = 1; /* wait a second */
1635
+ #endif
1636
+
1637
+ if (timeout == 0) { /* no delay */
1638
+ while(CURLM_CALL_MULTI_PERFORM == (mcode=curl_multi_perform(multi_handle, &still_running)) );
1639
+ continue;
1640
+ }
1641
+ else if (timeout == -1) {
1642
+ timeout = 1; /* wait a second */
1643
+ }
1644
+
1581
1645
  /* set a suitable timeout to play around with - ruby seems to be greedy about this and won't necessarily yield so the timeout is small.. */
1582
- timeout.tv_sec = 0.0;
1583
- timeout.tv_usec = 100000.0;
1584
- rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
1646
+ tv.tv_sec = timeout / 1000;
1647
+ tv.tv_usec = (timeout * 1000) % 1000000;
1648
+ rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv);
1585
1649
  if (rc < 0) {
1586
1650
  rb_raise(rb_eRuntimeError, "select(): %s", strerror(errno));
1587
1651
  }
1588
-
1652
+
1589
1653
  if( rc >= 0 ) {
1590
1654
  switch(rc) {
1591
1655
  case 0:
@@ -1600,13 +1664,13 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1600
1664
  else {
1601
1665
  // error
1602
1666
  }
1603
-
1667
+
1604
1668
  if (mcode != CURLM_CALL_MULTI_PERFORM && mcode != CURLM_OK) {
1605
1669
  raise_curl_multi_error_exception(mcode);
1606
1670
  }
1607
1671
 
1608
1672
  }
1609
-
1673
+
1610
1674
  /* check for errors */
1611
1675
  CURLMsg *msg = curl_multi_info_read(multi_handle, &msgs);
1612
1676
  if (msg && msg->msg == CURLMSG_DONE) {
@@ -1618,7 +1682,7 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1618
1682
  // }
1619
1683
 
1620
1684
  ruby_curl_easy_cleanup(self, rbce, bodybuf, headerbuf, headers);
1621
-
1685
+
1622
1686
  if (rbce->complete_proc != Qnil) {
1623
1687
  rb_funcall( rbce->complete_proc, idCall, 1, self );
1624
1688
  }
@@ -1639,7 +1703,7 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1639
1703
  ((response_code >= 200 && response_code < 300) || response_code == 0)) {
1640
1704
  rb_funcall( rbce->success_proc, idCall, 1, self );
1641
1705
  }
1642
- else if (rbce->failure_proc != Qnil &&
1706
+ else if (rbce->failure_proc != Qnil &&
1643
1707
  (response_code >= 300 && response_code <= 999)) {
1644
1708
  rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, INT2FIX(result) );
1645
1709
  }
@@ -1650,20 +1714,20 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1650
1714
  /*
1651
1715
  * call-seq:
1652
1716
  * easy.http_get => true
1653
- *
1717
+ *
1654
1718
  * GET the currently configured URL using the current options set for
1655
1719
  * this Curl::Easy instance. This method always returns true, or raises
1656
1720
  * an exception (defined under Curl::Err) on error.
1657
1721
  */
1658
- static VALUE ruby_curl_easy_perform_get(VALUE self) {
1722
+ static VALUE ruby_curl_easy_perform_get(VALUE self) {
1659
1723
  ruby_curl_easy *rbce;
1660
1724
  CURL *curl;
1661
1725
 
1662
1726
  Data_Get_Struct(self, ruby_curl_easy, rbce);
1663
1727
  curl = rbce->curl;
1664
-
1728
+
1665
1729
  curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
1666
-
1730
+
1667
1731
  return handle_perform(self,rbce);
1668
1732
  }
1669
1733
 
@@ -1681,7 +1745,7 @@ static VALUE ruby_curl_easy_perform_delete(VALUE self) {
1681
1745
 
1682
1746
  Data_Get_Struct(self, ruby_curl_easy, rbce);
1683
1747
  curl = rbce->curl;
1684
-
1748
+
1685
1749
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
1686
1750
 
1687
1751
  VALUE retval = handle_perform(self,rbce);
@@ -1694,16 +1758,16 @@ static VALUE ruby_curl_easy_perform_delete(VALUE self) {
1694
1758
  /*
1695
1759
  * call-seq:
1696
1760
  * easy.perform => true
1697
- *
1761
+ *
1698
1762
  * Transfer the currently configured URL using the options set for this
1699
1763
  * Curl::Easy instance. If this is an HTTP URL, it will be transferred via
1700
1764
  * the GET or HEAD request method.
1701
1765
  */
1702
- static VALUE ruby_curl_easy_perform(VALUE self) {
1766
+ static VALUE ruby_curl_easy_perform(VALUE self) {
1703
1767
  ruby_curl_easy *rbce;
1704
1768
 
1705
1769
  Data_Get_Struct(self, ruby_curl_easy, rbce);
1706
-
1770
+
1707
1771
  return handle_perform(self,rbce);
1708
1772
  }
1709
1773
 
@@ -1713,37 +1777,37 @@ static VALUE ruby_curl_easy_perform(VALUE self) {
1713
1777
  * easy.http_post("url=encoded%20form%20data", "and=so%20on", ...) => true
1714
1778
  * easy.http_post("url=encoded%20form%20data", Curl::PostField, "and=so%20on", ...) => true
1715
1779
  * easy.http_post(Curl::PostField, Curl::PostField ..., Curl::PostField) => true
1716
- *
1717
- * POST the specified formdata to the currently configured URL using
1718
- * the current options set for this Curl::Easy instance. This method
1719
- * always returns true, or raises an exception (defined under
1780
+ *
1781
+ * POST the specified formdata to the currently configured URL using
1782
+ * the current options set for this Curl::Easy instance. This method
1783
+ * always returns true, or raises an exception (defined under
1720
1784
  * Curl::Err) on error.
1721
- *
1785
+ *
1722
1786
  * The Content-type of the POST is determined by the current setting
1723
1787
  * of multipart_form_post? , according to the following rules:
1724
- * * When false (the default): the form will be POSTed with a
1788
+ * * When false (the default): the form will be POSTed with a
1725
1789
  * content-type of 'application/x-www-form-urlencoded', and any of the
1726
- * four calling forms may be used.
1727
- * * When true: the form will be POSTed with a content-type of
1728
- * 'multipart/formdata'. Only the last calling form may be used,
1790
+ * four calling forms may be used.
1791
+ * * When true: the form will be POSTed with a content-type of
1792
+ * 'multipart/formdata'. Only the last calling form may be used,
1729
1793
  * i.e. only PostField instances may be POSTed. In this mode,
1730
1794
  * individual fields' content-types are recognised, and file upload
1731
1795
  * fields are supported.
1732
- *
1796
+ *
1733
1797
  */
1734
- static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
1798
+ static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
1735
1799
  ruby_curl_easy *rbce;
1736
1800
  CURL *curl;
1737
1801
  int i;
1738
1802
  VALUE args_ary;
1739
-
1803
+
1740
1804
  rb_scan_args(argc, argv, "*", &args_ary);
1741
-
1805
+
1742
1806
  Data_Get_Struct(self, ruby_curl_easy, rbce);
1743
1807
  curl = curl_easy_duphandle(rbce->curl);
1744
1808
  curl_easy_cleanup(rbce->curl);
1745
1809
  rbce->curl = curl;
1746
-
1810
+
1747
1811
  if (rbce->multipart_form_post) {
1748
1812
  VALUE ret;
1749
1813
  struct curl_httppost *first = NULL, *last = NULL;
@@ -1759,22 +1823,22 @@ static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
1759
1823
  }
1760
1824
 
1761
1825
  curl_easy_setopt(curl, CURLOPT_POST, 0);
1762
- curl_easy_setopt(curl, CURLOPT_HTTPPOST, first);
1763
- ret = handle_perform(self,rbce);
1826
+ curl_easy_setopt(curl, CURLOPT_HTTPPOST, first);
1827
+ ret = handle_perform(self,rbce);
1764
1828
  curl_formfree(first);
1765
-
1766
- return ret;
1829
+
1830
+ return ret;
1767
1831
  } else {
1768
1832
  long len;
1769
1833
  char *data;
1770
-
1834
+
1771
1835
  if ((rbce->postdata_buffer = rb_funcall(args_ary, idJoin, 1, rbstrAmp)) == Qnil) {
1772
1836
  rb_raise(eCurlErrError, "Failed to join arguments");
1773
1837
  return Qnil;
1774
- } else {
1775
- data = StringValuePtr(rbce->postdata_buffer);
1838
+ } else {
1839
+ data = StringValuePtr(rbce->postdata_buffer);
1776
1840
  len = RSTRING_LEN(rbce->postdata_buffer);
1777
-
1841
+
1778
1842
  curl_easy_setopt(curl, CURLOPT_POST, 1);
1779
1843
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
1780
1844
  curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, len);
@@ -1787,12 +1851,12 @@ static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
1787
1851
  /*
1788
1852
  * call-seq:
1789
1853
  * easy.http_head => true
1790
- *
1854
+ *
1791
1855
  * Request headers from the currently configured URL using the HEAD
1792
- * method and current options set for this Curl::Easy instance. This
1793
- * method always returns true, or raises an exception (defined under
1856
+ * method and current options set for this Curl::Easy instance. This
1857
+ * method always returns true, or raises an exception (defined under
1794
1858
  * Curl::Err) on error.
1795
- *
1859
+ *
1796
1860
  */
1797
1861
  static VALUE ruby_curl_easy_perform_head(VALUE self) {
1798
1862
  ruby_curl_easy *rbce;
@@ -1831,7 +1895,7 @@ static VALUE ruby_curl_easy_set_head_option(VALUE self, VALUE onoff) {
1831
1895
  /*
1832
1896
  * call-seq:
1833
1897
  * easy.http_put(data) => true
1834
- *
1898
+ *
1835
1899
  * PUT the supplied data to the currently configured URL using the
1836
1900
  * current options set for this Curl::Easy instance. This method always
1837
1901
  * returns true, or raises an exception (defined under Curl::Err) on error.
@@ -1840,21 +1904,38 @@ static VALUE ruby_curl_easy_perform_put(VALUE self, VALUE data) {
1840
1904
  ruby_curl_easy *rbce;
1841
1905
  CURL *curl;
1842
1906
 
1843
- PutStream *pstream = (PutStream*)malloc(sizeof(PutStream));
1844
- memset(pstream, 0, sizeof(PutStream));
1845
-
1846
1907
  Data_Get_Struct(self, ruby_curl_easy, rbce);
1847
- curl = rbce->curl;
1848
1908
 
1849
- pstream->len = RSTRING_LEN(data);
1850
- pstream->buffer = StringValuePtr(data);
1909
+ VALUE upload = ruby_curl_upload_new(cCurlUpload);
1910
+ ruby_curl_upload_stream_set(upload,data);
1851
1911
 
1912
+ curl = rbce->curl;
1913
+ rbce->upload = upload; /* keep the upload object alive as long as
1914
+ the easy handle is active or until the upload
1915
+ is complete or terminated... */
1852
1916
 
1853
1917
  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
1854
1918
  curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback)read_data_handler);
1855
- curl_easy_setopt(curl, CURLOPT_READDATA, pstream);
1856
- //printf("uploading %d bytes\n", pstream->len);
1857
- curl_easy_setopt(curl, CURLOPT_INFILESIZE, pstream->len);
1919
+ curl_easy_setopt(curl, CURLOPT_READDATA, rbce);
1920
+
1921
+ if (rb_respond_to(data, rb_intern("read"))) {
1922
+ VALUE stat = rb_funcall(data, rb_intern("stat"), 0);
1923
+ if( stat ) {
1924
+ ruby_curl_easy_headers_set(self,rb_str_new2("Expect:"));
1925
+ VALUE size = rb_funcall(stat, rb_intern("size"), 0);
1926
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE, FIX2INT(size));
1927
+ }
1928
+ else {
1929
+ ruby_curl_easy_headers_set(self,rb_str_new2("Transfer-Encoding: chunked"));
1930
+ }
1931
+ }
1932
+ else if (rb_respond_to(data, rb_intern("to_s"))) {
1933
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE, RSTRING_LEN(data));
1934
+ ruby_curl_easy_headers_set(self,rb_str_new2("Expect:"));
1935
+ }
1936
+ else {
1937
+ rb_raise(rb_eRuntimeError, "PUT data must respond to read or to_s");
1938
+ }
1858
1939
 
1859
1940
  VALUE ret = handle_perform(self, rbce);
1860
1941
  /* cleanup */
@@ -1871,9 +1952,9 @@ static VALUE ruby_curl_easy_perform_put(VALUE self, VALUE data) {
1871
1952
  /*
1872
1953
  * call-seq:
1873
1954
  * easy.body_str => "response body"
1874
- *
1955
+ *
1875
1956
  * Return the response body from the previous call to +perform+. This
1876
- * is populated by the default +on_body+ handler - if you supply
1957
+ * is populated by the default +on_body+ handler - if you supply
1877
1958
  * your own body handler, this string will be empty.
1878
1959
  */
1879
1960
  static VALUE ruby_curl_easy_body_str_get(VALUE self) {
@@ -1883,9 +1964,9 @@ static VALUE ruby_curl_easy_body_str_get(VALUE self) {
1883
1964
  /*
1884
1965
  * call-seq:
1885
1966
  * easy.header_str => "response header"
1886
- *
1967
+ *
1887
1968
  * Return the response header from the previous call to +perform+. This
1888
- * is populated by the default +on_header+ handler - if you supply
1969
+ * is populated by the default +on_header+ handler - if you supply
1889
1970
  * your own header handler, this string will be empty.
1890
1971
  */
1891
1972
  static VALUE ruby_curl_easy_header_str_get(VALUE self) {
@@ -1898,7 +1979,7 @@ static VALUE ruby_curl_easy_header_str_get(VALUE self) {
1898
1979
  /*
1899
1980
  * call-seq:
1900
1981
  * easy.last_effective_url => "http://some.url" or nil
1901
- *
1982
+ *
1902
1983
  * Retrieve the last effective URL used by this instance.
1903
1984
  * This is the URL used in the last +perform+ call,
1904
1985
  * and may differ from the value of easy.url.
@@ -1906,514 +1987,514 @@ static VALUE ruby_curl_easy_header_str_get(VALUE self) {
1906
1987
  static VALUE ruby_curl_easy_last_effective_url_get(VALUE self) {
1907
1988
  ruby_curl_easy *rbce;
1908
1989
  char* url;
1909
-
1910
- Data_Get_Struct(self, ruby_curl_easy, rbce);
1990
+
1991
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1911
1992
  curl_easy_getinfo(rbce->curl, CURLINFO_EFFECTIVE_URL, &url);
1912
-
1993
+
1913
1994
  if (url && url[0]) { // curl returns empty string if none
1914
1995
  return rb_str_new2(url);
1915
1996
  } else {
1916
1997
  return Qnil;
1917
1998
  }
1918
1999
  }
1919
-
2000
+
1920
2001
  /*
1921
2002
  * call-seq:
1922
2003
  * easy.response_code => fixnum
1923
- *
1924
- * Retrieve the last received HTTP or FTP code. This will be zero
1925
- * if no server response code has been received. Note that a proxy's
2004
+ *
2005
+ * Retrieve the last received HTTP or FTP code. This will be zero
2006
+ * if no server response code has been received. Note that a proxy's
1926
2007
  * CONNECT response should be read with +http_connect_code+
1927
2008
  * and not this method.
1928
2009
  */
1929
2010
  static VALUE ruby_curl_easy_response_code_get(VALUE self) {
1930
2011
  ruby_curl_easy *rbce;
1931
2012
  long code;
1932
-
1933
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2013
+
2014
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1934
2015
  #ifdef HAVE_CURLINFO_RESPONSE_CODE
1935
2016
  curl_easy_getinfo(rbce->curl, CURLINFO_RESPONSE_CODE, &code);
1936
2017
  #else
1937
2018
  // old libcurl
1938
2019
  curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CODE, &code);
1939
2020
  #endif
1940
-
1941
- return LONG2NUM(code);
2021
+
2022
+ return LONG2NUM(code);
1942
2023
  }
1943
-
2024
+
1944
2025
  /*
1945
2026
  * call-seq:
1946
2027
  * easy.http_connect_code => fixnum
1947
- *
2028
+ *
1948
2029
  * Retrieve the last received proxy response code to a CONNECT request.
1949
2030
  */
1950
2031
  static VALUE ruby_curl_easy_http_connect_code_get(VALUE self) {
1951
2032
  ruby_curl_easy *rbce;
1952
2033
  long code;
1953
-
1954
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2034
+
2035
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1955
2036
  curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CONNECTCODE, &code);
1956
-
1957
- return LONG2NUM(code);
2037
+
2038
+ return LONG2NUM(code);
1958
2039
  }
1959
-
2040
+
1960
2041
  /*
1961
2042
  * call-seq:
1962
2043
  * easy.file_time => fixnum
1963
- *
1964
- * Retrieve the remote time of the retrieved document (in number of
1965
- * seconds since 1 jan 1970 in the GMT/UTC time zone). If you get -1,
1966
- * it can be because of many reasons (unknown, the server hides it
1967
- * or the server doesn't support the command that tells document time
1968
- * etc) and the time of the document is unknown.
1969
- *
1970
- * Note that you must tell the server to collect this information
1971
- * before the transfer is made, by setting +fetch_file_time?+ to true,
2044
+ *
2045
+ * Retrieve the remote time of the retrieved document (in number of
2046
+ * seconds since 1 jan 1970 in the GMT/UTC time zone). If you get -1,
2047
+ * it can be because of many reasons (unknown, the server hides it
2048
+ * or the server doesn't support the command that tells document time
2049
+ * etc) and the time of the document is unknown.
2050
+ *
2051
+ * Note that you must tell the server to collect this information
2052
+ * before the transfer is made, by setting +fetch_file_time?+ to true,
1972
2053
  * or you will unconditionally get a -1 back.
1973
- *
1974
- * This requires libcurl 7.5 or higher - otherwise -1 is unconditionally
2054
+ *
2055
+ * This requires libcurl 7.5 or higher - otherwise -1 is unconditionally
1975
2056
  * returned.
1976
2057
  */
1977
2058
  static VALUE ruby_curl_easy_file_time_get(VALUE self) {
1978
2059
  #ifdef HAVE_CURLINFO_FILETIME
1979
2060
  ruby_curl_easy *rbce;
1980
2061
  long time;
1981
-
1982
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2062
+
2063
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1983
2064
  curl_easy_getinfo(rbce->curl, CURLINFO_FILETIME, &time);
1984
-
2065
+
1985
2066
  return LONG2NUM(time);
1986
2067
  #else
1987
2068
  rb_warn("Installed libcurl is too old to support file_time");
1988
- return INT2FIX(0);
2069
+ return INT2FIX(0);
1989
2070
  #endif
1990
2071
  }
1991
-
2072
+
1992
2073
  /*
1993
2074
  * call-seq:
1994
2075
  * easy.total_time => float
1995
- *
1996
- * Retrieve the total time in seconds for the previous transfer,
1997
- * including name resolving, TCP connect etc.
2076
+ *
2077
+ * Retrieve the total time in seconds for the previous transfer,
2078
+ * including name resolving, TCP connect etc.
1998
2079
  */
1999
2080
  static VALUE ruby_curl_easy_total_time_get(VALUE self) {
2000
2081
  ruby_curl_easy *rbce;
2001
2082
  double time;
2002
-
2003
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2083
+
2084
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2004
2085
  curl_easy_getinfo(rbce->curl, CURLINFO_TOTAL_TIME, &time);
2005
-
2006
- return rb_float_new(time);
2086
+
2087
+ return rb_float_new(time);
2007
2088
  }
2008
-
2089
+
2009
2090
  /*
2010
2091
  * call-seq:
2011
2092
  * easy.name_lookup_time => float
2012
- *
2093
+ *
2013
2094
  * Retrieve the time, in seconds, it took from the start until the
2014
- * name resolving was completed.
2095
+ * name resolving was completed.
2015
2096
  */
2016
2097
  static VALUE ruby_curl_easy_name_lookup_time_get(VALUE self) {
2017
2098
  ruby_curl_easy *rbce;
2018
2099
  double time;
2019
-
2020
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2100
+
2101
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2021
2102
  curl_easy_getinfo(rbce->curl, CURLINFO_NAMELOOKUP_TIME, &time);
2022
-
2023
- return rb_float_new(time);
2103
+
2104
+ return rb_float_new(time);
2024
2105
  }
2025
-
2106
+
2026
2107
  /*
2027
2108
  * call-seq:
2028
2109
  * easy.connect_time => float
2029
- *
2110
+ *
2030
2111
  * Retrieve the time, in seconds, it took from the start until the
2031
- * connect to the remote host (or proxy) was completed.
2112
+ * connect to the remote host (or proxy) was completed.
2032
2113
  */
2033
2114
  static VALUE ruby_curl_easy_connect_time_get(VALUE self) {
2034
2115
  ruby_curl_easy *rbce;
2035
2116
  double time;
2036
-
2037
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2117
+
2118
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2038
2119
  curl_easy_getinfo(rbce->curl, CURLINFO_CONNECT_TIME, &time);
2039
-
2040
- return rb_float_new(time);
2120
+
2121
+ return rb_float_new(time);
2041
2122
  }
2042
-
2123
+
2043
2124
  /*
2044
2125
  * call-seq:
2045
2126
  * easy.pre_transfer_time => float
2046
- *
2047
- * Retrieve the time, in seconds, it took from the start until the
2048
- * file transfer is just about to begin. This includes all pre-transfer
2049
- * commands and negotiations that are specific to the particular protocol(s)
2050
- * involved.
2127
+ *
2128
+ * Retrieve the time, in seconds, it took from the start until the
2129
+ * file transfer is just about to begin. This includes all pre-transfer
2130
+ * commands and negotiations that are specific to the particular protocol(s)
2131
+ * involved.
2051
2132
  */
2052
2133
  static VALUE ruby_curl_easy_pre_transfer_time_get(VALUE self) {
2053
2134
  ruby_curl_easy *rbce;
2054
2135
  double time;
2055
-
2056
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2136
+
2137
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2057
2138
  curl_easy_getinfo(rbce->curl, CURLINFO_PRETRANSFER_TIME, &time);
2058
-
2059
- return rb_float_new(time);
2139
+
2140
+ return rb_float_new(time);
2060
2141
  }
2061
-
2142
+
2062
2143
  /*
2063
2144
  * call-seq:
2064
2145
  * easy.start_transfer_time => float
2065
- *
2066
- * Retrieve the time, in seconds, it took from the start until the first byte
2067
- * is just about to be transferred. This includes the +pre_transfer_time+ and
2068
- * also the time the server needs to calculate the result.
2146
+ *
2147
+ * Retrieve the time, in seconds, it took from the start until the first byte
2148
+ * is just about to be transferred. This includes the +pre_transfer_time+ and
2149
+ * also the time the server needs to calculate the result.
2069
2150
  */
2070
2151
  static VALUE ruby_curl_easy_start_transfer_time_get(VALUE self) {
2071
2152
  ruby_curl_easy *rbce;
2072
2153
  double time;
2073
-
2074
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2154
+
2155
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2075
2156
  curl_easy_getinfo(rbce->curl, CURLINFO_STARTTRANSFER_TIME, &time);
2076
-
2077
- return rb_float_new(time);
2157
+
2158
+ return rb_float_new(time);
2078
2159
  }
2079
-
2160
+
2080
2161
  /*
2081
2162
  * call-seq:
2082
2163
  * easy.redirect_time => float
2083
- *
2164
+ *
2084
2165
  * Retrieve the total time, in seconds, it took for all redirection steps
2085
- * include name lookup, connect, pretransfer and transfer before final
2086
- * transaction was started. +redirect_time+ contains the complete
2166
+ * include name lookup, connect, pretransfer and transfer before final
2167
+ * transaction was started. +redirect_time+ contains the complete
2087
2168
  * execution time for multiple redirections.
2088
- *
2169
+ *
2089
2170
  * Requires libcurl 7.9.7 or higher, otherwise -1 is always returned.
2090
2171
  */
2091
2172
  static VALUE ruby_curl_easy_redirect_time_get(VALUE self) {
2092
2173
  #ifdef HAVE_CURLINFO_REDIRECT_TIME
2093
2174
  ruby_curl_easy *rbce;
2094
2175
  double time;
2095
-
2096
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2176
+
2177
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2097
2178
  curl_easy_getinfo(rbce->curl, CURLINFO_REDIRECT_TIME, &time);
2098
-
2099
- return rb_float_new(time);
2179
+
2180
+ return rb_float_new(time);
2100
2181
  #else
2101
2182
  rb_warn("Installed libcurl is too old to support redirect_time");
2102
2183
  return rb_float_new(-1);
2103
2184
  #endif
2104
2185
  }
2105
-
2186
+
2106
2187
  /*
2107
2188
  * call-seq:
2108
2189
  * easy.redirect_count => integer
2109
- *
2190
+ *
2110
2191
  * Retrieve the total number of redirections that were actually followed.
2111
- *
2192
+ *
2112
2193
  * Requires libcurl 7.9.7 or higher, otherwise -1 is always returned.
2113
2194
  */
2114
2195
  static VALUE ruby_curl_easy_redirect_count_get(VALUE self) {
2115
2196
  #ifdef HAVE_CURLINFO_REDIRECT_COUNT
2116
2197
  ruby_curl_easy *rbce;
2117
2198
  long count;
2118
-
2119
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2199
+
2200
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2120
2201
  curl_easy_getinfo(rbce->curl, CURLINFO_REDIRECT_COUNT, &count);
2121
-
2202
+
2122
2203
  return LONG2NUM(count);
2123
2204
  #else
2124
2205
  rb_warn("Installed libcurl is too old to support redirect_count");
2125
2206
  return INT2FIX(-1);
2126
2207
  #endif
2127
-
2208
+
2128
2209
  }
2129
-
2210
+
2130
2211
  /*
2131
2212
  * call-seq:
2132
2213
  * easy.uploaded_bytes => float
2133
- *
2214
+ *
2134
2215
  * Retrieve the total amount of bytes that were uploaded in the
2135
2216
  * preceeding transfer.
2136
2217
  */
2137
2218
  static VALUE ruby_curl_easy_uploaded_bytes_get(VALUE self) {
2138
2219
  ruby_curl_easy *rbce;
2139
2220
  double bytes;
2140
-
2141
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2221
+
2222
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2142
2223
  curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_UPLOAD, &bytes);
2143
-
2144
- return rb_float_new(bytes);
2224
+
2225
+ return rb_float_new(bytes);
2145
2226
  }
2146
-
2227
+
2147
2228
  /*
2148
2229
  * call-seq:
2149
2230
  * easy.downloaded_bytes => float
2150
- *
2231
+ *
2151
2232
  * Retrieve the total amount of bytes that were downloaded in the
2152
2233
  * preceeding transfer.
2153
2234
  */
2154
2235
  static VALUE ruby_curl_easy_downloaded_bytes_get(VALUE self) {
2155
2236
  ruby_curl_easy *rbce;
2156
2237
  double bytes;
2157
-
2158
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2238
+
2239
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2159
2240
  curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_DOWNLOAD, &bytes);
2160
-
2161
- return rb_float_new(bytes);
2241
+
2242
+ return rb_float_new(bytes);
2162
2243
  }
2163
-
2244
+
2164
2245
  /*
2165
2246
  * call-seq:
2166
2247
  * easy.upload_speed => float
2167
- *
2168
- * Retrieve the average upload speed that curl measured for the
2169
- * preceeding complete upload.
2248
+ *
2249
+ * Retrieve the average upload speed that curl measured for the
2250
+ * preceeding complete upload.
2170
2251
  */
2171
2252
  static VALUE ruby_curl_easy_upload_speed_get(VALUE self) {
2172
2253
  ruby_curl_easy *rbce;
2173
2254
  double bytes;
2174
-
2175
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2255
+
2256
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2176
2257
  curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_UPLOAD, &bytes);
2177
-
2178
- return rb_float_new(bytes);
2258
+
2259
+ return rb_float_new(bytes);
2179
2260
  }
2180
-
2261
+
2181
2262
  /*
2182
2263
  * call-seq:
2183
2264
  * easy.download_speed => float
2184
- *
2185
- * Retrieve the average download speed that curl measured for
2186
- * the preceeding complete download.
2265
+ *
2266
+ * Retrieve the average download speed that curl measured for
2267
+ * the preceeding complete download.
2187
2268
  */
2188
2269
  static VALUE ruby_curl_easy_download_speed_get(VALUE self) {
2189
2270
  ruby_curl_easy *rbce;
2190
2271
  double bytes;
2191
-
2192
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2272
+
2273
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2193
2274
  curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_DOWNLOAD, &bytes);
2194
-
2195
- return rb_float_new(bytes);
2275
+
2276
+ return rb_float_new(bytes);
2196
2277
  }
2197
-
2278
+
2198
2279
  /*
2199
2280
  * call-seq:
2200
2281
  * easy.header_size => fixnum
2201
- *
2202
- * Retrieve the total size of all the headers received in the
2282
+ *
2283
+ * Retrieve the total size of all the headers received in the
2203
2284
  * preceeding transfer.
2204
2285
  */
2205
2286
  static VALUE ruby_curl_easy_header_size_get(VALUE self) {
2206
2287
  ruby_curl_easy *rbce;
2207
2288
  long size;
2208
-
2209
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2289
+
2290
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2210
2291
  curl_easy_getinfo(rbce->curl, CURLINFO_HEADER_SIZE, &size);
2211
-
2212
- return LONG2NUM(size);
2292
+
2293
+ return LONG2NUM(size);
2213
2294
  }
2214
-
2295
+
2215
2296
  /*
2216
2297
  * call-seq:
2217
2298
  * easy.request_size => fixnum
2218
- *
2219
- * Retrieve the total size of the issued requests. This is so far
2299
+ *
2300
+ * Retrieve the total size of the issued requests. This is so far
2220
2301
  * only for HTTP requests. Note that this may be more than one request
2221
- * if +follow_location?+ is true.
2302
+ * if +follow_location?+ is true.
2222
2303
  */
2223
2304
  static VALUE ruby_curl_easy_request_size_get(VALUE self) {
2224
2305
  ruby_curl_easy *rbce;
2225
2306
  long size;
2226
-
2227
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2307
+
2308
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2228
2309
  curl_easy_getinfo(rbce->curl, CURLINFO_REQUEST_SIZE, &size);
2229
-
2230
- return LONG2NUM(size);
2310
+
2311
+ return LONG2NUM(size);
2231
2312
  }
2232
-
2313
+
2233
2314
  /*
2234
2315
  * call-seq:
2235
2316
  * easy.ssl_verify_result => integer
2236
- *
2237
- * Retrieve the result of the certification verification that was requested
2238
- * (by setting +ssl_verify_peer?+ to +true+).
2317
+ *
2318
+ * Retrieve the result of the certification verification that was requested
2319
+ * (by setting +ssl_verify_peer?+ to +true+).
2239
2320
  */
2240
2321
  static VALUE ruby_curl_easy_ssl_verify_result_get(VALUE self) {
2241
2322
  ruby_curl_easy *rbce;
2242
2323
  long result;
2243
-
2244
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2324
+
2325
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2245
2326
  curl_easy_getinfo(rbce->curl, CURLINFO_SSL_VERIFYRESULT, &result);
2246
-
2247
- return LONG2NUM(result);
2327
+
2328
+ return LONG2NUM(result);
2248
2329
  }
2249
-
2250
- /* TODO CURLINFO_SSL_ENGINES
2251
2330
 
2252
- Pass the address of a 'struct curl_slist *' to receive a linked-list of OpenSSL crypto-engines supported. Note that engines are normally implemented in separate dynamic libraries. Hence not all the returned engines may be available at run-time. NOTE: you must call curl_slist_free_all(3) on the list pointer once you're done with it, as libcurl will not free the data for you. (Added in 7.12.3)
2331
+ /* TODO CURLINFO_SSL_ENGINES
2332
+
2333
+ Pass the address of a 'struct curl_slist *' to receive a linked-list of OpenSSL crypto-engines supported. Note that engines are normally implemented in separate dynamic libraries. Hence not all the returned engines may be available at run-time. NOTE: you must call curl_slist_free_all(3) on the list pointer once you're done with it, as libcurl will not free the data for you. (Added in 7.12.3)
2253
2334
  */
2254
2335
 
2255
2336
  /*
2256
2337
  * call-seq:
2257
2338
  * easy.downloaded_content_length => float
2258
- *
2259
- * Retrieve the content-length of the download. This is the value read
2260
- * from the Content-Length: field.
2339
+ *
2340
+ * Retrieve the content-length of the download. This is the value read
2341
+ * from the Content-Length: field.
2261
2342
  */
2262
2343
  static VALUE ruby_curl_easy_downloaded_content_length_get(VALUE self) {
2263
2344
  ruby_curl_easy *rbce;
2264
2345
  double bytes;
2265
-
2266
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2346
+
2347
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2267
2348
  curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &bytes);
2268
-
2269
- return rb_float_new(bytes);
2349
+
2350
+ return rb_float_new(bytes);
2270
2351
  }
2271
-
2352
+
2272
2353
  /*
2273
2354
  * call-seq:
2274
2355
  * easy.uploaded_content_length => float
2275
- *
2356
+ *
2276
2357
  * Retrieve the content-length of the upload.
2277
2358
  */
2278
2359
  static VALUE ruby_curl_easy_uploaded_content_length_get(VALUE self) {
2279
2360
  ruby_curl_easy *rbce;
2280
2361
  double bytes;
2281
-
2282
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2362
+
2363
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2283
2364
  curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &bytes);
2284
-
2285
- return rb_float_new(bytes);
2365
+
2366
+ return rb_float_new(bytes);
2286
2367
  }
2287
-
2368
+
2288
2369
  /*
2289
2370
  * call-seq:
2290
2371
  * easy.content_type => "content/type" or nil
2291
- *
2372
+ *
2292
2373
  * Retrieve the content-type of the downloaded object. This is the value read
2293
- * from the Content-Type: field. If you get +nil+, it means that the server
2294
- * didn't send a valid Content-Type header or that the protocol used doesn't
2295
- * support this.
2374
+ * from the Content-Type: field. If you get +nil+, it means that the server
2375
+ * didn't send a valid Content-Type header or that the protocol used doesn't
2376
+ * support this.
2296
2377
  */
2297
2378
  static VALUE ruby_curl_easy_content_type_get(VALUE self) {
2298
2379
  ruby_curl_easy *rbce;
2299
2380
  char* type;
2300
-
2301
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2381
+
2382
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2302
2383
  curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_TYPE, &type);
2303
-
2384
+
2304
2385
  if (type && type[0]) { // curl returns empty string if none
2305
2386
  return rb_str_new2(type);
2306
2387
  } else {
2307
2388
  return Qnil;
2308
2389
  }
2309
2390
  }
2310
-
2311
2391
 
2312
- /* NOT REQUIRED?
2313
- CURLINFO_PRIVATE
2314
2392
 
2315
- Pass a pointer to a 'char *' to receive the pointer to the private data associated with the curl handle (set with the CURLOPT_PRIVATE option to curl_easy_setopt(3)). (Added in 7.10.3)
2393
+ /* NOT REQUIRED?
2394
+ CURLINFO_PRIVATE
2395
+
2396
+ Pass a pointer to a 'char *' to receive the pointer to the private data associated with the curl handle (set with the CURLOPT_PRIVATE option to curl_easy_setopt(3)). (Added in 7.10.3)
2316
2397
  */
2317
2398
 
2318
2399
  /* TODO these will need constants setting up too for checking the bits.
2319
- *
2320
- * Alternatively, could return an object that wraps the long, and has
2400
+ *
2401
+ * Alternatively, could return an object that wraps the long, and has
2321
2402
  * question methods to query the auth types. Could return long from to_i(nt)
2322
2403
  *
2323
- CURLINFO_HTTPAUTH_AVAIL
2404
+ CURLINFO_HTTPAUTH_AVAIL
2324
2405
 
2325
- Pass a pointer to a long to receive a bitmask indicating the authentication method(s) available. The meaning of the bits is explained in the CURLOPT_HTTPAUTH option for curl_easy_setopt(3). (Added in 7.10.8)
2406
+ Pass a pointer to a long to receive a bitmask indicating the authentication method(s) available. The meaning of the bits is explained in the CURLOPT_HTTPAUTH option for curl_easy_setopt(3). (Added in 7.10.8)
2326
2407
 
2327
- CURLINFO_PROXYAUTH_AVAIL
2408
+ CURLINFO_PROXYAUTH_AVAIL
2328
2409
 
2329
- Pass a pointer to a long to receive a bitmask indicating the authentication method(s) available for your proxy authentication. (Added in 7.10.8)
2410
+ Pass a pointer to a long to receive a bitmask indicating the authentication method(s) available for your proxy authentication. (Added in 7.10.8)
2330
2411
  */
2331
2412
 
2332
2413
  /*
2333
2414
  * call-seq:
2334
2415
  * easy.os_errno => integer
2335
- *
2336
- * Retrieve the errno variable from a connect failure (requires
2416
+ *
2417
+ * Retrieve the errno variable from a connect failure (requires
2337
2418
  * libcurl 7.12.2 or higher, otherwise 0 is always returned).
2338
2419
  */
2339
2420
  static VALUE ruby_curl_easy_os_errno_get(VALUE self) {
2340
2421
  #ifdef HAVE_CURLINFO_OS_ERRNO
2341
2422
  ruby_curl_easy *rbce;
2342
2423
  long result;
2343
-
2344
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2424
+
2425
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2345
2426
  curl_easy_getinfo(rbce->curl, CURLINFO_OS_ERRNO, &result);
2346
-
2347
- return LONG2NUM(result);
2427
+
2428
+ return LONG2NUM(result);
2348
2429
  #else
2349
2430
  rb_warn("Installed libcurl is too old to support os_errno");
2350
2431
  return INT2FIX(0);
2351
2432
  #endif
2352
2433
  }
2353
-
2434
+
2354
2435
  /*
2355
2436
  * call-seq:
2356
2437
  * easy.num_connects => integer
2357
- *
2358
- * Retrieve the number of new connections libcurl had to create to achieve
2359
- * the previous transfer (only the successful connects are counted).
2360
- * Combined with +redirect_count+ you are able to know how many times libcurl
2361
- * successfully reused existing connection(s) or not.
2362
- *
2438
+ *
2439
+ * Retrieve the number of new connections libcurl had to create to achieve
2440
+ * the previous transfer (only the successful connects are counted).
2441
+ * Combined with +redirect_count+ you are able to know how many times libcurl
2442
+ * successfully reused existing connection(s) or not.
2443
+ *
2363
2444
  * See the Connection Options of curl_easy_setopt(3) to see how libcurl tries
2364
2445
  * to make persistent connections to save time.
2365
- *
2446
+ *
2366
2447
  * (requires libcurl 7.12.3 or higher, otherwise -1 is always returned).
2367
2448
  */
2368
2449
  static VALUE ruby_curl_easy_num_connects_get(VALUE self) {
2369
2450
  #ifdef HAVE_CURLINFO_NUM_CONNECTS
2370
2451
  ruby_curl_easy *rbce;
2371
2452
  long result;
2372
-
2373
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2453
+
2454
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2374
2455
  curl_easy_getinfo(rbce->curl, CURLINFO_NUM_CONNECTS, &result);
2375
-
2376
- return LONG2NUM(result);
2456
+
2457
+ return LONG2NUM(result);
2377
2458
  #else
2378
2459
  rb_warn("Installed libcurl is too old to support num_connects");
2379
2460
  return INT2FIX(-1);
2380
2461
  #endif
2381
2462
  }
2382
-
2463
+
2383
2464
 
2384
2465
  /* TODO this needs to be implemented.
2385
2466
 
2386
- CURLINFO_COOKIELIST
2467
+ CURLINFO_COOKIELIST
2387
2468
 
2388
- Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all cookies cURL knows (expired ones, too). Don't forget to curl_slist_free_all(3) the list after it has been used. If there are no cookies (cookies for the handle have not been enabled or simply none have been received) 'struct curl_slist *' will be set to point to NULL. (Added in 7.14.1)
2469
+ Pass a pointer to a 'struct curl_slist *' to receive a linked-list of all cookies cURL knows (expired ones, too). Don't forget to curl_slist_free_all(3) the list after it has been used. If there are no cookies (cookies for the handle have not been enabled or simply none have been received) 'struct curl_slist *' will be set to point to NULL. (Added in 7.14.1)
2389
2470
  */
2390
2471
 
2391
2472
  /* TODO this needs to be implemented. Could probably support CONNECT_ONLY by having this
2392
2473
  * return an open Socket or something.
2393
2474
  *
2394
- CURLINFO_LASTSOCKET
2475
+ CURLINFO_LASTSOCKET
2395
2476
 
2396
- Pass a pointer to a long to receive the last socket used by this curl session. If the socket is no longer valid, -1 is returned. When you finish working with the socket, you must call curl_easy_cleanup() as usual and let libcurl close the socket and cleanup other resources associated with the handle. This is typically used in combination with CURLOPT_CONNECT_ONLY. (Added in 7.15.2)
2477
+ Pass a pointer to a long to receive the last socket used by this curl session. If the socket is no longer valid, -1 is returned. When you finish working with the socket, you must call curl_easy_cleanup() as usual and let libcurl close the socket and cleanup other resources associated with the handle. This is typically used in combination with CURLOPT_CONNECT_ONLY. (Added in 7.15.2)
2397
2478
  */
2398
2479
 
2399
2480
  /*
2400
2481
  * call-seq:
2401
2482
  * easy.content_type => "content/type" or nil
2402
- *
2403
- * Retrieve the path of the entry path. That is the initial path libcurl ended
2404
- * up in when logging on to the remote FTP server. This returns +nil+ if
2483
+ *
2484
+ * Retrieve the path of the entry path. That is the initial path libcurl ended
2485
+ * up in when logging on to the remote FTP server. This returns +nil+ if
2405
2486
  * something is wrong.
2406
- *
2487
+ *
2407
2488
  * (requires libcurl 7.15.4 or higher, otherwise +nil+ is always returned).
2408
2489
  */
2409
2490
  static VALUE ruby_curl_easy_ftp_entry_path_get(VALUE self) {
2410
2491
  #ifdef HAVE_CURLINFO_FTP_ENTRY_PATH
2411
2492
  ruby_curl_easy *rbce;
2412
2493
  char* path = NULL;
2413
-
2414
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2494
+
2495
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2415
2496
  curl_easy_getinfo(rbce->curl, CURLINFO_FTP_ENTRY_PATH, &path);
2416
-
2497
+
2417
2498
  if (path && path[0]) { // curl returns NULL or empty string if none
2418
2499
  return rb_str_new2(path);
2419
2500
  } else {
@@ -2424,17 +2505,17 @@ static VALUE ruby_curl_easy_ftp_entry_path_get(VALUE self) {
2424
2505
  return Qnil;
2425
2506
  #endif
2426
2507
  }
2427
-
2508
+
2428
2509
 
2429
2510
  /* ================== ESCAPING FUNCS ==============*/
2430
2511
 
2431
- /*
2512
+ /*
2432
2513
  * call-seq:
2433
2514
  * easy.escape("some text") => "some%20text"
2434
- *
2515
+ *
2435
2516
  * Convert the given input string to a URL encoded string and return
2436
- * the result. All input characters that are not a-z, A-Z or 0-9 are
2437
- * converted to their "URL escaped" version (%NN where NN is a
2517
+ * the result. All input characters that are not a-z, A-Z or 0-9 are
2518
+ * converted to their "URL escaped" version (%NN where NN is a
2438
2519
  * two-digit hexadecimal number).
2439
2520
  */
2440
2521
  static VALUE ruby_curl_easy_escape(VALUE self, VALUE str) {
@@ -2443,7 +2524,7 @@ static VALUE ruby_curl_easy_escape(VALUE self, VALUE str) {
2443
2524
  VALUE rresult;
2444
2525
 
2445
2526
  Data_Get_Struct(self, ruby_curl_easy, rbce);
2446
-
2527
+
2447
2528
  #if (LIBCURL_VERSION_NUM >= 0x070f04)
2448
2529
  result = (char*)curl_easy_escape(rbce->curl, StringValuePtr(str), RSTRING_LEN(str));
2449
2530
  #else
@@ -2451,17 +2532,17 @@ static VALUE ruby_curl_easy_escape(VALUE self, VALUE str) {
2451
2532
  #endif
2452
2533
 
2453
2534
  rresult = rb_str_new2(result);
2454
- curl_free(result);
2455
-
2535
+ curl_free(result);
2536
+
2456
2537
  return rresult;
2457
2538
  }
2458
2539
 
2459
2540
  /*
2460
2541
  * call-seq:
2461
2542
  * easy.unescape("some text") => "some%20text"
2462
- *
2543
+ *
2463
2544
  * Convert the given URL encoded input string to a "plain string" and return
2464
- * the result. All input characters that are URL encoded (%XX where XX is a
2545
+ * the result. All input characters that are URL encoded (%XX where XX is a
2465
2546
  * two-digit hexadecimal number) are converted to their binary versions.
2466
2547
  */
2467
2548
  static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
@@ -2469,9 +2550,9 @@ static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
2469
2550
  int rlen;
2470
2551
  char *result;
2471
2552
  VALUE rresult;
2472
-
2553
+
2473
2554
  Data_Get_Struct(self, ruby_curl_easy, rbce);
2474
-
2555
+
2475
2556
  #if (LIBCURL_VERSION_NUM >= 0x070f04)
2476
2557
  result = (char*)curl_easy_unescape(rbce->curl, StringValuePtr(str), RSTRING_LEN(str), &rlen);
2477
2558
  #else
@@ -2480,8 +2561,8 @@ static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
2480
2561
  #endif
2481
2562
 
2482
2563
  rresult = rb_str_new(result, rlen);
2483
- curl_free(result);
2484
-
2564
+ curl_free(result);
2565
+
2485
2566
  return rresult;
2486
2567
  }
2487
2568
 
@@ -2491,63 +2572,63 @@ static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
2491
2572
  /*
2492
2573
  * call-seq:
2493
2574
  * Curl::Easy.perform(url) { |easy| ... } => #&lt;Curl::Easy...&gt;
2494
- *
2495
- * Convenience method that creates a new Curl::Easy instance with
2496
- * the specified URL and calls the general +perform+ method, before returning
2575
+ *
2576
+ * Convenience method that creates a new Curl::Easy instance with
2577
+ * the specified URL and calls the general +perform+ method, before returning
2497
2578
  * the new instance. For HTTP URLs, this is equivalent to calling +http_get+.
2498
- *
2579
+ *
2499
2580
  * If a block is supplied, the new instance will be yielded just prior to
2500
2581
  * the +http_get+ call.
2501
2582
  */
2502
2583
  static VALUE ruby_curl_easy_class_perform(int argc, VALUE *argv, VALUE klass) {
2503
- VALUE c = ruby_curl_easy_new(argc, argv, klass);
2504
-
2584
+ VALUE c = ruby_curl_easy_new(argc, argv, klass);
2585
+
2505
2586
  if (rb_block_given_p()) {
2506
2587
  rb_yield(c);
2507
2588
  }
2508
-
2589
+
2509
2590
  ruby_curl_easy_perform(c);
2510
- return c;
2591
+ return c;
2511
2592
  }
2512
2593
 
2513
2594
  /*
2514
2595
  * call-seq:
2515
2596
  * Curl::Easy.http_get(url) { |easy| ... } => #&lt;Curl::Easy...&gt;
2516
- *
2517
- * Convenience method that creates a new Curl::Easy instance with
2597
+ *
2598
+ * Convenience method that creates a new Curl::Easy instance with
2518
2599
  * the specified URL and calls +http_get+, before returning the new instance.
2519
- *
2600
+ *
2520
2601
  * If a block is supplied, the new instance will be yielded just prior to
2521
2602
  * the +http_get+ call.
2522
2603
  */
2523
2604
  static VALUE ruby_curl_easy_class_perform_get(int argc, VALUE *argv, VALUE klass) {
2524
- VALUE c = ruby_curl_easy_new(argc, argv, klass);
2525
-
2605
+ VALUE c = ruby_curl_easy_new(argc, argv, klass);
2606
+
2526
2607
  if (rb_block_given_p()) {
2527
2608
  rb_yield(c);
2528
2609
  }
2529
-
2610
+
2530
2611
  ruby_curl_easy_perform_get(c);
2531
- return c;
2612
+ return c;
2532
2613
  }
2533
2614
 
2534
2615
  /*
2535
2616
  * call-seq:
2536
2617
  * Curl::Easy.http_delete(url) { |easy| ... } => #&lt;Curl::Easy...&gt;
2537
- *
2538
- * Convenience method that creates a new Curl::Easy instance with
2618
+ *
2619
+ * Convenience method that creates a new Curl::Easy instance with
2539
2620
  * the specified URL and calls +http_delete+, before returning the new instance.
2540
- *
2621
+ *
2541
2622
  * If a block is supplied, the new instance will be yielded just prior to
2542
2623
  * the +http_delete+ call.
2543
2624
  */
2544
2625
  static VALUE ruby_curl_easy_class_perform_delete(int argc, VALUE *argv, VALUE klass) {
2545
- VALUE c = ruby_curl_easy_new(argc, argv, klass);
2546
-
2626
+ VALUE c = ruby_curl_easy_new(argc, argv, klass);
2627
+
2547
2628
  if (rb_block_given_p()) {
2548
2629
  rb_yield(c);
2549
2630
  }
2550
-
2631
+
2551
2632
  ruby_curl_easy_perform_delete(c);
2552
2633
  return c;
2553
2634
  }
@@ -2581,30 +2662,30 @@ static VALUE ruby_curl_easy_class_perform_head(int argc, VALUE *argv, VALUE klas
2581
2662
  * Curl::Easy.http_post(url, "some=urlencoded%20form%20data", "and=so%20on", ...) => true
2582
2663
  * Curl::Easy.http_post(url, "some=urlencoded%20form%20data", Curl::PostField, "and=so%20on", ...) => true
2583
2664
  * Curl::Easy.http_post(url, Curl::PostField, Curl::PostField ..., Curl::PostField) => true
2584
- *
2585
- * POST the specified formdata to the currently configured URL using
2586
- * the current options set for this Curl::Easy instance. This method
2587
- * always returns true, or raises an exception (defined under
2665
+ *
2666
+ * POST the specified formdata to the currently configured URL using
2667
+ * the current options set for this Curl::Easy instance. This method
2668
+ * always returns true, or raises an exception (defined under
2588
2669
  * Curl::Err) on error.
2589
- *
2670
+ *
2590
2671
  * If you wish to use multipart form encoding, you'll need to supply a block
2591
- * in order to set multipart_form_post true. See #http_post for more
2672
+ * in order to set multipart_form_post true. See #http_post for more
2592
2673
  * information.
2593
2674
  */
2594
- static VALUE ruby_curl_easy_class_perform_post(int argc, VALUE *argv, VALUE klass) {
2675
+ static VALUE ruby_curl_easy_class_perform_post(int argc, VALUE *argv, VALUE klass) {
2595
2676
  VALUE url, fields;
2596
-
2677
+
2597
2678
  rb_scan_args(argc, argv, "1*", &url, &fields);
2598
-
2599
- VALUE c = ruby_curl_easy_new(1, &url, klass);
2600
-
2679
+
2680
+ VALUE c = ruby_curl_easy_new(1, &url, klass);
2681
+
2601
2682
  if (argc > 1) {
2602
2683
  ruby_curl_easy_perform_post(argc - 1, &argv[1], c);
2603
2684
  } else {
2604
2685
  ruby_curl_easy_perform_post(0, NULL, c);
2605
- }
2606
-
2607
- return c;
2686
+ }
2687
+
2688
+ return c;
2608
2689
  }
2609
2690
 
2610
2691
 
@@ -2612,10 +2693,10 @@ static VALUE ruby_curl_easy_class_perform_post(int argc, VALUE *argv, VALUE klas
2612
2693
  void init_curb_easy() {
2613
2694
  idCall = rb_intern("call");
2614
2695
  idJoin = rb_intern("join");
2615
-
2696
+
2616
2697
  rbstrAmp = rb_str_new2("&");
2617
2698
  rb_global_variable(&rbstrAmp);
2618
-
2699
+
2619
2700
  cCurlEasy = rb_define_class_under(mCurl, "Easy", rb_cObject);
2620
2701
 
2621
2702
  /* Class methods */
@@ -2628,7 +2709,7 @@ void init_curb_easy() {
2628
2709
 
2629
2710
  /* Attributes for config next perform */
2630
2711
  rb_define_method(cCurlEasy, "url=", ruby_curl_easy_url_set, 1);
2631
- rb_define_method(cCurlEasy, "url", ruby_curl_easy_url_get, 0);
2712
+ rb_define_method(cCurlEasy, "url", ruby_curl_easy_url_get, 0);
2632
2713
  rb_define_method(cCurlEasy, "proxy_url=", ruby_curl_easy_proxy_url_set, 1);
2633
2714
  rb_define_method(cCurlEasy, "proxy_url", ruby_curl_easy_proxy_url_get, 0);
2634
2715
  rb_define_method(cCurlEasy, "headers=", ruby_curl_easy_headers_set, 1);
@@ -2672,7 +2753,7 @@ void init_curb_easy() {
2672
2753
  rb_define_method(cCurlEasy, "dns_cache_timeout", ruby_curl_easy_dns_cache_timeout_get, 0);
2673
2754
  rb_define_method(cCurlEasy, "ftp_response_timeout=", ruby_curl_easy_ftp_response_timeout_set, 1);
2674
2755
  rb_define_method(cCurlEasy, "ftp_response_timeout", ruby_curl_easy_ftp_response_timeout_get, 0);
2675
-
2756
+
2676
2757
  rb_define_method(cCurlEasy, "proxy_tunnel=", ruby_curl_easy_proxy_tunnel_set, 1);
2677
2758
  rb_define_method(cCurlEasy, "proxy_tunnel?", ruby_curl_easy_proxy_tunnel_q, 0);
2678
2759
  rb_define_method(cCurlEasy, "fetch_file_time=", ruby_curl_easy_fetch_file_time_set, 1);
@@ -2721,7 +2802,6 @@ void init_curb_easy() {
2721
2802
  rb_define_method(cCurlEasy, "http_connect_code", ruby_curl_easy_http_connect_code_get, 0);
2722
2803
  rb_define_method(cCurlEasy, "file_time", ruby_curl_easy_file_time_get, 0);
2723
2804
  rb_define_method(cCurlEasy, "total_time", ruby_curl_easy_total_time_get, 0);
2724
- rb_define_method(cCurlEasy, "total_time", ruby_curl_easy_total_time_get, 0);
2725
2805
  rb_define_method(cCurlEasy, "name_lookup_time", ruby_curl_easy_name_lookup_time_get, 0);
2726
2806
  rb_define_method(cCurlEasy, "connect_time", ruby_curl_easy_connect_time_get, 0);
2727
2807
  rb_define_method(cCurlEasy, "pre_transfer_time", ruby_curl_easy_pre_transfer_time_get, 0);
@@ -2748,5 +2828,5 @@ void init_curb_easy() {
2748
2828
 
2749
2829
  /* Runtime support */
2750
2830
  rb_define_method(cCurlEasy, "clone", ruby_curl_easy_clone, 0);
2751
- rb_define_alias(cCurlEasy, "dup", "clone");
2831
+ rb_define_alias(cCurlEasy, "dup", "clone");
2752
2832
  }