ghazel-curb 0.5.9.1 → 0.6.1.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.
- data/ext/curb.h +5 -5
- data/ext/curb_easy.c +3 -8
- data/ext/curb_easy.h +1 -1
- data/ext/curb_multi.c +13 -17
- data/tests/tc_curl_multi.rb +15 -4
- metadata +2 -2
data/ext/curb.h
CHANGED
@@ -20,12 +20,12 @@
|
|
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.6.1.0"
|
24
|
+
#define CURB_VER_NUM 610
|
25
25
|
#define CURB_VER_MAJ 0
|
26
|
-
#define CURB_VER_MIN
|
27
|
-
#define CURB_VER_MIC
|
28
|
-
#define CURB_VER_PATCH
|
26
|
+
#define CURB_VER_MIN 6
|
27
|
+
#define CURB_VER_MIC 1
|
28
|
+
#define CURB_VER_PATCH 0
|
29
29
|
|
30
30
|
|
31
31
|
// Maybe not yet defined in Ruby
|
data/ext/curb_easy.c
CHANGED
@@ -162,10 +162,6 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
|
|
162
162
|
rb_gc_mark(rbce->bodybuf);
|
163
163
|
rb_gc_mark(rbce->headerbuf);
|
164
164
|
|
165
|
-
if( rbce->self != Qnil ) {
|
166
|
-
rb_gc_mark(rbce->self);
|
167
|
-
}
|
168
|
-
|
169
165
|
if( rbce->upload != Qnil ) {
|
170
166
|
rb_gc_mark(rbce->upload);
|
171
167
|
}
|
@@ -263,13 +259,12 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
|
|
263
259
|
rbce->headerbuf = Qnil;
|
264
260
|
rbce->curl_headers = NULL;
|
265
261
|
|
266
|
-
rbce->self = Qnil;
|
267
262
|
rbce->upload = Qnil;
|
268
263
|
|
269
264
|
new_curl = Data_Wrap_Struct(klass, curl_easy_mark, curl_easy_free, rbce);
|
270
265
|
|
271
|
-
/* set the
|
272
|
-
ecode = curl_easy_setopt(rbce->curl, CURLOPT_PRIVATE, (void*)
|
266
|
+
/* set the new_curl pointer to the curl handle */
|
267
|
+
ecode = curl_easy_setopt(rbce->curl, CURLOPT_PRIVATE, (void*)new_curl);
|
273
268
|
if (ecode != CURLE_OK) {
|
274
269
|
raise_curl_easy_error_exception(ecode);
|
275
270
|
}
|
@@ -2636,7 +2631,7 @@ static VALUE ruby_curl_easy_escape(VALUE self, VALUE svalue) {
|
|
2636
2631
|
|
2637
2632
|
/*
|
2638
2633
|
* call-seq:
|
2639
|
-
* easy.unescape("some
|
2634
|
+
* easy.unescape("some%20text") => "some text"
|
2640
2635
|
*
|
2641
2636
|
* Convert the given URL encoded input string to a "plain string" and return
|
2642
2637
|
* the result. All input characters that are URL encoded (%XX where XX is a
|
data/ext/curb_easy.h
CHANGED
@@ -86,7 +86,7 @@ typedef struct {
|
|
86
86
|
VALUE headerbuf;
|
87
87
|
struct curl_slist *curl_headers;
|
88
88
|
|
89
|
-
VALUE self; /* pointer to self, used by multi interface */
|
89
|
+
// VALUE self; /* pointer to self, used by multi interface */
|
90
90
|
VALUE upload; /* pointer to an active upload otherwise Qnil */
|
91
91
|
|
92
92
|
int last_result; /* last result code from multi loop */
|
data/ext/curb_multi.c
CHANGED
@@ -199,9 +199,6 @@ VALUE ruby_curl_multi_add(VALUE self, VALUE easy) {
|
|
199
199
|
raise_curl_multi_error_exception(mcode);
|
200
200
|
}
|
201
201
|
|
202
|
-
/* save a pointer to self */
|
203
|
-
rbce->self = easy;
|
204
|
-
|
205
202
|
/* setup the easy handle */
|
206
203
|
ruby_curl_easy_setup( rbce, &(rbce->bodybuf), &(rbce->headerbuf), &(rbce->curl_headers) );
|
207
204
|
|
@@ -263,11 +260,11 @@ static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy) {
|
|
263
260
|
// active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
|
264
261
|
r = rb_hash_delete( rbcm->requests, easy );
|
265
262
|
if( r != easy || r == Qnil ) {
|
266
|
-
|
263
|
+
rb_warn("Possibly lost tack of Curl::Easy VALUE, it may not be reclaimed by GC");
|
267
264
|
}
|
268
265
|
}
|
269
266
|
|
270
|
-
|
267
|
+
/* Hash#foreach callback for ruby_curl_multi_cancel */
|
271
268
|
static int ruby_curl_multi_cancel_callback(VALUE key, VALUE value, ruby_curl_multi *rbcm) {
|
272
269
|
rb_curl_multi_remove(rbcm, value);
|
273
270
|
|
@@ -287,16 +284,19 @@ static VALUE ruby_curl_multi_cancel(VALUE self) {
|
|
287
284
|
|
288
285
|
rb_hash_foreach( rbcm->requests, ruby_curl_multi_cancel_callback, (VALUE)rbcm );
|
289
286
|
|
290
|
-
|
287
|
+
/* for chaining */
|
291
288
|
return self;
|
292
289
|
}
|
293
290
|
|
294
291
|
static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int result) {
|
295
292
|
|
296
293
|
long response_code = -1;
|
294
|
+
VALUE easy;
|
297
295
|
ruby_curl_easy *rbce = NULL;
|
298
|
-
|
299
|
-
CURLcode ecode = curl_easy_getinfo(easy_handle, CURLINFO_PRIVATE, (char**)&
|
296
|
+
|
297
|
+
CURLcode ecode = curl_easy_getinfo(easy_handle, CURLINFO_PRIVATE, (char**)&easy);
|
298
|
+
|
299
|
+
Data_Get_Struct(easy, ruby_curl_easy, rbce);
|
300
300
|
|
301
301
|
if (ecode != 0) {
|
302
302
|
raise_curl_easy_error_exception(ecode);
|
@@ -304,31 +304,27 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
|
|
304
304
|
|
305
305
|
rbce->last_result = result; /* save the last easy result code */
|
306
306
|
|
307
|
-
ruby_curl_multi_remove( self,
|
307
|
+
ruby_curl_multi_remove( self, easy );
|
308
308
|
|
309
309
|
if (rbce->complete_proc != Qnil) {
|
310
|
-
rb_funcall( rbce->complete_proc, idCall, 1,
|
310
|
+
rb_funcall( rbce->complete_proc, idCall, 1, easy );
|
311
311
|
}
|
312
312
|
|
313
313
|
curl_easy_getinfo(rbce->curl, CURLINFO_RESPONSE_CODE, &response_code);
|
314
314
|
|
315
|
-
ref = rbce->self;
|
316
|
-
/* break reference */
|
317
|
-
rbce->self = Qnil;
|
318
|
-
|
319
315
|
if (result != 0) {
|
320
316
|
if (rbce->failure_proc != Qnil) {
|
321
|
-
rb_funcall( rbce->failure_proc, idCall, 2,
|
317
|
+
rb_funcall( rbce->failure_proc, idCall, 2, easy, rb_curl_easy_error(result) );
|
322
318
|
}
|
323
319
|
}
|
324
320
|
else if (rbce->success_proc != Qnil &&
|
325
321
|
((response_code >= 200 && response_code < 300) || response_code == 0)) {
|
326
322
|
/* NOTE: we allow response_code == 0, in the case of non http requests e.g. reading from disk */
|
327
|
-
rb_funcall( rbce->success_proc, idCall, 1,
|
323
|
+
rb_funcall( rbce->success_proc, idCall, 1, easy );
|
328
324
|
}
|
329
325
|
else if (rbce->failure_proc != Qnil &&
|
330
326
|
(response_code >= 300 && response_code <= 999)) {
|
331
|
-
rb_funcall( rbce->failure_proc, idCall, 2,
|
327
|
+
rb_funcall( rbce->failure_proc, idCall, 2, easy, rb_curl_easy_error(result) );
|
332
328
|
}
|
333
329
|
}
|
334
330
|
|
data/tests/tc_curl_multi.rb
CHANGED
@@ -391,7 +391,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
391
391
|
def test_retry_easy_handle
|
392
392
|
m = Curl::Multi.new
|
393
393
|
|
394
|
-
tries =
|
394
|
+
tries = 10
|
395
395
|
|
396
396
|
c1 = Curl::Easy.new('http://127.1.1.1:99911') do |curl|
|
397
397
|
curl.on_failure {|c,e|
|
@@ -406,13 +406,24 @@ class TestCurbCurlMulti < Test::Unit::TestCase
|
|
406
406
|
tries -= 1
|
407
407
|
m.add(c1)
|
408
408
|
|
409
|
-
|
410
|
-
m.perform
|
411
|
-
end
|
409
|
+
m.perform
|
412
410
|
assert_equal 0, tries
|
413
411
|
assert_equal 0, m.requests.size
|
414
412
|
end
|
415
413
|
|
414
|
+
def test_reusing_handle
|
415
|
+
m = Curl::Multi.new
|
416
|
+
|
417
|
+
c = Curl::Easy.new('http://127.0.0.1') do|easy|
|
418
|
+
easy.on_complete{|e,r| puts e.inspect }
|
419
|
+
end
|
420
|
+
|
421
|
+
m.add(c)
|
422
|
+
m.add(c)
|
423
|
+
rescue => e
|
424
|
+
assert_equal Curl::Err::MultiBadEasyHandle, e.class
|
425
|
+
end
|
426
|
+
|
416
427
|
include TestServerMethods
|
417
428
|
|
418
429
|
def setup
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghazel-curb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Bamford
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-12-06 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|