curb 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/Rakefile +25 -9
- data/ext/curb.c +10 -0
- data/ext/curb.h +3 -3
- data/ext/curb_easy.c +213 -18
- data/ext/curb_easy.h +3 -0
- data/ext/curb_multi.c +126 -161
- data/ext/curb_multi.h +0 -1
- data/ext/extconf.rb +2 -0
- data/lib/curl/easy.rb +1 -1
- data/lib/curl/multi.rb +39 -1
- data/tests/helper.rb +78 -0
- data/tests/tc_curl_easy.rb +50 -16
- data/tests/tc_curl_multi.rb +67 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64402c665924d5c24d6fa01dff9dd9f41d522ef1ca6e663d2038a204bd0290b4
|
4
|
+
data.tar.gz: 645f0b0f29804b105b9a4caaa1b2132d9d18b5dd4d678072e7e41a1d8d73771a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f86cb2a29633a86820862e35a5a1113c859e55636a50e779ab4235ccc54fb3b38a894edb8fcc090522ceb509ac0c2da329f708a9c109a2f871ce9c718984729c
|
7
|
+
data.tar.gz: a2d20ac0b5aee80de2aa37f4c49b923c5e6b19c2b0dd82d4466d14b21f0988644baa893bd23950380efec0ab028c9f1fd9c1dfc6d2ab7c97246c86bb2aad5cf2
|
data/Rakefile
CHANGED
@@ -2,11 +2,6 @@
|
|
2
2
|
#
|
3
3
|
require 'rake/clean'
|
4
4
|
require 'rake/testtask'
|
5
|
-
begin
|
6
|
-
require 'rdoc/task'
|
7
|
-
rescue LoadError => e
|
8
|
-
require 'rake/rdoctask'
|
9
|
-
end
|
10
5
|
|
11
6
|
CLEAN.include '**/*.o'
|
12
7
|
CLEAN.include "**/*.#{(defined?(RbConfig) ? RbConfig : Config)::MAKEFILE_CONFIG['DLEXT']}"
|
@@ -15,6 +10,22 @@ CLOBBER.include '**/*.log'
|
|
15
10
|
CLOBBER.include '**/Makefile'
|
16
11
|
CLOBBER.include '**/extconf.h'
|
17
12
|
|
13
|
+
# Not available for really old rubies, but that's ok.
|
14
|
+
begin
|
15
|
+
require 'pry'
|
16
|
+
rescue LoadError
|
17
|
+
puts "Failed to load pry."
|
18
|
+
end
|
19
|
+
|
20
|
+
# Load support ruby and rake files (in this order)
|
21
|
+
Dir.glob('tasks/*.rb').each { |r| load r}
|
22
|
+
Dir.glob('tasks/*.rake').each { |r| load r}
|
23
|
+
|
24
|
+
desc 'Print Ruby major version (ie "2_5")'
|
25
|
+
task :ruby_version do
|
26
|
+
print current_ruby_major
|
27
|
+
end
|
28
|
+
|
18
29
|
def announce(msg='')
|
19
30
|
$stderr.puts msg
|
20
31
|
end
|
@@ -43,12 +54,11 @@ end
|
|
43
54
|
make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
|
44
55
|
MAKECMD = ENV['MAKE_CMD'] || make_program
|
45
56
|
MAKEOPTS = ENV['MAKE_OPTS'] || ''
|
46
|
-
|
47
57
|
CURB_SO = "ext/curb_core.#{(defined?(RbConfig) ? RbConfig : Config)::MAKEFILE_CONFIG['DLEXT']}"
|
48
58
|
|
49
59
|
file 'ext/Makefile' => 'ext/extconf.rb' do
|
50
60
|
Dir.chdir('ext') do
|
51
|
-
ruby
|
61
|
+
shell('ruby', 'extconf.rb', ENV['EXTCONF_OPTS'].to_s, live_stdout: STDOUT)
|
52
62
|
end
|
53
63
|
end
|
54
64
|
|
@@ -89,12 +99,12 @@ if ENV['RELTEST']
|
|
89
99
|
else
|
90
100
|
task :alltests => [:unittests, :bugtests]
|
91
101
|
end
|
92
|
-
|
102
|
+
|
93
103
|
Rake::TestTask.new(:unittests) do |t|
|
94
104
|
t.test_files = FileList['tests/tc_*.rb']
|
95
105
|
t.verbose = false
|
96
106
|
end
|
97
|
-
|
107
|
+
|
98
108
|
Rake::TestTask.new(:bugtests) do |t|
|
99
109
|
t.test_files = FileList['tests/bug_*.rb']
|
100
110
|
t.verbose = false
|
@@ -136,6 +146,12 @@ end
|
|
136
146
|
|
137
147
|
desc "Publish the RDoc documentation to project web site"
|
138
148
|
task :doc_upload => [ :doc ] do
|
149
|
+
begin
|
150
|
+
require 'rdoc/task'
|
151
|
+
rescue LoadError => e
|
152
|
+
require 'rake/rdoctask'
|
153
|
+
end
|
154
|
+
|
139
155
|
if ENV['RELTEST']
|
140
156
|
announce "Release Task Testing, skipping doc upload"
|
141
157
|
else
|
data/ext/curb.c
CHANGED
@@ -352,6 +352,13 @@ void Init_curb_core() {
|
|
352
352
|
rb_define_const(mCurl, "CURLPROXY_SOCKS5", LONG2NUM(-2));
|
353
353
|
#endif
|
354
354
|
|
355
|
+
/* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS5 proxy (and that the proxy should resolve the hostname). (libcurl >= 7.17.2) */
|
356
|
+
#ifdef HAVE_CURLPROXY_SOCKS5_HOSTNAME
|
357
|
+
rb_define_const(mCurl, "CURLPROXY_SOCKS5_HOSTNAME", LONG2NUM(CURLPROXY_SOCKS5_HOSTNAME));
|
358
|
+
#else
|
359
|
+
rb_define_const(mCurl, "CURLPROXY_SOCKS5_HOSTNAME", LONG2NUM(-2));
|
360
|
+
#endif
|
361
|
+
|
355
362
|
/* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use Basic authentication. */
|
356
363
|
#ifdef HAVE_CURLAUTH_BASIC
|
357
364
|
rb_define_const(mCurl, "CURLAUTH_BASIC", LONG2NUM(CURLAUTH_BASIC));
|
@@ -585,6 +592,9 @@ void Init_curb_core() {
|
|
585
592
|
CURB_DEFINE(CURLOPT_REFERER);
|
586
593
|
CURB_DEFINE(CURLOPT_USERAGENT);
|
587
594
|
CURB_DEFINE(CURLOPT_HTTPHEADER);
|
595
|
+
#if HAVE_CURLOPT_PROXYHEADER
|
596
|
+
CURB_DEFINE(CURLOPT_PROXYHEADER);
|
597
|
+
#endif
|
588
598
|
#if HAVE_CURLOPT_HTTP200ALIASES
|
589
599
|
CURB_DEFINE(CURLOPT_HTTP200ALIASES);
|
590
600
|
#endif
|
data/ext/curb.h
CHANGED
@@ -20,11 +20,11 @@
|
|
20
20
|
#include "curb_macros.h"
|
21
21
|
|
22
22
|
// These should be managed from the Rake 'release' task.
|
23
|
-
#define CURB_VERSION "0.9.
|
24
|
-
#define CURB_VER_NUM
|
23
|
+
#define CURB_VERSION "0.9.8"
|
24
|
+
#define CURB_VER_NUM 908
|
25
25
|
#define CURB_VER_MAJ 0
|
26
26
|
#define CURB_VER_MIN 9
|
27
|
-
#define CURB_VER_MIC
|
27
|
+
#define CURB_VER_MIC 8
|
28
28
|
#define CURB_VER_PATCH 0
|
29
29
|
|
30
30
|
|
data/ext/curb_easy.c
CHANGED
@@ -223,6 +223,10 @@ static void ruby_curl_easy_free(ruby_curl_easy *rbce) {
|
|
223
223
|
curl_slist_free_all(rbce->curl_headers);
|
224
224
|
}
|
225
225
|
|
226
|
+
if (rbce->curl_proxy_headers) {
|
227
|
+
curl_slist_free_all(rbce->curl_proxy_headers);
|
228
|
+
}
|
229
|
+
|
226
230
|
if (rbce->curl_ftp_commands) {
|
227
231
|
curl_slist_free_all(rbce->curl_ftp_commands);
|
228
232
|
}
|
@@ -258,6 +262,7 @@ static void ruby_curl_easy_zero(ruby_curl_easy *rbce) {
|
|
258
262
|
rbce->opts = rb_hash_new();
|
259
263
|
|
260
264
|
rbce->curl_headers = NULL;
|
265
|
+
rbce->curl_proxy_headers = NULL;
|
261
266
|
rbce->curl_ftp_commands = NULL;
|
262
267
|
rbce->curl_resolve = NULL;
|
263
268
|
|
@@ -277,6 +282,8 @@ static void ruby_curl_easy_zero(ruby_curl_easy *rbce) {
|
|
277
282
|
rbce->ftp_response_timeout = 0;
|
278
283
|
rbce->low_speed_limit = 0;
|
279
284
|
rbce->low_speed_time = 0;
|
285
|
+
rbce->max_send_speed_large = 0;
|
286
|
+
rbce->max_recv_speed_large = 0;
|
280
287
|
rbce->ssl_version = -1;
|
281
288
|
rbce->use_ssl = -1;
|
282
289
|
rbce->ftp_filemethod = -1;
|
@@ -343,7 +350,8 @@ static VALUE ruby_curl_easy_initialize(int argc, VALUE *argv, VALUE self) {
|
|
343
350
|
|
344
351
|
rb_easy_set("url", url);
|
345
352
|
|
346
|
-
|
353
|
+
|
354
|
+
/* set the pointer to the curl handle */
|
347
355
|
ecode = curl_easy_setopt(rbce->curl, CURLOPT_PRIVATE, (void*)self);
|
348
356
|
if (ecode != CURLE_OK) {
|
349
357
|
raise_curl_easy_error_exception(ecode);
|
@@ -373,6 +381,7 @@ static VALUE ruby_curl_easy_clone(VALUE self) {
|
|
373
381
|
memcpy(newrbce, rbce, sizeof(ruby_curl_easy));
|
374
382
|
newrbce->curl = curl_easy_duphandle(rbce->curl);
|
375
383
|
newrbce->curl_headers = NULL;
|
384
|
+
newrbce->curl_proxy_headers = NULL;
|
376
385
|
newrbce->curl_ftp_commands = NULL;
|
377
386
|
newrbce->curl_resolve = NULL;
|
378
387
|
|
@@ -457,6 +466,12 @@ static VALUE ruby_curl_easy_reset(VALUE self) {
|
|
457
466
|
rbce->curl_headers = NULL;
|
458
467
|
}
|
459
468
|
|
469
|
+
/* Free everything up */
|
470
|
+
if (rbce->curl_proxy_headers) {
|
471
|
+
curl_slist_free_all(rbce->curl_proxy_headers);
|
472
|
+
rbce->curl_proxy_headers = NULL;
|
473
|
+
}
|
474
|
+
|
460
475
|
return opts_dup;
|
461
476
|
}
|
462
477
|
|
@@ -509,6 +524,10 @@ static VALUE ruby_curl_easy_headers_set(VALUE self, VALUE headers) {
|
|
509
524
|
CURB_OBJECT_HSETTER(ruby_curl_easy, headers);
|
510
525
|
}
|
511
526
|
|
527
|
+
static VALUE ruby_curl_easy_proxy_headers_set(VALUE self, VALUE proxy_headers) {
|
528
|
+
CURB_OBJECT_HSETTER(ruby_curl_easy, proxy_headers);
|
529
|
+
}
|
530
|
+
|
512
531
|
/*
|
513
532
|
* call-seq:
|
514
533
|
* easy.headers => Hash, Array or Str
|
@@ -524,6 +543,41 @@ static VALUE ruby_curl_easy_headers_get(VALUE self) {
|
|
524
543
|
return headers;
|
525
544
|
}
|
526
545
|
|
546
|
+
/*
|
547
|
+
* call-seq:
|
548
|
+
* easy.proxy_headers = "Header: val" => "Header: val"
|
549
|
+
* easy.proxy_headers = {"Header" => "val" ..., "Header" => "val"} => {"Header: val", ...}
|
550
|
+
* easy.proxy_headers = ["Header: val" ..., "Header: val"] => ["Header: val", ...]
|
551
|
+
*
|
552
|
+
*
|
553
|
+
* For example to set a standard or custom header:
|
554
|
+
*
|
555
|
+
* easy.proxy_headers["MyHeader"] = "myval"
|
556
|
+
*
|
557
|
+
* To remove a standard header (this is useful when removing libcurls default
|
558
|
+
* 'Expect: 100-Continue' header when using HTTP form posts):
|
559
|
+
*
|
560
|
+
* easy.proxy_headers["Expect"] = ''
|
561
|
+
*
|
562
|
+
* Anything passed to libcurl as a header will be converted to a string during
|
563
|
+
* the perform step.
|
564
|
+
*/
|
565
|
+
|
566
|
+
/*
|
567
|
+
* call-seq:
|
568
|
+
* easy.proxy_headers => Hash, Array or Str
|
569
|
+
*
|
570
|
+
* Obtain the custom HTTP proxy_headers for following requests.
|
571
|
+
*/
|
572
|
+
static VALUE ruby_curl_easy_proxy_headers_get(VALUE self) {
|
573
|
+
ruby_curl_easy *rbce;
|
574
|
+
VALUE proxy_headers;
|
575
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
576
|
+
proxy_headers = rb_easy_get("proxy_headers");//rb_hash_aref(rbce->opts, rb_intern("proxy_headers"));
|
577
|
+
if (proxy_headers == Qnil) { proxy_headers = rb_easy_set("proxy_headers", rb_hash_new()); }
|
578
|
+
return proxy_headers;
|
579
|
+
}
|
580
|
+
|
527
581
|
/*
|
528
582
|
* call-seq:
|
529
583
|
* easy.interface => string
|
@@ -1139,7 +1193,7 @@ static VALUE ruby_curl_easy_max_redirects_get(VALUE self) {
|
|
1139
1193
|
|
1140
1194
|
/*
|
1141
1195
|
* call-seq:
|
1142
|
-
* easy.timeout = fixnum or nil
|
1196
|
+
* easy.timeout = float, fixnum or nil => numeric
|
1143
1197
|
*
|
1144
1198
|
* Set the maximum time in seconds that you allow the libcurl transfer
|
1145
1199
|
* operation to take. Normally, name lookups can take a considerable time
|
@@ -1148,20 +1202,39 @@ static VALUE ruby_curl_easy_max_redirects_get(VALUE self) {
|
|
1148
1202
|
*
|
1149
1203
|
* Set to nil (or zero) to disable timeout (it will then only timeout
|
1150
1204
|
* on the system's internal timeouts).
|
1205
|
+
*
|
1206
|
+
* Uses timeout_ms internally instead of timeout because it allows for
|
1207
|
+
* better precision and libcurl will use the last set value when both
|
1208
|
+
* timeout and timeout_ms are set.
|
1209
|
+
*
|
1151
1210
|
*/
|
1152
|
-
static VALUE ruby_curl_easy_timeout_set(VALUE self, VALUE
|
1153
|
-
|
1211
|
+
static VALUE ruby_curl_easy_timeout_set(VALUE self, VALUE timeout_s) {
|
1212
|
+
ruby_curl_easy *rbce;
|
1213
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
1214
|
+
|
1215
|
+
if (Qnil == timeout_s || NUM2DBL(timeout_s) <= 0.0) {
|
1216
|
+
rbce->timeout_ms = 0;
|
1217
|
+
} else {
|
1218
|
+
rbce->timeout_ms = (unsigned long)(NUM2DBL(timeout_s) * 1000);
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
return DBL2NUM(rbce->timeout_ms / 1000.0);
|
1154
1222
|
}
|
1155
1223
|
|
1156
1224
|
/*
|
1157
1225
|
* call-seq:
|
1158
|
-
* easy.timeout =>
|
1226
|
+
* easy.timeout => numeric
|
1159
1227
|
*
|
1160
1228
|
* Obtain the maximum time in seconds that you allow the libcurl transfer
|
1161
1229
|
* operation to take.
|
1230
|
+
*
|
1231
|
+
* Uses timeout_ms internally instead of timeout.
|
1232
|
+
*
|
1162
1233
|
*/
|
1163
|
-
static VALUE ruby_curl_easy_timeout_get(VALUE self
|
1164
|
-
|
1234
|
+
static VALUE ruby_curl_easy_timeout_get(VALUE self) {
|
1235
|
+
ruby_curl_easy *rbce;
|
1236
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
1237
|
+
return DBL2NUM(rbce->timeout_ms / 1000.0);
|
1165
1238
|
}
|
1166
1239
|
|
1167
1240
|
/*
|
@@ -1177,7 +1250,16 @@ static VALUE ruby_curl_easy_timeout_get(VALUE self, VALUE timeout) {
|
|
1177
1250
|
* on the system's internal timeouts).
|
1178
1251
|
*/
|
1179
1252
|
static VALUE ruby_curl_easy_timeout_ms_set(VALUE self, VALUE timeout_ms) {
|
1180
|
-
|
1253
|
+
ruby_curl_easy *rbce;
|
1254
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
1255
|
+
|
1256
|
+
if (Qnil == timeout_ms || NUM2DBL(timeout_ms) <= 0.0) {
|
1257
|
+
rbce->timeout_ms = 0;
|
1258
|
+
} else {
|
1259
|
+
rbce->timeout_ms = NUM2ULONG(timeout_ms);
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
return ULONG2NUM(rbce->timeout_ms);
|
1181
1263
|
}
|
1182
1264
|
|
1183
1265
|
/*
|
@@ -1187,8 +1269,10 @@ static VALUE ruby_curl_easy_timeout_ms_set(VALUE self, VALUE timeout_ms) {
|
|
1187
1269
|
* Obtain the maximum time in milliseconds that you allow the libcurl transfer
|
1188
1270
|
* operation to take.
|
1189
1271
|
*/
|
1190
|
-
static VALUE ruby_curl_easy_timeout_ms_get(VALUE self
|
1191
|
-
|
1272
|
+
static VALUE ruby_curl_easy_timeout_ms_get(VALUE self) {
|
1273
|
+
ruby_curl_easy *rbce;
|
1274
|
+
Data_Get_Struct(self, ruby_curl_easy, rbce);
|
1275
|
+
return LONG2NUM(rbce->timeout_ms);
|
1192
1276
|
}
|
1193
1277
|
|
1194
1278
|
/*
|
@@ -1338,6 +1422,46 @@ static VALUE ruby_curl_easy_low_speed_time_get(VALUE self, VALUE low_speed_time)
|
|
1338
1422
|
CURB_IMMED_GETTER(ruby_curl_easy, low_speed_time, 0);
|
1339
1423
|
}
|
1340
1424
|
|
1425
|
+
/*
|
1426
|
+
* call-seq:
|
1427
|
+
* easy.max_send_speed_large = fixnum or nil => fixnum or nil
|
1428
|
+
*
|
1429
|
+
* Set the maximal sending transfer speed (in bytes per second)
|
1430
|
+
*/
|
1431
|
+
static VALUE ruby_curl_easy_max_send_speed_large_set(VALUE self, VALUE max_send_speed_large) {
|
1432
|
+
CURB_IMMED_SETTER(ruby_curl_easy, max_send_speed_large, 0);
|
1433
|
+
}
|
1434
|
+
|
1435
|
+
/*
|
1436
|
+
* call-seq:
|
1437
|
+
* easy.max_send_speed_large = fixnum or nil => fixnum or nil
|
1438
|
+
*
|
1439
|
+
* Get the maximal sending transfer speed (in bytes per second)
|
1440
|
+
*/
|
1441
|
+
static VALUE ruby_curl_easy_max_send_speed_large_get(VALUE self, VALUE max_send_speed_large) {
|
1442
|
+
CURB_IMMED_GETTER(ruby_curl_easy, max_send_speed_large, 0);
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
/*
|
1446
|
+
* call-seq:
|
1447
|
+
* easy.max_recv_speed_large = fixnum or nil => fixnum or nil
|
1448
|
+
*
|
1449
|
+
* Set the maximal receiving transfer speed (in bytes per second)
|
1450
|
+
*/
|
1451
|
+
static VALUE ruby_curl_easy_max_recv_speed_large_set(VALUE self, VALUE max_recv_speed_large) {
|
1452
|
+
CURB_IMMED_SETTER(ruby_curl_easy, max_recv_speed_large, 0);
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
/*
|
1456
|
+
* call-seq:
|
1457
|
+
* easy.max_recv_speed_large = fixnum or nil => fixnum or nil
|
1458
|
+
*
|
1459
|
+
* Get the maximal receiving transfer speed (in bytes per second)
|
1460
|
+
*/
|
1461
|
+
static VALUE ruby_curl_easy_max_recv_speed_large_get(VALUE self, VALUE max_recv_speed_large) {
|
1462
|
+
CURB_IMMED_GETTER(ruby_curl_easy, max_recv_speed_large, 0);
|
1463
|
+
}
|
1464
|
+
|
1341
1465
|
/*
|
1342
1466
|
* call-seq:
|
1343
1467
|
* easy.username = string => string
|
@@ -2012,6 +2136,38 @@ static VALUE cb_each_http_header(VALUE header, VALUE wrap) {
|
|
2012
2136
|
return header_str;
|
2013
2137
|
}
|
2014
2138
|
|
2139
|
+
/***********************************************
|
2140
|
+
* This is an rb_iterate callback used to set up http proxy headers.
|
2141
|
+
*/
|
2142
|
+
static VALUE cb_each_http_proxy_header(VALUE proxy_header, VALUE wrap) {
|
2143
|
+
struct curl_slist **list;
|
2144
|
+
VALUE proxy_header_str = Qnil;
|
2145
|
+
|
2146
|
+
Data_Get_Struct(wrap, struct curl_slist *, list);
|
2147
|
+
|
2148
|
+
//rb_p(proxy_header);
|
2149
|
+
|
2150
|
+
if (rb_type(proxy_header) == T_ARRAY) {
|
2151
|
+
// we're processing a hash, proxy header is [name, val]
|
2152
|
+
VALUE name, value;
|
2153
|
+
|
2154
|
+
name = rb_obj_as_string(rb_ary_entry(proxy_header, 0));
|
2155
|
+
value = rb_obj_as_string(rb_ary_entry(proxy_header, 1));
|
2156
|
+
|
2157
|
+
// This is a bit inefficient, but we don't want to be modifying
|
2158
|
+
// the actual values in the original hash.
|
2159
|
+
proxy_header_str = rb_str_plus(name, rb_str_new2(": "));
|
2160
|
+
proxy_header_str = rb_str_plus(proxy_header_str, value);
|
2161
|
+
} else {
|
2162
|
+
proxy_header_str = rb_obj_as_string(proxy_header);
|
2163
|
+
}
|
2164
|
+
|
2165
|
+
//rb_p(header_str);
|
2166
|
+
|
2167
|
+
*list = curl_slist_append(*list, StringValuePtr(proxy_header_str));
|
2168
|
+
return proxy_header_str;
|
2169
|
+
}
|
2170
|
+
|
2015
2171
|
/***********************************************
|
2016
2172
|
* This is an rb_iterate callback used to set up ftp commands.
|
2017
2173
|
*/
|
@@ -2051,6 +2207,7 @@ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce) {
|
|
2051
2207
|
CURL *curl;
|
2052
2208
|
VALUE url, _url = rb_easy_get("url");
|
2053
2209
|
struct curl_slist **hdrs = &(rbce->curl_headers);
|
2210
|
+
struct curl_slist **phdrs = &(rbce->curl_proxy_headers);
|
2054
2211
|
struct curl_slist **cmds = &(rbce->curl_ftp_commands);
|
2055
2212
|
struct curl_slist **rslv = &(rbce->curl_resolve);
|
2056
2213
|
|
@@ -2061,7 +2218,6 @@ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce) {
|
|
2061
2218
|
}
|
2062
2219
|
|
2063
2220
|
url = rb_check_string_type(_url);
|
2064
|
-
|
2065
2221
|
curl_easy_setopt(curl, CURLOPT_URL, StringValuePtr(url));
|
2066
2222
|
|
2067
2223
|
// network stuff and auth
|
@@ -2174,15 +2330,14 @@ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce) {
|
|
2174
2330
|
|
2175
2331
|
curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, rbce->unrestricted_auth);
|
2176
2332
|
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
if (rbce->timeout_ms && rbce->timeout_ms > 0) {
|
2182
|
-
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, rbce->timeout_ms);
|
2183
|
-
}
|
2333
|
+
#if HAVE_CURLOPT_TIMEOUT_MS
|
2334
|
+
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, rbce->timeout_ms);
|
2335
|
+
#endif
|
2336
|
+
|
2184
2337
|
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, rbce->connect_timeout);
|
2338
|
+
#if HAVE_CURLOPT_CONNECTTIMEOUT_MS
|
2185
2339
|
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, rbce->connect_timeout_ms);
|
2340
|
+
#endif
|
2186
2341
|
curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, rbce->dns_cache_timeout);
|
2187
2342
|
|
2188
2343
|
curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, rbce->ignore_content_length);
|
@@ -2201,6 +2356,9 @@ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce) {
|
|
2201
2356
|
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, rbce->low_speed_limit);
|
2202
2357
|
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, rbce->low_speed_time);
|
2203
2358
|
|
2359
|
+
curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, rbce->max_recv_speed_large);
|
2360
|
+
curl_easy_setopt(curl, CURLOPT_MAX_SEND_SPEED_LARGE, rbce->max_send_speed_large);
|
2361
|
+
|
2204
2362
|
// Set up localport / proxy port
|
2205
2363
|
// FIXME these won't get returned to default if they're unset Ruby
|
2206
2364
|
if (rbce->proxy_port > 0) {
|
@@ -2334,6 +2492,25 @@ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce) {
|
|
2334
2492
|
}
|
2335
2493
|
}
|
2336
2494
|
|
2495
|
+
#if HAVE_CURLOPT_PROXYHEADER
|
2496
|
+
/* Setup HTTP proxy headers if necessary */
|
2497
|
+
curl_easy_setopt(curl, CURLOPT_PROXYHEADER, NULL); // XXX: maybe we shouldn't be clearing this?
|
2498
|
+
|
2499
|
+
if (!rb_easy_nil("proxy_headers")) {
|
2500
|
+
if (rb_easy_type_check("proxy_headers", T_ARRAY) || rb_easy_type_check("proxy_headers", T_HASH)) {
|
2501
|
+
VALUE wrap = Data_Wrap_Struct(rb_cObject, 0, 0, phdrs);
|
2502
|
+
rb_iterate(rb_each, rb_easy_get("proxy_headers"), cb_each_http_proxy_header, wrap);
|
2503
|
+
} else {
|
2504
|
+
VALUE proxy_headers_str = rb_obj_as_string(rb_easy_get("proxy_headers"));
|
2505
|
+
*phdrs = curl_slist_append(*hdrs, StringValuePtr(proxy_headers_str));
|
2506
|
+
}
|
2507
|
+
|
2508
|
+
if (*phdrs) {
|
2509
|
+
curl_easy_setopt(curl, CURLOPT_PROXYHEADER, *phdrs);
|
2510
|
+
}
|
2511
|
+
}
|
2512
|
+
#endif
|
2513
|
+
|
2337
2514
|
/* Setup FTP commands if necessary */
|
2338
2515
|
if (!rb_easy_nil("ftp_commands")) {
|
2339
2516
|
if (rb_easy_type_check("ftp_commands", T_ARRAY)) {
|
@@ -2380,6 +2557,11 @@ VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce ) {
|
|
2380
2557
|
rbce->curl_headers = NULL;
|
2381
2558
|
}
|
2382
2559
|
|
2560
|
+
if (rbce->curl_proxy_headers) {
|
2561
|
+
curl_slist_free_all(rbce->curl_proxy_headers);
|
2562
|
+
rbce->curl_proxy_headers = NULL;
|
2563
|
+
}
|
2564
|
+
|
2383
2565
|
ftp_commands = rbce->curl_ftp_commands;
|
2384
2566
|
if (ftp_commands) {
|
2385
2567
|
curl_slist_free_all(ftp_commands);
|
@@ -3384,6 +3566,11 @@ static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
|
|
3384
3566
|
case CURLOPT_MAX_RECV_SPEED_LARGE: {
|
3385
3567
|
curl_easy_setopt(rbce->curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t) NUM2LL(val));
|
3386
3568
|
} break;
|
3569
|
+
#endif
|
3570
|
+
#if HAVE_CURLOPT_MAXFILESIZE
|
3571
|
+
case CURLOPT_MAXFILESIZE:
|
3572
|
+
curl_easy_setopt(rbce->curl, CURLOPT_MAXFILESIZE, NUM2LONG(val));
|
3573
|
+
break;
|
3387
3574
|
#endif
|
3388
3575
|
default:
|
3389
3576
|
rb_raise(rb_eTypeError, "Curb unsupported option");
|
@@ -3520,6 +3707,10 @@ void init_curb_easy() {
|
|
3520
3707
|
/* Attributes for config next perform */
|
3521
3708
|
rb_define_method(cCurlEasy, "url", ruby_curl_easy_url_get, 0);
|
3522
3709
|
rb_define_method(cCurlEasy, "proxy_url", ruby_curl_easy_proxy_url_get, 0);
|
3710
|
+
|
3711
|
+
rb_define_method(cCurlEasy, "proxy_headers=", ruby_curl_easy_proxy_headers_set, 1);
|
3712
|
+
rb_define_method(cCurlEasy, "proxy_headers", ruby_curl_easy_proxy_headers_get, 0);
|
3713
|
+
|
3523
3714
|
rb_define_method(cCurlEasy, "headers=", ruby_curl_easy_headers_set, 1);
|
3524
3715
|
rb_define_method(cCurlEasy, "headers", ruby_curl_easy_headers_get, 0);
|
3525
3716
|
rb_define_method(cCurlEasy, "interface", ruby_curl_easy_interface_get, 0);
|
@@ -3579,6 +3770,10 @@ void init_curb_easy() {
|
|
3579
3770
|
rb_define_method(cCurlEasy, "low_speed_limit", ruby_curl_easy_low_speed_limit_get, 0);
|
3580
3771
|
rb_define_method(cCurlEasy, "low_speed_time=", ruby_curl_easy_low_speed_time_set, 1);
|
3581
3772
|
rb_define_method(cCurlEasy, "low_speed_time", ruby_curl_easy_low_speed_time_get, 0);
|
3773
|
+
rb_define_method(cCurlEasy, "max_send_speed_large=", ruby_curl_easy_max_send_speed_large_set, 1);
|
3774
|
+
rb_define_method(cCurlEasy, "max_send_speed_large", ruby_curl_easy_max_send_speed_large_get, 0);
|
3775
|
+
rb_define_method(cCurlEasy, "max_recv_speed_large=", ruby_curl_easy_max_recv_speed_large_set, 1);
|
3776
|
+
rb_define_method(cCurlEasy, "max_recv_speed_large", ruby_curl_easy_max_recv_speed_large_get, 0);
|
3582
3777
|
rb_define_method(cCurlEasy, "ssl_version=", ruby_curl_easy_ssl_version_set, 1);
|
3583
3778
|
rb_define_method(cCurlEasy, "ssl_version", ruby_curl_easy_ssl_version_get, 0);
|
3584
3779
|
rb_define_method(cCurlEasy, "use_ssl=", ruby_curl_easy_use_ssl_set, 1);
|