curb 0.6.5.1 → 0.6.6.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
@@ -100,7 +100,7 @@ Rake::TestTask.new(:bugtests) do |t|
100
100
  t.test_files = FileList['tests/bug_*.rb']
101
101
  t.verbose = false
102
102
  end
103
-
103
+
104
104
  #Rake::TestTask.new(:funtests) do |t|
105
105
  # t.test_files = FileList['test/func_*.rb']
106
106
  #t.warning = true
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.6.5.1"
24
- #define CURB_VER_NUM 651
23
+ #define CURB_VERSION "0.6.6.0"
24
+ #define CURB_VER_NUM 660
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 6
27
- #define CURB_VER_MIC 5
28
- #define CURB_VER_PATCH 1
27
+ #define CURB_VER_MIC 6
28
+ #define CURB_VER_PATCH 0
29
29
 
30
30
 
31
31
  // Maybe not yet defined in Ruby
data/ext/curb_easy.c CHANGED
@@ -134,46 +134,6 @@ static int proc_debug_handler(CURL *curl,
134
134
 
135
135
  /* ================== MARK/FREE FUNC ==================*/
136
136
  void curl_easy_mark(ruby_curl_easy *rbce) {
137
- #if 0
138
- rb_gc_mark(rbce->url);
139
- rb_gc_mark(rbce->proxy_url);
140
- rb_gc_mark(rbce->body_proc);
141
- rb_gc_mark(rbce->body_data);
142
- rb_gc_mark(rbce->header_proc);
143
- rb_gc_mark(rbce->header_data);
144
- rb_gc_mark(rbce->progress_proc);
145
- rb_gc_mark(rbce->debug_proc);
146
- rb_gc_mark(rbce->interface_hm);
147
- rb_gc_mark(rbce->userpwd);
148
- #if HAVE_CURLOPT_USERNAME
149
- rb_gc_mark(rbce->username);
150
- #endif
151
- #if HAVE_CURLOPT_PASSWORD
152
- rb_gc_mark(rbce->password);
153
- #endif
154
- rb_gc_mark(rbce->proxypwd);
155
- rb_gc_mark(rbce->headers);
156
- rb_gc_mark(rbce->cookies);
157
- rb_gc_mark(rbce->cookiefile);
158
- rb_gc_mark(rbce->cookiejar);
159
- rb_gc_mark(rbce->cert);
160
- rb_gc_mark(rbce->cacert);
161
- rb_gc_mark(rbce->certpassword);
162
- rb_gc_mark(rbce->certtype);
163
- rb_gc_mark(rbce->encoding);
164
- rb_gc_mark(rbce->useragent);
165
- rb_gc_mark(rbce->success_proc);
166
- rb_gc_mark(rbce->failure_proc);
167
- rb_gc_mark(rbce->complete_proc);
168
-
169
- rb_gc_mark(rbce->postdata_buffer);
170
- rb_gc_mark(rbce->bodybuf);
171
- rb_gc_mark(rbce->headerbuf);
172
-
173
- if( rbce->upload != Qnil ) {
174
- rb_gc_mark(rbce->upload);
175
- }
176
- #endif
177
137
  rb_gc_mark(rbce->opts);
178
138
  }
179
139
 
@@ -1568,10 +1528,11 @@ static VALUE cb_each_http_header(VALUE header, struct curl_slist **list) {
1568
1528
  *
1569
1529
  * Always returns Qtrue, rb_raise on error.
1570
1530
  */
1571
- VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, struct curl_slist **hdrs ) {
1531
+ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
1572
1532
  // TODO this could do with a bit of refactoring...
1573
1533
  CURL *curl;
1574
1534
  VALUE url, _url = rb_easy_get("url");
1535
+ struct curl_slist **hdrs = &(rbce->curl_headers);
1575
1536
 
1576
1537
  curl = rbce->curl;
1577
1538
 
@@ -1823,10 +1784,10 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, struct curl_slist **hdrs ) {
1823
1784
  *
1824
1785
  * Always returns Qtrue.
1825
1786
  */
1826
- VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce, struct curl_slist *headers ) {
1787
+ VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce ) {
1827
1788
 
1828
1789
  CURL *curl = rbce->curl;
1829
-
1790
+ struct curl_slist *headers = rbce->curl_headers;
1830
1791
  // Free everything up
1831
1792
  if (headers) {
1832
1793
  curl_slist_free_all(headers);
data/ext/curb_easy.h CHANGED
@@ -53,8 +53,8 @@ typedef struct {
53
53
 
54
54
  extern VALUE cCurlEasy;
55
55
 
56
- VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce, struct curl_slist **headers);
57
- VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce, struct curl_slist *headers);
56
+ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce);
57
+ VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce);
58
58
 
59
59
  void init_curb_easy();
60
60
 
data/ext/curb_multi.c CHANGED
@@ -28,6 +28,8 @@ static VALUE idCall;
28
28
 
29
29
  VALUE cCurlMulti;
30
30
 
31
+ static long cCurlMutiDefaulttimeout = 100; /* milliseconds */
32
+
31
33
  static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy);
32
34
  static void rb_curl_multi_read_info(VALUE self, CURLM *mptr);
33
35
 
@@ -92,6 +94,30 @@ VALUE ruby_curl_multi_new(VALUE klass) {
92
94
  return new_curlm;
93
95
  }
94
96
 
97
+ /*
98
+ * call-seq:
99
+ * Curl::Multi.default_timeout = 4 => 4
100
+ *
101
+ * Set the global default time out for all Curl::Multi Handles. This value is used
102
+ * when libcurl cannot determine a timeout value when calling curl_multi_timeout.
103
+ *
104
+ */
105
+ VALUE ruby_curl_multi_set_default_timeout(VALUE klass, VALUE timeout) {
106
+ cCurlMutiDefaulttimeout = FIX2LONG(timeout);
107
+ return timeout;
108
+ }
109
+
110
+ /*
111
+ * call-seq:
112
+ * Curl::Multi.default_timeout = 4 => 4
113
+ *
114
+ * Get the global default time out for all Curl::Multi Handles.
115
+ *
116
+ */
117
+ VALUE ruby_curl_multi_get_default_timeout(VALUE klass) {
118
+ return INT2FIX(cCurlMutiDefaulttimeout);
119
+ }
120
+
95
121
  /* Hash#foreach callback for ruby_curl_multi_requests */
96
122
  static int ruby_curl_multi_requests_callback(VALUE key, VALUE value, VALUE result_array) {
97
123
  rb_ary_push(result_array, value);
@@ -194,14 +220,14 @@ VALUE ruby_curl_multi_add(VALUE self, VALUE easy) {
194
220
  Data_Get_Struct(self, ruby_curl_multi, rbcm);
195
221
  Data_Get_Struct(easy, ruby_curl_easy, rbce);
196
222
 
223
+ /* setup the easy handle */
224
+ ruby_curl_easy_setup( rbce );
225
+
197
226
  mcode = curl_multi_add_handle(rbcm->handle, rbce->curl);
198
227
  if (mcode != CURLM_CALL_MULTI_PERFORM && mcode != CURLM_OK) {
199
228
  raise_curl_multi_error_exception(mcode);
200
229
  }
201
230
 
202
- /* setup the easy handle */
203
- ruby_curl_easy_setup( rbce, &(rbce->curl_headers) );
204
-
205
231
  rbcm->active++;
206
232
 
207
233
  /* Increase the running count, so that the perform loop keeps running.
@@ -253,7 +279,7 @@ static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy) {
253
279
 
254
280
  rbcm->active--;
255
281
 
256
- ruby_curl_easy_cleanup( easy, rbce, rbce->curl_headers );
282
+ ruby_curl_easy_cleanup( easy, rbce );
257
283
 
258
284
  // active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
259
285
  r = rb_hash_delete( rbcm->requests, easy );
@@ -417,11 +443,11 @@ VALUE ruby_curl_multi_perform(int argc, VALUE *argv, VALUE self) {
417
443
  continue;
418
444
  }
419
445
  else if(timeout_milliseconds < 0) {
420
- timeout_milliseconds = 500; /* wait half a second, libcurl doesn't know how long to wait */
446
+ timeout_milliseconds = cCurlMutiDefaulttimeout; /* wait half a second, libcurl doesn't know how long to wait */
421
447
  }
422
448
  #ifdef __APPLE_CC__
423
449
  if(timeout_milliseconds > 1000) {
424
- timeout_milliseconds = 1000; /* apple libcurl sometimes reports huge timeouts... let's cap it */
450
+ timeout_milliseconds = cCurlMutiDefaulttimeout; /* apple libcurl sometimes reports huge timeouts... let's cap it */
425
451
  }
426
452
  #endif
427
453
 
@@ -458,6 +484,8 @@ void init_curb_multi() {
458
484
 
459
485
  /* Class methods */
460
486
  rb_define_singleton_method(cCurlMulti, "new", ruby_curl_multi_new, 0);
487
+ rb_define_singleton_method(cCurlMulti, "default_timeout=", ruby_curl_multi_set_default_timeout, 1);
488
+ rb_define_singleton_method(cCurlMulti, "default_timeout", ruby_curl_multi_get_default_timeout, 0);
461
489
 
462
490
  /* "Attributes" */
463
491
  rb_define_method(cCurlMulti, "requests", ruby_curl_multi_requests, 0);
@@ -6,5 +6,9 @@
6
6
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__),'..','ext'))
7
7
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
8
8
  require 'curb'
9
- multi = Curl::Multi.new
10
- exit
9
+
10
+ class BugMultiSegfault < Test::Unit::TestCase
11
+ def test_bug
12
+ multi = Curl::Multi.new
13
+ end
14
+ end
data/tests/bugtests.rb ADDED
@@ -0,0 +1,9 @@
1
+ $: << $TESTDIR = File.expand_path(File.dirname(__FILE__))
2
+ puts "start"
3
+ begin
4
+ Dir[File.join($TESTDIR, 'bug_*.rb')].each { |lib| require lib }
5
+ rescue Object => e
6
+ puts e.message
7
+ ensure
8
+ puts "done"
9
+ end
@@ -424,6 +424,13 @@ class TestCurbCurlMulti < Test::Unit::TestCase
424
424
  assert_equal Curl::Err::MultiBadEasyHandle, e.class
425
425
  end
426
426
 
427
+ def test_multi_default_timeout
428
+ assert_equal 100, Curl::Multi.default_timeout
429
+ Curl::Multi.default_timeout = 12
430
+ assert_equal 12, Curl::Multi.default_timeout
431
+ assert_equal 100, (Curl::Multi.default_timeout = 100)
432
+ end
433
+
427
434
  include TestServerMethods
428
435
 
429
436
  def setup
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.6.5.1
4
+ version: 0.6.6.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: 2010-01-29 00:00:00 -05:00
13
+ date: 2010-01-31 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -32,18 +32,18 @@ files:
32
32
  - lib/curb.rb
33
33
  - lib/curl.rb
34
34
  - ext/curb.c
35
- - ext/curb_postfield.c
36
- - ext/curb_multi.c
37
- - ext/curb_errors.c
38
35
  - ext/curb_easy.c
36
+ - ext/curb_errors.c
37
+ - ext/curb_multi.c
38
+ - ext/curb_postfield.c
39
39
  - ext/curb_upload.c
40
+ - ext/curb.h
40
41
  - ext/curb_easy.h
41
42
  - ext/curb_errors.h
42
- - ext/curb_upload.h
43
43
  - ext/curb_macros.h
44
- - ext/curb.h
45
- - ext/curb_postfield.h
46
44
  - ext/curb_multi.h
45
+ - ext/curb_postfield.h
46
+ - ext/curb_upload.h
47
47
  has_rdoc: true
48
48
  homepage: http://curb.rubyforge.org/
49
49
  licenses: []
@@ -75,19 +75,19 @@ signing_key:
75
75
  specification_version: 3
76
76
  summary: Ruby libcurl bindings
77
77
  test_files:
78
- - tests/tc_curl_multi.rb
79
- - tests/tc_curl_postfield.rb
80
- - tests/bug_curb_easy_blocks_ruby_threads.rb
81
- - tests/unittests.rb
82
- - tests/mem_check.rb
83
- - tests/bug_require_last_or_segfault.rb
84
- - tests/bug_instance_post_differs_from_class_post.rb
85
- - tests/tc_curl_download.rb
86
78
  - tests/alltests.rb
79
+ - tests/bug_curb_easy_blocks_ruby_threads.rb
87
80
  - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
88
- - tests/helper.rb
89
- - tests/tc_curl_easy.rb
81
+ - tests/bug_instance_post_differs_from_class_post.rb
90
82
  - tests/bug_multi_segfault.rb
91
- - tests/require_last_or_segfault_script.rb
92
83
  - tests/bug_postfields_crash.rb
93
- - tests/s.rb
84
+ - tests/bug_require_last_or_segfault.rb
85
+ - tests/bugtests.rb
86
+ - tests/helper.rb
87
+ - tests/mem_check.rb
88
+ - tests/require_last_or_segfault_script.rb
89
+ - tests/tc_curl_download.rb
90
+ - tests/tc_curl_easy.rb
91
+ - tests/tc_curl_multi.rb
92
+ - tests/tc_curl_postfield.rb
93
+ - tests/unittests.rb
data/tests/s.rb DELETED
@@ -1,4 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- c = Curl::Easy.new("http://www.google.com/")
4
- c.perform