curb 0.3.7 → 0.4.2.0

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

Potentially problematic release.


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

data/Rakefile CHANGED
@@ -4,6 +4,12 @@ require 'rake/clean'
4
4
  require 'rake/testtask'
5
5
  require 'rake/rdoctask'
6
6
 
7
+ #begin
8
+ # require 'rake/gempackagetask'
9
+ #rescue LoadError
10
+ # $stderr.puts("Rubygems support disabled")
11
+ #end
12
+
7
13
  CLEAN.include '**/*.o'
8
14
  CLEAN.include "**/*.#{Config::MAKEFILE_CONFIG['DLEXT']}"
9
15
  CLOBBER.include 'doc'
@@ -61,7 +67,7 @@ file CURB_SO => (['ext/Makefile'] + Dir['ext/*.c'] + Dir['ext/*.h']) do
61
67
  end
62
68
 
63
69
  desc "Compile the shared object"
64
- task :compile => CURB_SO
70
+ task :compile => [CURB_SO]
65
71
 
66
72
  desc "Install to your site_ruby directory"
67
73
  task :install => :alltests do
@@ -72,7 +78,11 @@ end
72
78
  # Test Tasks ---------------------------------------------------------
73
79
  task :ta => :alltests
74
80
  task :tu => :unittests
75
- task :test => :unittests
81
+ task :test => [:rmpid,:unittests]
82
+
83
+ task :rmpid do
84
+ sh "rm -rf tests/server_lock-*"
85
+ end
76
86
 
77
87
  if ENV['RELTEST']
78
88
  announce "Release task testing - not running regression tests on alltests"
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.3.7"
24
- #define CURB_VER_NUM 370
23
+ #define CURB_VERSION "0.4.2"
24
+ #define CURB_VER_NUM 420
25
25
  #define CURB_VER_MAJ 0
26
- #define CURB_VER_MIN 3
27
- #define CURB_VER_MIC 7
26
+ #define CURB_VER_MIN 4
27
+ #define CURB_VER_MIC 2
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
-
@@ -38,7 +38,20 @@
38
38
  #define HAVE_CURLE_SSL_ENGINE_INITFAILED 1
39
39
  #define HAVE_CURLE_LOGIN_DENIED 1
40
40
  #define HAVE_CURLMOPT_MAXCONNECTS 1
41
- #define HAVE_CURLMOPT_PIPELINING 1
41
+ #define HAVE_CURLE_CONV_FAILED 1
42
+ #define HAVE_CURLE_CONV_REQD 1
43
+ #define HAVE_CURLE_SSL_CACERT_BADFILE 1
44
+ #define HAVE_CURLE_REMOTE_FILE_NOT_FOUND 1
45
+ #define HAVE_CURLE_SSH 1
46
+ #define HAVE_CURLE_SSL_SHUTDOWN_FAILED 1
47
+ #define HAVE_CURLE_AGAIN 1
48
+ #define HAVE_CURLE_SSL_CRL_BADFILE 1
49
+ #define HAVE_CURLE_SSL_ISSUER_ERROR 1
50
+ #define HAVE_CURLM_BAD_SOCKET 1
51
+ #define HAVE_CURLM_UNKNOWN_OPTION 1
52
+ #define HAVE_CURL_MULTI_TIMEOUT 1
53
+ #define HAVE_CURL_MULTI_FDSET 1
54
+ #define HAVE_CURL_MULTI_PERFORM 1
42
55
  #define HAVE_RUBY19_ST_H 1
43
56
  #define HAVE_CURL_EASY_ESCAPE 1
44
57
  #endif
@@ -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,22 +1557,18 @@ 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
- int msgs;
1529
- int still_running = 1;
1530
1571
  CURLcode result = -1;
1531
- CURLMcode mcode = -1;
1532
- CURLM *multi_handle = curl_multi_init();
1533
1572
  struct curl_slist *headers = NULL;
1534
1573
  VALUE bodybuf = Qnil, headerbuf = Qnil;
1535
1574
  // char errors[CURL_ERROR_SIZE*2];
@@ -1538,13 +1577,21 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1538
1577
  // curl_easy_setopt(rbce->curl, CURLOPT_ERRORBUFFER, errors);
1539
1578
  // curl_easy_setopt(rbce->curl, CURLOPT_VERBOSE, 1);
1540
1579
 
1541
- // if( rb_thread_alone() ) {
1542
- // result = curl_easy_perform(rbce->curl);
1543
- // }
1544
- // else {
1580
+ if( rb_thread_alone() ) {
1581
+ result = curl_easy_perform(rbce->curl);
1582
+ }
1583
+ else {
1584
+ int msgs;
1585
+ int still_running = 1;
1586
+ CURLMcode mcode = -1;
1587
+ CURLM *multi_handle = curl_multi_init();
1588
+ long timeout;
1589
+ struct timeval tv = {0, 0};
1590
+ int rc; /* select() return code */
1591
+ int maxfd;
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) {
@@ -1615,10 +1679,10 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1615
1679
 
1616
1680
  curl_multi_remove_handle(multi_handle, rbce->curl);
1617
1681
  curl_multi_cleanup(multi_handle);
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
  }
@@ -1629,7 +1693,7 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1629
1693
  if (result != 0) {
1630
1694
  // printf("error: %s\n", errors);
1631
1695
  if (rbce->failure_proc != Qnil) {
1632
- rb_funcall( rbce->failure_proc, idCall, 1, self );
1696
+ rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, INT2FIX(result) );
1633
1697
  } else {
1634
1698
  raise_curl_easy_error_exception(result);
1635
1699
  }
@@ -1639,9 +1703,9 @@ 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
- rb_funcall( rbce->failure_proc, idCall, 1, self );
1708
+ rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, INT2FIX(result) );
1645
1709
  }
1646
1710
 
1647
1711
  return Qtrue;
@@ -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,52 @@ 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
+ /*
1922
+ * we need to set specific headers for the PUT to work... so
1923
+ * convert the internal headers structure to a HASH if one is set
1924
+ */
1925
+ if (rbce->headers != Qnil) {
1926
+ if (rb_type(rbce->headers) == T_ARRAY || rb_type(rbce->headers) == T_STRING) {
1927
+ rb_raise(rb_eRuntimeError, "Must set headers as a HASH to modify the headers in an http_put request");
1928
+ }
1929
+ }
1930
+
1931
+ if (rb_respond_to(data, rb_intern("read"))) {
1932
+ VALUE stat = rb_funcall(data, rb_intern("stat"), 0);
1933
+ if( stat ) {
1934
+ if( rb_hash_aref(rbce->headers, rb_str_new2("Expect")) == Qnil ) {
1935
+ rb_hash_aset(rbce->headers, rb_str_new2("Expect"), rb_str_new2(""));
1936
+ }
1937
+ VALUE size = rb_funcall(stat, rb_intern("size"), 0);
1938
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE, FIX2INT(size));
1939
+ }
1940
+ else if( rb_hash_aref(rbce->headers, rb_str_new2("Transfer-Encoding")) == Qnil ) {
1941
+ rb_hash_aset(rbce->headers, rb_str_new2("Transfer-Encoding"), rb_str_new2("chunked"));
1942
+ }
1943
+ }
1944
+ else if (rb_respond_to(data, rb_intern("to_s"))) {
1945
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE, RSTRING_LEN(data));
1946
+ if( rb_hash_aref(rbce->headers, rb_str_new2("Expect")) == Qnil ) {
1947
+ rb_hash_aset(rbce->headers, rb_str_new2("Expect"), rb_str_new2(""));
1948
+ }
1949
+ }
1950
+ else {
1951
+ rb_raise(rb_eRuntimeError, "PUT data must respond to read or to_s");
1952
+ }
1858
1953
 
1859
1954
  VALUE ret = handle_perform(self, rbce);
1860
1955
  /* cleanup */
@@ -1871,9 +1966,9 @@ static VALUE ruby_curl_easy_perform_put(VALUE self, VALUE data) {
1871
1966
  /*
1872
1967
  * call-seq:
1873
1968
  * easy.body_str => "response body"
1874
- *
1969
+ *
1875
1970
  * Return the response body from the previous call to +perform+. This
1876
- * is populated by the default +on_body+ handler - if you supply
1971
+ * is populated by the default +on_body+ handler - if you supply
1877
1972
  * your own body handler, this string will be empty.
1878
1973
  */
1879
1974
  static VALUE ruby_curl_easy_body_str_get(VALUE self) {
@@ -1883,9 +1978,9 @@ static VALUE ruby_curl_easy_body_str_get(VALUE self) {
1883
1978
  /*
1884
1979
  * call-seq:
1885
1980
  * easy.header_str => "response header"
1886
- *
1981
+ *
1887
1982
  * Return the response header from the previous call to +perform+. This
1888
- * is populated by the default +on_header+ handler - if you supply
1983
+ * is populated by the default +on_header+ handler - if you supply
1889
1984
  * your own header handler, this string will be empty.
1890
1985
  */
1891
1986
  static VALUE ruby_curl_easy_header_str_get(VALUE self) {
@@ -1898,7 +1993,7 @@ static VALUE ruby_curl_easy_header_str_get(VALUE self) {
1898
1993
  /*
1899
1994
  * call-seq:
1900
1995
  * easy.last_effective_url => "http://some.url" or nil
1901
- *
1996
+ *
1902
1997
  * Retrieve the last effective URL used by this instance.
1903
1998
  * This is the URL used in the last +perform+ call,
1904
1999
  * and may differ from the value of easy.url.
@@ -1906,514 +2001,514 @@ static VALUE ruby_curl_easy_header_str_get(VALUE self) {
1906
2001
  static VALUE ruby_curl_easy_last_effective_url_get(VALUE self) {
1907
2002
  ruby_curl_easy *rbce;
1908
2003
  char* url;
1909
-
1910
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2004
+
2005
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1911
2006
  curl_easy_getinfo(rbce->curl, CURLINFO_EFFECTIVE_URL, &url);
1912
-
2007
+
1913
2008
  if (url && url[0]) { // curl returns empty string if none
1914
2009
  return rb_str_new2(url);
1915
2010
  } else {
1916
2011
  return Qnil;
1917
2012
  }
1918
2013
  }
1919
-
2014
+
1920
2015
  /*
1921
2016
  * call-seq:
1922
2017
  * 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
2018
+ *
2019
+ * Retrieve the last received HTTP or FTP code. This will be zero
2020
+ * if no server response code has been received. Note that a proxy's
1926
2021
  * CONNECT response should be read with +http_connect_code+
1927
2022
  * and not this method.
1928
2023
  */
1929
2024
  static VALUE ruby_curl_easy_response_code_get(VALUE self) {
1930
2025
  ruby_curl_easy *rbce;
1931
2026
  long code;
1932
-
1933
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2027
+
2028
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1934
2029
  #ifdef HAVE_CURLINFO_RESPONSE_CODE
1935
2030
  curl_easy_getinfo(rbce->curl, CURLINFO_RESPONSE_CODE, &code);
1936
2031
  #else
1937
2032
  // old libcurl
1938
2033
  curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CODE, &code);
1939
2034
  #endif
1940
-
1941
- return LONG2NUM(code);
2035
+
2036
+ return LONG2NUM(code);
1942
2037
  }
1943
-
2038
+
1944
2039
  /*
1945
2040
  * call-seq:
1946
2041
  * easy.http_connect_code => fixnum
1947
- *
2042
+ *
1948
2043
  * Retrieve the last received proxy response code to a CONNECT request.
1949
2044
  */
1950
2045
  static VALUE ruby_curl_easy_http_connect_code_get(VALUE self) {
1951
2046
  ruby_curl_easy *rbce;
1952
2047
  long code;
1953
-
1954
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2048
+
2049
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1955
2050
  curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CONNECTCODE, &code);
1956
-
1957
- return LONG2NUM(code);
2051
+
2052
+ return LONG2NUM(code);
1958
2053
  }
1959
-
2054
+
1960
2055
  /*
1961
2056
  * call-seq:
1962
2057
  * 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,
2058
+ *
2059
+ * Retrieve the remote time of the retrieved document (in number of
2060
+ * seconds since 1 jan 1970 in the GMT/UTC time zone). If you get -1,
2061
+ * it can be because of many reasons (unknown, the server hides it
2062
+ * or the server doesn't support the command that tells document time
2063
+ * etc) and the time of the document is unknown.
2064
+ *
2065
+ * Note that you must tell the server to collect this information
2066
+ * before the transfer is made, by setting +fetch_file_time?+ to true,
1972
2067
  * or you will unconditionally get a -1 back.
1973
- *
1974
- * This requires libcurl 7.5 or higher - otherwise -1 is unconditionally
2068
+ *
2069
+ * This requires libcurl 7.5 or higher - otherwise -1 is unconditionally
1975
2070
  * returned.
1976
2071
  */
1977
2072
  static VALUE ruby_curl_easy_file_time_get(VALUE self) {
1978
2073
  #ifdef HAVE_CURLINFO_FILETIME
1979
2074
  ruby_curl_easy *rbce;
1980
2075
  long time;
1981
-
1982
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2076
+
2077
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1983
2078
  curl_easy_getinfo(rbce->curl, CURLINFO_FILETIME, &time);
1984
-
2079
+
1985
2080
  return LONG2NUM(time);
1986
2081
  #else
1987
2082
  rb_warn("Installed libcurl is too old to support file_time");
1988
- return INT2FIX(0);
2083
+ return INT2FIX(0);
1989
2084
  #endif
1990
2085
  }
1991
-
2086
+
1992
2087
  /*
1993
2088
  * call-seq:
1994
2089
  * easy.total_time => float
1995
- *
1996
- * Retrieve the total time in seconds for the previous transfer,
1997
- * including name resolving, TCP connect etc.
2090
+ *
2091
+ * Retrieve the total time in seconds for the previous transfer,
2092
+ * including name resolving, TCP connect etc.
1998
2093
  */
1999
2094
  static VALUE ruby_curl_easy_total_time_get(VALUE self) {
2000
2095
  ruby_curl_easy *rbce;
2001
2096
  double time;
2002
-
2003
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2097
+
2098
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2004
2099
  curl_easy_getinfo(rbce->curl, CURLINFO_TOTAL_TIME, &time);
2005
-
2006
- return rb_float_new(time);
2100
+
2101
+ return rb_float_new(time);
2007
2102
  }
2008
-
2103
+
2009
2104
  /*
2010
2105
  * call-seq:
2011
2106
  * easy.name_lookup_time => float
2012
- *
2107
+ *
2013
2108
  * Retrieve the time, in seconds, it took from the start until the
2014
- * name resolving was completed.
2109
+ * name resolving was completed.
2015
2110
  */
2016
2111
  static VALUE ruby_curl_easy_name_lookup_time_get(VALUE self) {
2017
2112
  ruby_curl_easy *rbce;
2018
2113
  double time;
2019
-
2020
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2114
+
2115
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2021
2116
  curl_easy_getinfo(rbce->curl, CURLINFO_NAMELOOKUP_TIME, &time);
2022
-
2023
- return rb_float_new(time);
2117
+
2118
+ return rb_float_new(time);
2024
2119
  }
2025
-
2120
+
2026
2121
  /*
2027
2122
  * call-seq:
2028
2123
  * easy.connect_time => float
2029
- *
2124
+ *
2030
2125
  * Retrieve the time, in seconds, it took from the start until the
2031
- * connect to the remote host (or proxy) was completed.
2126
+ * connect to the remote host (or proxy) was completed.
2032
2127
  */
2033
2128
  static VALUE ruby_curl_easy_connect_time_get(VALUE self) {
2034
2129
  ruby_curl_easy *rbce;
2035
2130
  double time;
2036
-
2037
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2131
+
2132
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2038
2133
  curl_easy_getinfo(rbce->curl, CURLINFO_CONNECT_TIME, &time);
2039
-
2040
- return rb_float_new(time);
2134
+
2135
+ return rb_float_new(time);
2041
2136
  }
2042
-
2137
+
2043
2138
  /*
2044
2139
  * call-seq:
2045
2140
  * 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.
2141
+ *
2142
+ * Retrieve the time, in seconds, it took from the start until the
2143
+ * file transfer is just about to begin. This includes all pre-transfer
2144
+ * commands and negotiations that are specific to the particular protocol(s)
2145
+ * involved.
2051
2146
  */
2052
2147
  static VALUE ruby_curl_easy_pre_transfer_time_get(VALUE self) {
2053
2148
  ruby_curl_easy *rbce;
2054
2149
  double time;
2055
-
2056
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2150
+
2151
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2057
2152
  curl_easy_getinfo(rbce->curl, CURLINFO_PRETRANSFER_TIME, &time);
2058
-
2059
- return rb_float_new(time);
2153
+
2154
+ return rb_float_new(time);
2060
2155
  }
2061
-
2156
+
2062
2157
  /*
2063
2158
  * call-seq:
2064
2159
  * 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.
2160
+ *
2161
+ * Retrieve the time, in seconds, it took from the start until the first byte
2162
+ * is just about to be transferred. This includes the +pre_transfer_time+ and
2163
+ * also the time the server needs to calculate the result.
2069
2164
  */
2070
2165
  static VALUE ruby_curl_easy_start_transfer_time_get(VALUE self) {
2071
2166
  ruby_curl_easy *rbce;
2072
2167
  double time;
2073
-
2074
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2168
+
2169
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2075
2170
  curl_easy_getinfo(rbce->curl, CURLINFO_STARTTRANSFER_TIME, &time);
2076
-
2077
- return rb_float_new(time);
2171
+
2172
+ return rb_float_new(time);
2078
2173
  }
2079
-
2174
+
2080
2175
  /*
2081
2176
  * call-seq:
2082
2177
  * easy.redirect_time => float
2083
- *
2178
+ *
2084
2179
  * 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
2180
+ * include name lookup, connect, pretransfer and transfer before final
2181
+ * transaction was started. +redirect_time+ contains the complete
2087
2182
  * execution time for multiple redirections.
2088
- *
2183
+ *
2089
2184
  * Requires libcurl 7.9.7 or higher, otherwise -1 is always returned.
2090
2185
  */
2091
2186
  static VALUE ruby_curl_easy_redirect_time_get(VALUE self) {
2092
2187
  #ifdef HAVE_CURLINFO_REDIRECT_TIME
2093
2188
  ruby_curl_easy *rbce;
2094
2189
  double time;
2095
-
2096
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2190
+
2191
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2097
2192
  curl_easy_getinfo(rbce->curl, CURLINFO_REDIRECT_TIME, &time);
2098
-
2099
- return rb_float_new(time);
2193
+
2194
+ return rb_float_new(time);
2100
2195
  #else
2101
2196
  rb_warn("Installed libcurl is too old to support redirect_time");
2102
2197
  return rb_float_new(-1);
2103
2198
  #endif
2104
2199
  }
2105
-
2200
+
2106
2201
  /*
2107
2202
  * call-seq:
2108
2203
  * easy.redirect_count => integer
2109
- *
2204
+ *
2110
2205
  * Retrieve the total number of redirections that were actually followed.
2111
- *
2206
+ *
2112
2207
  * Requires libcurl 7.9.7 or higher, otherwise -1 is always returned.
2113
2208
  */
2114
2209
  static VALUE ruby_curl_easy_redirect_count_get(VALUE self) {
2115
2210
  #ifdef HAVE_CURLINFO_REDIRECT_COUNT
2116
2211
  ruby_curl_easy *rbce;
2117
2212
  long count;
2118
-
2119
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2213
+
2214
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2120
2215
  curl_easy_getinfo(rbce->curl, CURLINFO_REDIRECT_COUNT, &count);
2121
-
2216
+
2122
2217
  return LONG2NUM(count);
2123
2218
  #else
2124
2219
  rb_warn("Installed libcurl is too old to support redirect_count");
2125
2220
  return INT2FIX(-1);
2126
2221
  #endif
2127
-
2222
+
2128
2223
  }
2129
-
2224
+
2130
2225
  /*
2131
2226
  * call-seq:
2132
2227
  * easy.uploaded_bytes => float
2133
- *
2228
+ *
2134
2229
  * Retrieve the total amount of bytes that were uploaded in the
2135
2230
  * preceeding transfer.
2136
2231
  */
2137
2232
  static VALUE ruby_curl_easy_uploaded_bytes_get(VALUE self) {
2138
2233
  ruby_curl_easy *rbce;
2139
2234
  double bytes;
2140
-
2141
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2235
+
2236
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2142
2237
  curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_UPLOAD, &bytes);
2143
-
2144
- return rb_float_new(bytes);
2238
+
2239
+ return rb_float_new(bytes);
2145
2240
  }
2146
-
2241
+
2147
2242
  /*
2148
2243
  * call-seq:
2149
2244
  * easy.downloaded_bytes => float
2150
- *
2245
+ *
2151
2246
  * Retrieve the total amount of bytes that were downloaded in the
2152
2247
  * preceeding transfer.
2153
2248
  */
2154
2249
  static VALUE ruby_curl_easy_downloaded_bytes_get(VALUE self) {
2155
2250
  ruby_curl_easy *rbce;
2156
2251
  double bytes;
2157
-
2158
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2252
+
2253
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2159
2254
  curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_DOWNLOAD, &bytes);
2160
-
2161
- return rb_float_new(bytes);
2255
+
2256
+ return rb_float_new(bytes);
2162
2257
  }
2163
-
2258
+
2164
2259
  /*
2165
2260
  * call-seq:
2166
2261
  * easy.upload_speed => float
2167
- *
2168
- * Retrieve the average upload speed that curl measured for the
2169
- * preceeding complete upload.
2262
+ *
2263
+ * Retrieve the average upload speed that curl measured for the
2264
+ * preceeding complete upload.
2170
2265
  */
2171
2266
  static VALUE ruby_curl_easy_upload_speed_get(VALUE self) {
2172
2267
  ruby_curl_easy *rbce;
2173
2268
  double bytes;
2174
-
2175
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2269
+
2270
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2176
2271
  curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_UPLOAD, &bytes);
2177
-
2178
- return rb_float_new(bytes);
2272
+
2273
+ return rb_float_new(bytes);
2179
2274
  }
2180
-
2275
+
2181
2276
  /*
2182
2277
  * call-seq:
2183
2278
  * easy.download_speed => float
2184
- *
2185
- * Retrieve the average download speed that curl measured for
2186
- * the preceeding complete download.
2279
+ *
2280
+ * Retrieve the average download speed that curl measured for
2281
+ * the preceeding complete download.
2187
2282
  */
2188
2283
  static VALUE ruby_curl_easy_download_speed_get(VALUE self) {
2189
2284
  ruby_curl_easy *rbce;
2190
2285
  double bytes;
2191
-
2192
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2286
+
2287
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2193
2288
  curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_DOWNLOAD, &bytes);
2194
-
2195
- return rb_float_new(bytes);
2289
+
2290
+ return rb_float_new(bytes);
2196
2291
  }
2197
-
2292
+
2198
2293
  /*
2199
2294
  * call-seq:
2200
2295
  * easy.header_size => fixnum
2201
- *
2202
- * Retrieve the total size of all the headers received in the
2296
+ *
2297
+ * Retrieve the total size of all the headers received in the
2203
2298
  * preceeding transfer.
2204
2299
  */
2205
2300
  static VALUE ruby_curl_easy_header_size_get(VALUE self) {
2206
2301
  ruby_curl_easy *rbce;
2207
2302
  long size;
2208
-
2209
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2303
+
2304
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2210
2305
  curl_easy_getinfo(rbce->curl, CURLINFO_HEADER_SIZE, &size);
2211
-
2212
- return LONG2NUM(size);
2306
+
2307
+ return LONG2NUM(size);
2213
2308
  }
2214
-
2309
+
2215
2310
  /*
2216
2311
  * call-seq:
2217
2312
  * easy.request_size => fixnum
2218
- *
2219
- * Retrieve the total size of the issued requests. This is so far
2313
+ *
2314
+ * Retrieve the total size of the issued requests. This is so far
2220
2315
  * only for HTTP requests. Note that this may be more than one request
2221
- * if +follow_location?+ is true.
2316
+ * if +follow_location?+ is true.
2222
2317
  */
2223
2318
  static VALUE ruby_curl_easy_request_size_get(VALUE self) {
2224
2319
  ruby_curl_easy *rbce;
2225
2320
  long size;
2226
-
2227
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2321
+
2322
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2228
2323
  curl_easy_getinfo(rbce->curl, CURLINFO_REQUEST_SIZE, &size);
2229
-
2230
- return LONG2NUM(size);
2324
+
2325
+ return LONG2NUM(size);
2231
2326
  }
2232
-
2327
+
2233
2328
  /*
2234
2329
  * call-seq:
2235
2330
  * 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+).
2331
+ *
2332
+ * Retrieve the result of the certification verification that was requested
2333
+ * (by setting +ssl_verify_peer?+ to +true+).
2239
2334
  */
2240
2335
  static VALUE ruby_curl_easy_ssl_verify_result_get(VALUE self) {
2241
2336
  ruby_curl_easy *rbce;
2242
2337
  long result;
2243
-
2244
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2338
+
2339
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2245
2340
  curl_easy_getinfo(rbce->curl, CURLINFO_SSL_VERIFYRESULT, &result);
2246
-
2247
- return LONG2NUM(result);
2341
+
2342
+ return LONG2NUM(result);
2248
2343
  }
2249
-
2250
- /* TODO CURLINFO_SSL_ENGINES
2251
2344
 
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)
2345
+ /* TODO CURLINFO_SSL_ENGINES
2346
+
2347
+ 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
2348
  */
2254
2349
 
2255
2350
  /*
2256
2351
  * call-seq:
2257
2352
  * 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.
2353
+ *
2354
+ * Retrieve the content-length of the download. This is the value read
2355
+ * from the Content-Length: field.
2261
2356
  */
2262
2357
  static VALUE ruby_curl_easy_downloaded_content_length_get(VALUE self) {
2263
2358
  ruby_curl_easy *rbce;
2264
2359
  double bytes;
2265
-
2266
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2360
+
2361
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2267
2362
  curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &bytes);
2268
-
2269
- return rb_float_new(bytes);
2363
+
2364
+ return rb_float_new(bytes);
2270
2365
  }
2271
-
2366
+
2272
2367
  /*
2273
2368
  * call-seq:
2274
2369
  * easy.uploaded_content_length => float
2275
- *
2370
+ *
2276
2371
  * Retrieve the content-length of the upload.
2277
2372
  */
2278
2373
  static VALUE ruby_curl_easy_uploaded_content_length_get(VALUE self) {
2279
2374
  ruby_curl_easy *rbce;
2280
2375
  double bytes;
2281
-
2282
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2376
+
2377
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2283
2378
  curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &bytes);
2284
-
2285
- return rb_float_new(bytes);
2379
+
2380
+ return rb_float_new(bytes);
2286
2381
  }
2287
-
2382
+
2288
2383
  /*
2289
2384
  * call-seq:
2290
2385
  * easy.content_type => "content/type" or nil
2291
- *
2386
+ *
2292
2387
  * 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.
2388
+ * from the Content-Type: field. If you get +nil+, it means that the server
2389
+ * didn't send a valid Content-Type header or that the protocol used doesn't
2390
+ * support this.
2296
2391
  */
2297
2392
  static VALUE ruby_curl_easy_content_type_get(VALUE self) {
2298
2393
  ruby_curl_easy *rbce;
2299
2394
  char* type;
2300
-
2301
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2395
+
2396
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2302
2397
  curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_TYPE, &type);
2303
-
2398
+
2304
2399
  if (type && type[0]) { // curl returns empty string if none
2305
2400
  return rb_str_new2(type);
2306
2401
  } else {
2307
2402
  return Qnil;
2308
2403
  }
2309
2404
  }
2310
-
2311
2405
 
2312
- /* NOT REQUIRED?
2313
- CURLINFO_PRIVATE
2314
2406
 
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)
2407
+ /* NOT REQUIRED?
2408
+ CURLINFO_PRIVATE
2409
+
2410
+ 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
2411
  */
2317
2412
 
2318
2413
  /* 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
2414
+ *
2415
+ * Alternatively, could return an object that wraps the long, and has
2321
2416
  * question methods to query the auth types. Could return long from to_i(nt)
2322
2417
  *
2323
- CURLINFO_HTTPAUTH_AVAIL
2418
+ CURLINFO_HTTPAUTH_AVAIL
2324
2419
 
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)
2420
+ 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
2421
 
2327
- CURLINFO_PROXYAUTH_AVAIL
2422
+ CURLINFO_PROXYAUTH_AVAIL
2328
2423
 
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)
2424
+ 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
2425
  */
2331
2426
 
2332
2427
  /*
2333
2428
  * call-seq:
2334
2429
  * easy.os_errno => integer
2335
- *
2336
- * Retrieve the errno variable from a connect failure (requires
2430
+ *
2431
+ * Retrieve the errno variable from a connect failure (requires
2337
2432
  * libcurl 7.12.2 or higher, otherwise 0 is always returned).
2338
2433
  */
2339
2434
  static VALUE ruby_curl_easy_os_errno_get(VALUE self) {
2340
2435
  #ifdef HAVE_CURLINFO_OS_ERRNO
2341
2436
  ruby_curl_easy *rbce;
2342
2437
  long result;
2343
-
2344
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2438
+
2439
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2345
2440
  curl_easy_getinfo(rbce->curl, CURLINFO_OS_ERRNO, &result);
2346
-
2347
- return LONG2NUM(result);
2441
+
2442
+ return LONG2NUM(result);
2348
2443
  #else
2349
2444
  rb_warn("Installed libcurl is too old to support os_errno");
2350
2445
  return INT2FIX(0);
2351
2446
  #endif
2352
2447
  }
2353
-
2448
+
2354
2449
  /*
2355
2450
  * call-seq:
2356
2451
  * 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
- *
2452
+ *
2453
+ * Retrieve the number of new connections libcurl had to create to achieve
2454
+ * the previous transfer (only the successful connects are counted).
2455
+ * Combined with +redirect_count+ you are able to know how many times libcurl
2456
+ * successfully reused existing connection(s) or not.
2457
+ *
2363
2458
  * See the Connection Options of curl_easy_setopt(3) to see how libcurl tries
2364
2459
  * to make persistent connections to save time.
2365
- *
2460
+ *
2366
2461
  * (requires libcurl 7.12.3 or higher, otherwise -1 is always returned).
2367
2462
  */
2368
2463
  static VALUE ruby_curl_easy_num_connects_get(VALUE self) {
2369
2464
  #ifdef HAVE_CURLINFO_NUM_CONNECTS
2370
2465
  ruby_curl_easy *rbce;
2371
2466
  long result;
2372
-
2373
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2467
+
2468
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2374
2469
  curl_easy_getinfo(rbce->curl, CURLINFO_NUM_CONNECTS, &result);
2375
-
2376
- return LONG2NUM(result);
2470
+
2471
+ return LONG2NUM(result);
2377
2472
  #else
2378
2473
  rb_warn("Installed libcurl is too old to support num_connects");
2379
2474
  return INT2FIX(-1);
2380
2475
  #endif
2381
2476
  }
2382
-
2477
+
2383
2478
 
2384
2479
  /* TODO this needs to be implemented.
2385
2480
 
2386
- CURLINFO_COOKIELIST
2481
+ CURLINFO_COOKIELIST
2387
2482
 
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)
2483
+ 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
2484
  */
2390
2485
 
2391
2486
  /* TODO this needs to be implemented. Could probably support CONNECT_ONLY by having this
2392
2487
  * return an open Socket or something.
2393
2488
  *
2394
- CURLINFO_LASTSOCKET
2489
+ CURLINFO_LASTSOCKET
2395
2490
 
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)
2491
+ 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
2492
  */
2398
2493
 
2399
2494
  /*
2400
2495
  * call-seq:
2401
2496
  * 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
2497
+ *
2498
+ * Retrieve the path of the entry path. That is the initial path libcurl ended
2499
+ * up in when logging on to the remote FTP server. This returns +nil+ if
2405
2500
  * something is wrong.
2406
- *
2501
+ *
2407
2502
  * (requires libcurl 7.15.4 or higher, otherwise +nil+ is always returned).
2408
2503
  */
2409
2504
  static VALUE ruby_curl_easy_ftp_entry_path_get(VALUE self) {
2410
2505
  #ifdef HAVE_CURLINFO_FTP_ENTRY_PATH
2411
2506
  ruby_curl_easy *rbce;
2412
2507
  char* path = NULL;
2413
-
2414
- Data_Get_Struct(self, ruby_curl_easy, rbce);
2508
+
2509
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
2415
2510
  curl_easy_getinfo(rbce->curl, CURLINFO_FTP_ENTRY_PATH, &path);
2416
-
2511
+
2417
2512
  if (path && path[0]) { // curl returns NULL or empty string if none
2418
2513
  return rb_str_new2(path);
2419
2514
  } else {
@@ -2424,17 +2519,17 @@ static VALUE ruby_curl_easy_ftp_entry_path_get(VALUE self) {
2424
2519
  return Qnil;
2425
2520
  #endif
2426
2521
  }
2427
-
2522
+
2428
2523
 
2429
2524
  /* ================== ESCAPING FUNCS ==============*/
2430
2525
 
2431
- /*
2526
+ /*
2432
2527
  * call-seq:
2433
2528
  * easy.escape("some text") => "some%20text"
2434
- *
2529
+ *
2435
2530
  * 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
2531
+ * the result. All input characters that are not a-z, A-Z or 0-9 are
2532
+ * converted to their "URL escaped" version (%NN where NN is a
2438
2533
  * two-digit hexadecimal number).
2439
2534
  */
2440
2535
  static VALUE ruby_curl_easy_escape(VALUE self, VALUE str) {
@@ -2443,7 +2538,7 @@ static VALUE ruby_curl_easy_escape(VALUE self, VALUE str) {
2443
2538
  VALUE rresult;
2444
2539
 
2445
2540
  Data_Get_Struct(self, ruby_curl_easy, rbce);
2446
-
2541
+
2447
2542
  #if (LIBCURL_VERSION_NUM >= 0x070f04)
2448
2543
  result = (char*)curl_easy_escape(rbce->curl, StringValuePtr(str), RSTRING_LEN(str));
2449
2544
  #else
@@ -2451,17 +2546,17 @@ static VALUE ruby_curl_easy_escape(VALUE self, VALUE str) {
2451
2546
  #endif
2452
2547
 
2453
2548
  rresult = rb_str_new2(result);
2454
- curl_free(result);
2455
-
2549
+ curl_free(result);
2550
+
2456
2551
  return rresult;
2457
2552
  }
2458
2553
 
2459
2554
  /*
2460
2555
  * call-seq:
2461
2556
  * easy.unescape("some text") => "some%20text"
2462
- *
2557
+ *
2463
2558
  * 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
2559
+ * the result. All input characters that are URL encoded (%XX where XX is a
2465
2560
  * two-digit hexadecimal number) are converted to their binary versions.
2466
2561
  */
2467
2562
  static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
@@ -2469,9 +2564,9 @@ static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
2469
2564
  int rlen;
2470
2565
  char *result;
2471
2566
  VALUE rresult;
2472
-
2567
+
2473
2568
  Data_Get_Struct(self, ruby_curl_easy, rbce);
2474
-
2569
+
2475
2570
  #if (LIBCURL_VERSION_NUM >= 0x070f04)
2476
2571
  result = (char*)curl_easy_unescape(rbce->curl, StringValuePtr(str), RSTRING_LEN(str), &rlen);
2477
2572
  #else
@@ -2480,8 +2575,8 @@ static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
2480
2575
  #endif
2481
2576
 
2482
2577
  rresult = rb_str_new(result, rlen);
2483
- curl_free(result);
2484
-
2578
+ curl_free(result);
2579
+
2485
2580
  return rresult;
2486
2581
  }
2487
2582
 
@@ -2491,63 +2586,63 @@ static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
2491
2586
  /*
2492
2587
  * call-seq:
2493
2588
  * 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
2589
+ *
2590
+ * Convenience method that creates a new Curl::Easy instance with
2591
+ * the specified URL and calls the general +perform+ method, before returning
2497
2592
  * the new instance. For HTTP URLs, this is equivalent to calling +http_get+.
2498
- *
2593
+ *
2499
2594
  * If a block is supplied, the new instance will be yielded just prior to
2500
2595
  * the +http_get+ call.
2501
2596
  */
2502
2597
  static VALUE ruby_curl_easy_class_perform(int argc, VALUE *argv, VALUE klass) {
2503
- VALUE c = ruby_curl_easy_new(argc, argv, klass);
2504
-
2598
+ VALUE c = ruby_curl_easy_new(argc, argv, klass);
2599
+
2505
2600
  if (rb_block_given_p()) {
2506
2601
  rb_yield(c);
2507
2602
  }
2508
-
2603
+
2509
2604
  ruby_curl_easy_perform(c);
2510
- return c;
2605
+ return c;
2511
2606
  }
2512
2607
 
2513
2608
  /*
2514
2609
  * call-seq:
2515
2610
  * Curl::Easy.http_get(url) { |easy| ... } => #&lt;Curl::Easy...&gt;
2516
- *
2517
- * Convenience method that creates a new Curl::Easy instance with
2611
+ *
2612
+ * Convenience method that creates a new Curl::Easy instance with
2518
2613
  * the specified URL and calls +http_get+, before returning the new instance.
2519
- *
2614
+ *
2520
2615
  * If a block is supplied, the new instance will be yielded just prior to
2521
2616
  * the +http_get+ call.
2522
2617
  */
2523
2618
  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
-
2619
+ VALUE c = ruby_curl_easy_new(argc, argv, klass);
2620
+
2526
2621
  if (rb_block_given_p()) {
2527
2622
  rb_yield(c);
2528
2623
  }
2529
-
2624
+
2530
2625
  ruby_curl_easy_perform_get(c);
2531
- return c;
2626
+ return c;
2532
2627
  }
2533
2628
 
2534
2629
  /*
2535
2630
  * call-seq:
2536
2631
  * Curl::Easy.http_delete(url) { |easy| ... } => #&lt;Curl::Easy...&gt;
2537
- *
2538
- * Convenience method that creates a new Curl::Easy instance with
2632
+ *
2633
+ * Convenience method that creates a new Curl::Easy instance with
2539
2634
  * the specified URL and calls +http_delete+, before returning the new instance.
2540
- *
2635
+ *
2541
2636
  * If a block is supplied, the new instance will be yielded just prior to
2542
2637
  * the +http_delete+ call.
2543
2638
  */
2544
2639
  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
-
2640
+ VALUE c = ruby_curl_easy_new(argc, argv, klass);
2641
+
2547
2642
  if (rb_block_given_p()) {
2548
2643
  rb_yield(c);
2549
2644
  }
2550
-
2645
+
2551
2646
  ruby_curl_easy_perform_delete(c);
2552
2647
  return c;
2553
2648
  }
@@ -2581,30 +2676,30 @@ static VALUE ruby_curl_easy_class_perform_head(int argc, VALUE *argv, VALUE klas
2581
2676
  * Curl::Easy.http_post(url, "some=urlencoded%20form%20data", "and=so%20on", ...) => true
2582
2677
  * Curl::Easy.http_post(url, "some=urlencoded%20form%20data", Curl::PostField, "and=so%20on", ...) => true
2583
2678
  * 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
2679
+ *
2680
+ * POST the specified formdata to the currently configured URL using
2681
+ * the current options set for this Curl::Easy instance. This method
2682
+ * always returns true, or raises an exception (defined under
2588
2683
  * Curl::Err) on error.
2589
- *
2684
+ *
2590
2685
  * 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
2686
+ * in order to set multipart_form_post true. See #http_post for more
2592
2687
  * information.
2593
2688
  */
2594
- static VALUE ruby_curl_easy_class_perform_post(int argc, VALUE *argv, VALUE klass) {
2689
+ static VALUE ruby_curl_easy_class_perform_post(int argc, VALUE *argv, VALUE klass) {
2595
2690
  VALUE url, fields;
2596
-
2691
+
2597
2692
  rb_scan_args(argc, argv, "1*", &url, &fields);
2598
-
2599
- VALUE c = ruby_curl_easy_new(1, &url, klass);
2600
-
2693
+
2694
+ VALUE c = ruby_curl_easy_new(1, &url, klass);
2695
+
2601
2696
  if (argc > 1) {
2602
2697
  ruby_curl_easy_perform_post(argc - 1, &argv[1], c);
2603
2698
  } else {
2604
2699
  ruby_curl_easy_perform_post(0, NULL, c);
2605
- }
2606
-
2607
- return c;
2700
+ }
2701
+
2702
+ return c;
2608
2703
  }
2609
2704
 
2610
2705
 
@@ -2612,10 +2707,10 @@ static VALUE ruby_curl_easy_class_perform_post(int argc, VALUE *argv, VALUE klas
2612
2707
  void init_curb_easy() {
2613
2708
  idCall = rb_intern("call");
2614
2709
  idJoin = rb_intern("join");
2615
-
2710
+
2616
2711
  rbstrAmp = rb_str_new2("&");
2617
2712
  rb_global_variable(&rbstrAmp);
2618
-
2713
+
2619
2714
  cCurlEasy = rb_define_class_under(mCurl, "Easy", rb_cObject);
2620
2715
 
2621
2716
  /* Class methods */
@@ -2628,7 +2723,7 @@ void init_curb_easy() {
2628
2723
 
2629
2724
  /* Attributes for config next perform */
2630
2725
  rb_define_method(cCurlEasy, "url=", ruby_curl_easy_url_set, 1);
2631
- rb_define_method(cCurlEasy, "url", ruby_curl_easy_url_get, 0);
2726
+ rb_define_method(cCurlEasy, "url", ruby_curl_easy_url_get, 0);
2632
2727
  rb_define_method(cCurlEasy, "proxy_url=", ruby_curl_easy_proxy_url_set, 1);
2633
2728
  rb_define_method(cCurlEasy, "proxy_url", ruby_curl_easy_proxy_url_get, 0);
2634
2729
  rb_define_method(cCurlEasy, "headers=", ruby_curl_easy_headers_set, 1);
@@ -2672,7 +2767,7 @@ void init_curb_easy() {
2672
2767
  rb_define_method(cCurlEasy, "dns_cache_timeout", ruby_curl_easy_dns_cache_timeout_get, 0);
2673
2768
  rb_define_method(cCurlEasy, "ftp_response_timeout=", ruby_curl_easy_ftp_response_timeout_set, 1);
2674
2769
  rb_define_method(cCurlEasy, "ftp_response_timeout", ruby_curl_easy_ftp_response_timeout_get, 0);
2675
-
2770
+
2676
2771
  rb_define_method(cCurlEasy, "proxy_tunnel=", ruby_curl_easy_proxy_tunnel_set, 1);
2677
2772
  rb_define_method(cCurlEasy, "proxy_tunnel?", ruby_curl_easy_proxy_tunnel_q, 0);
2678
2773
  rb_define_method(cCurlEasy, "fetch_file_time=", ruby_curl_easy_fetch_file_time_set, 1);
@@ -2721,7 +2816,6 @@ void init_curb_easy() {
2721
2816
  rb_define_method(cCurlEasy, "http_connect_code", ruby_curl_easy_http_connect_code_get, 0);
2722
2817
  rb_define_method(cCurlEasy, "file_time", ruby_curl_easy_file_time_get, 0);
2723
2818
  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
2819
  rb_define_method(cCurlEasy, "name_lookup_time", ruby_curl_easy_name_lookup_time_get, 0);
2726
2820
  rb_define_method(cCurlEasy, "connect_time", ruby_curl_easy_connect_time_get, 0);
2727
2821
  rb_define_method(cCurlEasy, "pre_transfer_time", ruby_curl_easy_pre_transfer_time_get, 0);
@@ -2748,5 +2842,5 @@ void init_curb_easy() {
2748
2842
 
2749
2843
  /* Runtime support */
2750
2844
  rb_define_method(cCurlEasy, "clone", ruby_curl_easy_clone, 0);
2751
- rb_define_alias(cCurlEasy, "dup", "clone");
2845
+ rb_define_alias(cCurlEasy, "dup", "clone");
2752
2846
  }