curb 0.8.8 → 0.9.0
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 +4 -4
- data/README.markdown +1 -2
- data/ext/curb.c +23 -0
- data/ext/curb.h +4 -4
- data/ext/curb_easy.c +76 -12
- data/ext/curb_easy.h +2 -0
- data/ext/curb_multi.c +20 -7
- data/ext/extconf.rb +4 -0
- data/lib/curl.rb +1 -1
- data/lib/curl/easy.rb +2 -0
- data/lib/curl/multi.rb +4 -4
- data/tests/tc_curl_easy.rb +26 -2
- data/tests/timeout.rb +10 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05b2aed0c904477e11533547620bc7e29a83d4fa
|
4
|
+
data.tar.gz: f4dd037db2c1018f2fe5c5a281e49df1179c129b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a604239fe8d5808d8ab3da005e1124a4bf1350038a50147e7dc27fcb4021cdfd14ed0d99a3a962c99f27f96ee81915dd520bccdcf69ac022cdafe56e1106460
|
7
|
+
data.tar.gz: 3f40806f07ea74cbafa75b3b346bb37cc03a6960064950c8e95bbf39b2c71283d09091acb27036fe057718387275700e5f0bdbc13c43ccfdd68c81729353ead3
|
data/README.markdown
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Curb - Libcurl bindings for Ruby
|
2
2
|
|
3
|
-
* [
|
4
|
-
* [rubyforge project](http://rubyforge.org/projects/curb)
|
3
|
+
* [rubydoc rdoc](http://www.rubydoc.info/github/taf2/curb/)
|
5
4
|
* [github project](http://github.com/taf2/curb/tree/master)
|
6
5
|
|
7
6
|
Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the
|
data/ext/curb.c
CHANGED
@@ -219,6 +219,22 @@ static VALUE ruby_curl_conv_q(VALUE mod) {
|
|
219
219
|
#endif
|
220
220
|
}
|
221
221
|
|
222
|
+
/*
|
223
|
+
* call-seq:
|
224
|
+
* Curl.http2? => true or false
|
225
|
+
*
|
226
|
+
* Returns true if the installed libcurl was built with support for HTTP2.
|
227
|
+
* For libcurl versions < 7.33.0, always returns false.
|
228
|
+
*/
|
229
|
+
static VALUE ruby_curl_http2_q(VALUE mod) {
|
230
|
+
#ifdef HAVE_CURL_VERSION_HTTP2
|
231
|
+
curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
|
232
|
+
return((ver->features & CURL_VERSION_HTTP2) ? Qtrue : Qfalse);
|
233
|
+
#else
|
234
|
+
return Qfalse;
|
235
|
+
#endif
|
236
|
+
}
|
237
|
+
|
222
238
|
void Init_curb_core() {
|
223
239
|
// TODO we need to call curl_global_cleanup at exit!
|
224
240
|
curl_version_info_data *ver;
|
@@ -970,7 +986,13 @@ void Init_curb_core() {
|
|
970
986
|
CURB_DEFINE(CURLGSSAPI_DELEGATION_POLICY_FLAG);
|
971
987
|
#endif
|
972
988
|
|
989
|
+
#if HAVE_CURLOPT_UNIX_SOCKET_PATH
|
990
|
+
CURB_DEFINE(CURLOPT_UNIX_SOCKET_PATH);
|
991
|
+
#endif
|
973
992
|
|
993
|
+
#if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
|
994
|
+
rb_define_const(mCurl, "HTTP_2_0", LONG2NUM(CURL_HTTP_VERSION_2_0));
|
995
|
+
#endif
|
974
996
|
rb_define_const(mCurl, "HTTP_1_1", LONG2NUM(CURL_HTTP_VERSION_1_1));
|
975
997
|
rb_define_const(mCurl, "HTTP_1_0", LONG2NUM(CURL_HTTP_VERSION_1_0));
|
976
998
|
rb_define_const(mCurl, "HTTP_NONE", LONG2NUM(CURL_HTTP_VERSION_NONE));
|
@@ -988,6 +1010,7 @@ void Init_curb_core() {
|
|
988
1010
|
rb_define_singleton_method(mCurl, "idn?", ruby_curl_idn_q, 0);
|
989
1011
|
rb_define_singleton_method(mCurl, "sspi?", ruby_curl_sspi_q, 0);
|
990
1012
|
rb_define_singleton_method(mCurl, "conv?", ruby_curl_conv_q, 0);
|
1013
|
+
rb_define_singleton_method(mCurl, "http2?", ruby_curl_http2_q, 0);
|
991
1014
|
|
992
1015
|
init_curb_errors();
|
993
1016
|
init_curb_easy();
|
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.
|
24
|
-
#define CURB_VER_NUM
|
23
|
+
#define CURB_VERSION "0.9.0"
|
24
|
+
#define CURB_VER_NUM 900
|
25
25
|
#define CURB_VER_MAJ 0
|
26
|
-
#define CURB_VER_MIN
|
27
|
-
#define CURB_VER_MIC
|
26
|
+
#define CURB_VER_MIN 0
|
27
|
+
#define CURB_VER_MIC 0
|
28
28
|
#define CURB_VER_PATCH 0
|
29
29
|
|
30
30
|
|
data/ext/curb_easy.c
CHANGED
@@ -255,7 +255,9 @@ static void ruby_curl_easy_zero(ruby_curl_easy *rbce) {
|
|
255
255
|
rbce->proxy_auth_types = 0;
|
256
256
|
rbce->max_redirs = -1;
|
257
257
|
rbce->timeout = 0;
|
258
|
+
rbce->timeout_ms = 0;
|
258
259
|
rbce->connect_timeout = 0;
|
260
|
+
rbce->connect_timeout_ms = 0;
|
259
261
|
rbce->dns_cache_timeout = 60;
|
260
262
|
rbce->ftp_response_timeout = 0;
|
261
263
|
rbce->low_speed_limit = 0;
|
@@ -1116,6 +1118,33 @@ static VALUE ruby_curl_easy_timeout_get(VALUE self, VALUE timeout) {
|
|
1116
1118
|
CURB_IMMED_GETTER(ruby_curl_easy, timeout, 0);
|
1117
1119
|
}
|
1118
1120
|
|
1121
|
+
/*
|
1122
|
+
* call-seq:
|
1123
|
+
* easy.timeout_ms = fixnum or nil => fixnum or nil
|
1124
|
+
*
|
1125
|
+
* Set the maximum time in milliseconds that you allow the libcurl transfer
|
1126
|
+
* operation to take. Normally, name lookups can take a considerable time
|
1127
|
+
* and limiting operations to less than a few minutes risk aborting
|
1128
|
+
* perfectly normal operations.
|
1129
|
+
*
|
1130
|
+
* Set to nil (or zero) to disable timeout (it will then only timeout
|
1131
|
+
* on the system's internal timeouts).
|
1132
|
+
*/
|
1133
|
+
static VALUE ruby_curl_easy_timeout_ms_set(VALUE self, VALUE timeout_ms) {
|
1134
|
+
CURB_IMMED_SETTER(ruby_curl_easy, timeout_ms, 0);
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
/*
|
1138
|
+
* call-seq:
|
1139
|
+
* easy.timeout_ms => fixnum or nil
|
1140
|
+
*
|
1141
|
+
* Obtain the maximum time in milliseconds that you allow the libcurl transfer
|
1142
|
+
* operation to take.
|
1143
|
+
*/
|
1144
|
+
static VALUE ruby_curl_easy_timeout_ms_get(VALUE self, VALUE timeout_ms) {
|
1145
|
+
CURB_IMMED_GETTER(ruby_curl_easy, timeout_ms, 0);
|
1146
|
+
}
|
1147
|
+
|
1119
1148
|
/*
|
1120
1149
|
* call-seq:
|
1121
1150
|
* easy.connect_timeout = fixnum or nil => fixnum or nil
|
@@ -1142,6 +1171,32 @@ static VALUE ruby_curl_easy_connect_timeout_get(VALUE self, VALUE connect_timeou
|
|
1142
1171
|
CURB_IMMED_GETTER(ruby_curl_easy, connect_timeout, 0);
|
1143
1172
|
}
|
1144
1173
|
|
1174
|
+
/*
|
1175
|
+
* call-seq:
|
1176
|
+
* easy.connect_timeout_ms = fixnum or nil => fixnum or nil
|
1177
|
+
*
|
1178
|
+
* Set the maximum time in milliseconds that you allow the connection to the
|
1179
|
+
* server to take. This only limits the connection phase, once it has
|
1180
|
+
* connected, this option is of no more use.
|
1181
|
+
*
|
1182
|
+
* Set to nil (or zero) to disable connection timeout (it will then only
|
1183
|
+
* timeout on the system's internal timeouts).
|
1184
|
+
*/
|
1185
|
+
static VALUE ruby_curl_easy_connect_timeout_ms_set(VALUE self, VALUE connect_timeout_ms) {
|
1186
|
+
CURB_IMMED_SETTER(ruby_curl_easy, connect_timeout_ms, 0);
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
/*
|
1190
|
+
* call-seq:
|
1191
|
+
* easy.connect_timeout_ms => fixnum or nil
|
1192
|
+
*
|
1193
|
+
* Obtain the maximum time in milliseconds that you allow the connection to the
|
1194
|
+
* server to take.
|
1195
|
+
*/
|
1196
|
+
static VALUE ruby_curl_easy_connect_timeout_ms_get(VALUE self, VALUE connect_timeout_ms) {
|
1197
|
+
CURB_IMMED_GETTER(ruby_curl_easy, connect_timeout_ms, 0);
|
1198
|
+
}
|
1199
|
+
|
1145
1200
|
/*
|
1146
1201
|
* call-seq:
|
1147
1202
|
* easy.dns_cache_timeout = fixnum or nil => fixnum or nil
|
@@ -2052,7 +2107,9 @@ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce) {
|
|
2052
2107
|
curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, rbce->unrestricted_auth);
|
2053
2108
|
|
2054
2109
|
curl_easy_setopt(curl, CURLOPT_TIMEOUT, rbce->timeout);
|
2110
|
+
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, rbce->timeout_ms);
|
2055
2111
|
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, rbce->connect_timeout);
|
2112
|
+
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, rbce->connect_timeout_ms);
|
2056
2113
|
curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, rbce->dns_cache_timeout);
|
2057
2114
|
|
2058
2115
|
curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, rbce->ignore_content_length);
|
@@ -2103,11 +2160,12 @@ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce) {
|
|
2103
2160
|
#endif
|
2104
2161
|
}
|
2105
2162
|
|
2163
|
+
/*
|
2164
|
+
* NOTE: we used to set CURLAUTH_ANY but see: http://curl.haxx.se/mail/lib-2015-06/0033.html
|
2165
|
+
*/
|
2106
2166
|
if (rbce->http_auth_types > 0) {
|
2107
2167
|
#if LIBCURL_VERSION_NUM >= 0x070a06
|
2108
2168
|
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, rbce->http_auth_types);
|
2109
|
-
} else {
|
2110
|
-
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
2111
2169
|
#else
|
2112
2170
|
rb_warn("Installed libcurl is too old to support http_auth_types");
|
2113
2171
|
#endif
|
@@ -2116,8 +2174,6 @@ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce) {
|
|
2116
2174
|
if (rbce->proxy_auth_types > 0) {
|
2117
2175
|
#if LIBCURL_VERSION_NUM >= 0x070a07
|
2118
2176
|
curl_easy_setopt(curl, CURLOPT_PROXYAUTH, rbce->proxy_auth_types);
|
2119
|
-
} else {
|
2120
|
-
curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
|
2121
2177
|
#else
|
2122
2178
|
rb_warn("Installed libcurl is too old to support proxy_auth_types");
|
2123
2179
|
#endif
|
@@ -3082,7 +3138,7 @@ static VALUE ruby_curl_easy_last_result(VALUE self) {
|
|
3082
3138
|
* call-seq:
|
3083
3139
|
* easy.setopt Fixnum, value => value
|
3084
3140
|
*
|
3085
|
-
*
|
3141
|
+
* Initial access to libcurl curl_easy_setopt
|
3086
3142
|
*/
|
3087
3143
|
static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
|
3088
3144
|
ruby_curl_easy *rbce;
|
@@ -3125,13 +3181,6 @@ static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
|
|
3125
3181
|
case CURLOPT_NOPROGRESS:
|
3126
3182
|
case CURLOPT_NOSIGNAL:
|
3127
3183
|
case CURLOPT_HTTPGET:
|
3128
|
-
break;
|
3129
|
-
case CURLOPT_POST: {
|
3130
|
-
curl_easy_setopt(rbce->curl, CURLOPT_POST, rb_type(val) == T_TRUE);
|
3131
|
-
} break;
|
3132
|
-
case CURLOPT_POSTFIELDS: {
|
3133
|
-
curl_easy_setopt(rbce->curl, CURLOPT_POSTFIELDS, NIL_P(val) ? NULL : StringValueCStr(val));
|
3134
|
-
} break;
|
3135
3184
|
case CURLOPT_NOBODY: {
|
3136
3185
|
int type = rb_type(val);
|
3137
3186
|
VALUE value;
|
@@ -3144,6 +3193,12 @@ static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
|
|
3144
3193
|
}
|
3145
3194
|
curl_easy_setopt(rbce->curl, option, FIX2INT(value));
|
3146
3195
|
} break;
|
3196
|
+
case CURLOPT_POST: {
|
3197
|
+
curl_easy_setopt(rbce->curl, CURLOPT_POST, rb_type(val) == T_TRUE);
|
3198
|
+
} break;
|
3199
|
+
case CURLOPT_POSTFIELDS: {
|
3200
|
+
curl_easy_setopt(rbce->curl, CURLOPT_POSTFIELDS, NIL_P(val) ? NULL : StringValueCStr(val));
|
3201
|
+
} break;
|
3147
3202
|
case CURLOPT_USERPWD: {
|
3148
3203
|
VALUE userpwd = val;
|
3149
3204
|
CURB_OBJECT_HSETTER(ruby_curl_easy, userpwd);
|
@@ -3180,6 +3235,11 @@ static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
|
|
3180
3235
|
case CURLOPT_GSSAPI_DELEGATION: {
|
3181
3236
|
curl_easy_setopt(rbce->curl, CURLOPT_GSSAPI_DELEGATION, FIX2LONG(val));
|
3182
3237
|
} break;
|
3238
|
+
#endif
|
3239
|
+
#if HAVE_CURLOPT_UNIX_SOCKET_PATH
|
3240
|
+
case CURLOPT_UNIX_SOCKET_PATH: {
|
3241
|
+
curl_easy_setopt(rbce->curl, CURLOPT_UNIX_SOCKET_PATH, StringValueCStr(val));
|
3242
|
+
} break;
|
3183
3243
|
#endif
|
3184
3244
|
default:
|
3185
3245
|
rb_raise(rb_eTypeError, "Curb unsupported option");
|
@@ -3356,8 +3416,12 @@ void init_curb_easy() {
|
|
3356
3416
|
rb_define_method(cCurlEasy, "max_redirects", ruby_curl_easy_max_redirects_get, 0);
|
3357
3417
|
rb_define_method(cCurlEasy, "timeout=", ruby_curl_easy_timeout_set, 1);
|
3358
3418
|
rb_define_method(cCurlEasy, "timeout", ruby_curl_easy_timeout_get, 0);
|
3419
|
+
rb_define_method(cCurlEasy, "timeout_ms=", ruby_curl_easy_timeout_ms_set, 1);
|
3420
|
+
rb_define_method(cCurlEasy, "timeout_ms", ruby_curl_easy_timeout_ms_get, 0);
|
3359
3421
|
rb_define_method(cCurlEasy, "connect_timeout=", ruby_curl_easy_connect_timeout_set, 1);
|
3360
3422
|
rb_define_method(cCurlEasy, "connect_timeout", ruby_curl_easy_connect_timeout_get, 0);
|
3423
|
+
rb_define_method(cCurlEasy, "connect_timeout_ms=", ruby_curl_easy_connect_timeout_ms_set, 1);
|
3424
|
+
rb_define_method(cCurlEasy, "connect_timeout_ms", ruby_curl_easy_connect_timeout_ms_get, 0);
|
3361
3425
|
rb_define_method(cCurlEasy, "dns_cache_timeout=", ruby_curl_easy_dns_cache_timeout_set, 1);
|
3362
3426
|
rb_define_method(cCurlEasy, "dns_cache_timeout", ruby_curl_easy_dns_cache_timeout_get, 0);
|
3363
3427
|
rb_define_method(cCurlEasy, "ftp_response_timeout=", ruby_curl_easy_ftp_response_timeout_set, 1);
|
data/ext/curb_easy.h
CHANGED
@@ -48,7 +48,9 @@ typedef struct {
|
|
48
48
|
long proxy_auth_types;
|
49
49
|
long max_redirs;
|
50
50
|
unsigned long timeout;
|
51
|
+
unsigned long timeout_ms;
|
51
52
|
unsigned long connect_timeout;
|
53
|
+
unsigned long connect_timeout_ms;
|
52
54
|
long dns_cache_timeout;
|
53
55
|
unsigned long ftp_response_timeout;
|
54
56
|
long low_speed_limit;
|
data/ext/curb_multi.c
CHANGED
@@ -67,12 +67,14 @@ rb_hash_clear_i(VALUE key, VALUE value, VALUE dummy) {
|
|
67
67
|
}
|
68
68
|
|
69
69
|
static void curl_multi_free(ruby_curl_multi *rbcm) {
|
70
|
+
VALUE hash = rbcm->requests;
|
70
71
|
|
71
|
-
if (rbcm && !
|
72
|
+
if (rbcm && !NIL_P(hash) && rb_type(hash) == T_HASH && RHASH_SIZE(hash) > 0) {
|
72
73
|
|
73
|
-
rb_hash_foreach(
|
74
|
+
rb_hash_foreach(hash, (int (*)())curl_multi_flush_easy, (VALUE)rbcm);
|
75
|
+
rb_hash_foreach(hash, rb_hash_clear_i, 0);
|
76
|
+
/* rb_hash_clear(rbcm->requests); */
|
74
77
|
|
75
|
-
rb_hash_foreach(rbcm->requests, rb_hash_clear_i, 0); //rb_hash_clear(rbcm->requests);
|
76
78
|
rbcm->requests = Qnil;
|
77
79
|
}
|
78
80
|
curl_multi_cleanup(rbcm->handle);
|
@@ -225,12 +227,19 @@ static VALUE ruby_curl_multi_pipeline(VALUE self, VALUE onoff) {
|
|
225
227
|
*/
|
226
228
|
VALUE ruby_curl_multi_add(VALUE self, VALUE easy) {
|
227
229
|
CURLMcode mcode;
|
230
|
+
VALUE r;
|
228
231
|
ruby_curl_easy *rbce;
|
229
232
|
ruby_curl_multi *rbcm;
|
230
233
|
|
231
234
|
Data_Get_Struct(self, ruby_curl_multi, rbcm);
|
232
235
|
Data_Get_Struct(easy, ruby_curl_easy, rbce);
|
233
236
|
|
237
|
+
// check if this curl handle has been added before adding again
|
238
|
+
r = rb_hash_aref(rbcm->requests, INT2NUM((int)rbce->curl));
|
239
|
+
if ( r != Qnil ) {
|
240
|
+
return Qnil;
|
241
|
+
}
|
242
|
+
|
234
243
|
/* setup the easy handle */
|
235
244
|
ruby_curl_easy_setup( rbce );
|
236
245
|
|
@@ -245,7 +254,7 @@ VALUE ruby_curl_multi_add(VALUE self, VALUE easy) {
|
|
245
254
|
* If this number is not correct, the next call to curl_multi_perform will correct it. */
|
246
255
|
rbcm->running++;
|
247
256
|
|
248
|
-
rb_hash_aset( rbcm->requests,
|
257
|
+
rb_hash_aset( rbcm->requests, INT2NUM((int)rbce->curl), easy );
|
249
258
|
|
250
259
|
return self;
|
251
260
|
}
|
@@ -280,6 +289,12 @@ static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy) {
|
|
280
289
|
|
281
290
|
Data_Get_Struct(easy, ruby_curl_easy, rbce);
|
282
291
|
|
292
|
+
// check if this curl handle has been added before removing
|
293
|
+
r = rb_hash_aref(rbcm->requests, INT2NUM((int)rbce->curl));
|
294
|
+
if ( r == Qnil ) {
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
|
283
298
|
result = curl_multi_remove_handle(rbcm->handle, rbce->curl);
|
284
299
|
if (result != 0) {
|
285
300
|
raise_curl_multi_error_exception(result);
|
@@ -290,7 +305,7 @@ static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy) {
|
|
290
305
|
ruby_curl_easy_cleanup( easy, rbce );
|
291
306
|
|
292
307
|
// active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
|
293
|
-
r = rb_hash_delete( rbcm->requests,
|
308
|
+
r = rb_hash_delete( rbcm->requests, INT2NUM((int)rbce->curl) );
|
294
309
|
if( r != easy || r == Qnil ) {
|
295
310
|
rb_warn("Possibly lost track of Curl::Easy VALUE, it may not be reclaimed by GC");
|
296
311
|
}
|
@@ -406,8 +421,6 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
|
|
406
421
|
|
407
422
|
if (val == Qfalse) {
|
408
423
|
rb_warn("uncaught exception from callback");
|
409
|
-
// exception was raised?
|
410
|
-
//fprintf(stderr, "exception raised from callback\n");
|
411
424
|
}
|
412
425
|
|
413
426
|
}
|
data/ext/extconf.rb
CHANGED
@@ -78,6 +78,7 @@ have_constant "curl_version_largefile"
|
|
78
78
|
have_constant "curl_version_idn"
|
79
79
|
have_constant "curl_version_sspi"
|
80
80
|
have_constant "curl_version_conv"
|
81
|
+
have_constant "curl_version_http2"
|
81
82
|
have_constant "curlproxy_http"
|
82
83
|
have_constant "curlproxy_socks4"
|
83
84
|
have_constant "curlproxy_socks4a"
|
@@ -360,6 +361,9 @@ have_constant "curlgssapi_delegation_flag"
|
|
360
361
|
|
361
362
|
have_constant "CURLM_ADDED_ALREADY"
|
362
363
|
|
364
|
+
# added in 7.40.0
|
365
|
+
have_constant "curlopt_unix_socket_path"
|
366
|
+
|
363
367
|
if try_compile('int main() { return 0; }','-Wall')
|
364
368
|
$CFLAGS << ' -Wall'
|
365
369
|
end
|
data/lib/curl.rb
CHANGED
@@ -48,7 +48,7 @@ module Curl
|
|
48
48
|
|
49
49
|
def self.urlalize(url, params={})
|
50
50
|
query_str = params.map {|k,v| "#{URI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
|
51
|
-
if url.match(/\?/)
|
51
|
+
if url.match(/\?/) && query_str.size > 0
|
52
52
|
"#{url}&#{query_str}"
|
53
53
|
elsif query_str.size > 0
|
54
54
|
"#{url}?#{query_str}"
|
data/lib/curl/easy.rb
CHANGED
@@ -66,6 +66,7 @@ module Curl
|
|
66
66
|
self.multi = Curl::Multi.new if self.multi.nil?
|
67
67
|
self.multi.add self
|
68
68
|
ret = self.multi.perform
|
69
|
+
self.multi.remove self
|
69
70
|
|
70
71
|
if self.last_result != 0 && self.on_failure.nil?
|
71
72
|
error = Curl::Easy.error(self.last_result)
|
@@ -100,6 +101,7 @@ module Curl
|
|
100
101
|
# call-seq:
|
101
102
|
#
|
102
103
|
# easy = Curl::Easy.new("url")
|
104
|
+
# easy.version = Curl::HTTP_2_0
|
103
105
|
# easy.version = Curl::HTTP_1_1
|
104
106
|
# easy.version = Curl::HTTP_1_0
|
105
107
|
# easy.version = Curl::HTTP_NONE
|
data/lib/curl/multi.rb
CHANGED
@@ -3,7 +3,7 @@ module Curl
|
|
3
3
|
class Multi
|
4
4
|
class << self
|
5
5
|
# call-seq:
|
6
|
-
# Curl::Multi.get('url1','url2','url3','url4','url5', :follow_location => true) do|easy|
|
6
|
+
# Curl::Multi.get(['url1','url2','url3','url4','url5'], :follow_location => true) do|easy|
|
7
7
|
# easy
|
8
8
|
# end
|
9
9
|
#
|
@@ -92,7 +92,7 @@ module Curl
|
|
92
92
|
|
93
93
|
# configure the multi handle
|
94
94
|
multi_options.each { |k,v| m.send("#{k}=", v) }
|
95
|
-
callbacks = [:on_progress,:on_debug,:on_failure,:on_success,:on_body,:on_header]
|
95
|
+
callbacks = [:on_progress,:on_debug,:on_failure,:on_success,:on_redirect,:on_body,:on_header]
|
96
96
|
|
97
97
|
add_free_handle = proc do|conf, easy|
|
98
98
|
c = conf.dup # avoid being destructive to input
|
@@ -135,9 +135,9 @@ module Curl
|
|
135
135
|
#
|
136
136
|
c.each { |k,v| easy.send("#{k}=",v) }
|
137
137
|
|
138
|
-
easy.on_complete {|curl
|
138
|
+
easy.on_complete {|curl|
|
139
139
|
free_handles << curl
|
140
|
-
blk.call(curl,
|
140
|
+
blk.call(curl,curl.response_code,method) if blk
|
141
141
|
}
|
142
142
|
m.add(easy)
|
143
143
|
end
|
data/tests/tc_curl_easy.rb
CHANGED
@@ -341,7 +341,19 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
341
341
|
c.timeout = nil
|
342
342
|
assert_nil c.timeout
|
343
343
|
end
|
344
|
-
|
344
|
+
|
345
|
+
def test_timeout_ms_01
|
346
|
+
c = Curl::Easy.new($TEST_URL)
|
347
|
+
|
348
|
+
assert_nil c.timeout_ms
|
349
|
+
|
350
|
+
c.timeout_ms = 100
|
351
|
+
assert_equal 100, c.timeout_ms
|
352
|
+
|
353
|
+
c.timeout_ms = nil
|
354
|
+
assert_nil c.timeout_ms
|
355
|
+
end
|
356
|
+
|
345
357
|
def test_connect_timeout_01
|
346
358
|
c = Curl::Easy.new($TEST_URL)
|
347
359
|
|
@@ -353,7 +365,19 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
353
365
|
c.connect_timeout = nil
|
354
366
|
assert_nil c.connect_timeout
|
355
367
|
end
|
356
|
-
|
368
|
+
|
369
|
+
def test_connect_timeout_ms_01
|
370
|
+
c = Curl::Easy.new($TEST_URL)
|
371
|
+
|
372
|
+
assert_nil c.connect_timeout_ms
|
373
|
+
|
374
|
+
c.connect_timeout_ms = 100
|
375
|
+
assert_equal 100, c.connect_timeout_ms
|
376
|
+
|
377
|
+
c.connect_timeout_ms = nil
|
378
|
+
assert_nil c.connect_timeout_ms
|
379
|
+
end
|
380
|
+
|
357
381
|
def test_ftp_response_timeout_01
|
358
382
|
c = Curl::Easy.new($TEST_URL)
|
359
383
|
|
data/tests/timeout.rb
CHANGED
@@ -13,7 +13,7 @@ class TestCurbTimeouts < Test::Unit::TestCase
|
|
13
13
|
elapsed = Time.now - start
|
14
14
|
assert elapsed > 2
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def test_overall_timeout_on_dead_transfer
|
18
18
|
curl = Curl::Easy.new(wait_url(2))
|
19
19
|
curl.timeout = 1
|
@@ -21,7 +21,15 @@ class TestCurbTimeouts < Test::Unit::TestCase
|
|
21
21
|
curl.http_get
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
|
+
def test_overall_timeout_ms_on_dead_transfer
|
26
|
+
curl = Curl::Easy.new(wait_url(2))
|
27
|
+
curl.timeout_ms = 1000
|
28
|
+
assert_raise(Curl::Err::TimeoutError) do
|
29
|
+
curl.http_get
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
25
33
|
def test_clearing_timeout
|
26
34
|
curl = Curl::Easy.new(wait_url(2))
|
27
35
|
curl.timeout = 1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Bamford
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings
|
15
15
|
for the libcurl(3), a fully-featured client-side URL transfer library. cURL and
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
93
|
rubyforge_project: curb
|
94
|
-
rubygems_version: 2.4.
|
94
|
+
rubygems_version: 2.4.3
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Ruby libcurl bindings
|