curb 0.7.6 → 0.7.7

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/README CHANGED
@@ -144,12 +144,13 @@ documentation with:
144
144
  c = Curl::Easy.new(url) do|curl|
145
145
  curl.follow_location = true
146
146
  curl.on_body{|data| responses[url] << data; data.size }
147
+ curl.on_success {|easy| puts "success, add more easy handles" }
147
148
  end
148
149
  m.add(c)
149
150
  end
150
151
 
151
152
  m.perform do
152
- puts "idling... can do some work here, including add new requests"
153
+ puts "idling... can do some work here"
153
154
  end
154
155
 
155
156
  requests.each do|url|
data/Rakefile CHANGED
@@ -110,6 +110,25 @@ end
110
110
  task :unittests => :compile
111
111
  task :bugtests => :compile
112
112
 
113
+ def has_gem?(file,name)
114
+ begin
115
+ require file
116
+ has_http_persistent = true
117
+ rescue LoadError => e
118
+ puts "Skipping #{name}"
119
+ end
120
+ end
121
+
122
+ desc "Benchmark curl against http://127.0.0.1/zeros-2k - will fail if /zeros-2k or 127.0.0.1 are missing"
123
+ task :bench do
124
+ sh "ruby bench/curb_easy.rb"
125
+ sh "ruby bench/curb_multi.rb"
126
+ sh "ruby bench/nethttp_test.rb" if has_gem?("net/http/persistent","net-http-persistent")
127
+ sh "ruby bench/patron_test.rb" if has_gem?("patron","patron")
128
+ sh "ruby bench/typhoeus_test.rb" if has_gem?("typhoeus","typhoeus")
129
+ sh "ruby bench/typhoeus_hydra_test.rb" if has_gem?("typhoeus","typhoeus")
130
+ end
131
+
113
132
  # RDoc Tasks ---------------------------------------------------------
114
133
  desc "Create the RDOC documentation"
115
134
  task :doc do
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.7.6"
24
- #define CURB_VER_NUM 706
23
+ #define CURB_VERSION "0.7.7"
24
+ #define CURB_VER_NUM 707
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 7
27
- #define CURB_VER_MIC 6
27
+ #define CURB_VER_MIC 7
28
28
  #define CURB_VER_PATCH 0
29
29
 
30
30
 
@@ -32,6 +32,7 @@ static long cCurlMutiDefaulttimeout = 100; /* milliseconds */
32
32
 
33
33
  static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy);
34
34
  static void rb_curl_multi_read_info(VALUE self, CURLM *mptr);
35
+ static void rb_curl_multi_run(VALUE self, CURLM *multi_handle, int *still_running);
35
36
 
36
37
  static void rb_curl_multi_mark_all_easy(VALUE key, VALUE rbeasy, ruby_curl_multi *rbcm) {
37
38
  rb_gc_mark(rbeasy);
@@ -239,6 +240,8 @@ VALUE ruby_curl_multi_add(VALUE self, VALUE easy) {
239
240
 
240
241
  rb_hash_aset( rbcm->requests, easy, easy );
241
242
 
243
+ rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
244
+
242
245
  return self;
243
246
  }
244
247
 
@@ -383,8 +386,7 @@ static void rb_curl_multi_run(VALUE self, CURLM *multi_handle, int *still_runnin
383
386
  if (mcode != CURLM_OK) {
384
387
  raise_curl_multi_error_exception(mcode);
385
388
  }
386
-
387
- rb_curl_multi_read_info( self, multi_handle );
389
+
388
390
  }
389
391
 
390
392
  /*
@@ -416,65 +418,72 @@ VALUE ruby_curl_multi_perform(int argc, VALUE *argv, VALUE self) {
416
418
 
417
419
  Data_Get_Struct(self, ruby_curl_multi, rbcm);
418
420
 
419
- rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
421
+ timeout_milliseconds = cCurlMutiDefaulttimeout;
420
422
 
421
- while (rbcm->running) {
423
+ rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
424
+
425
+ do {
426
+ while (rbcm->running) {
422
427
 
423
428
  #ifdef HAVE_CURL_MULTI_TIMEOUT
424
- /* get the curl suggested time out */
425
- mcode = curl_multi_timeout(rbcm->handle, &timeout_milliseconds);
426
- if (mcode != CURLM_OK) {
427
- raise_curl_multi_error_exception(mcode);
428
- }
429
+ /* get the curl suggested time out */
430
+ mcode = curl_multi_timeout(rbcm->handle, &timeout_milliseconds);
431
+ if (mcode != CURLM_OK) {
432
+ raise_curl_multi_error_exception(mcode);
433
+ }
429
434
  #else
430
- /* libcurl doesn't have a timeout method defined, initialize to -1 we'll pick up the default later */
431
- timeout_milliseconds = -1;
435
+ /* libcurl doesn't have a timeout method defined, initialize to -1 we'll pick up the default later */
436
+ timeout_milliseconds = -1;
432
437
  #endif
433
438
 
434
- if (timeout_milliseconds == 0) { /* no delay */
435
- rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
436
- continue;
437
- }
438
- else if (timeout_milliseconds < 0) {
439
- timeout_milliseconds = cCurlMutiDefaulttimeout; /* libcurl doesn't know how long to wait, use a default timeout */
440
- }
439
+ if (timeout_milliseconds == 0) { /* no delay */
440
+ rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
441
+ continue;
442
+ }
443
+ else if (timeout_milliseconds < 0) {
444
+ timeout_milliseconds = cCurlMutiDefaulttimeout; /* libcurl doesn't know how long to wait, use a default timeout */
445
+ }
441
446
 
442
- if (timeout_milliseconds > cCurlMutiDefaulttimeout) {
443
- timeout_milliseconds = cCurlMutiDefaulttimeout; /* buggy versions libcurl sometimes reports huge timeouts... let's cap it */
444
- }
447
+ if (timeout_milliseconds > cCurlMutiDefaulttimeout) {
448
+ timeout_milliseconds = cCurlMutiDefaulttimeout; /* buggy versions libcurl sometimes reports huge timeouts... let's cap it */
449
+ }
445
450
 
446
- tv.tv_sec = 0; /* never wait longer than 1 second */
447
- tv.tv_usec = timeout_milliseconds * 1000;
451
+ tv.tv_sec = 0; /* never wait longer than 1 second */
452
+ tv.tv_usec = timeout_milliseconds * 1000;
448
453
 
449
- FD_ZERO(&fdread);
450
- FD_ZERO(&fdwrite);
451
- FD_ZERO(&fdexcep);
454
+ if (timeout_milliseconds == 0) { /* no delay */
455
+ rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
456
+ continue;
457
+ }
452
458
 
453
- /* load the fd sets from the multi handle */
454
- mcode = curl_multi_fdset(rbcm->handle, &fdread, &fdwrite, &fdexcep, &maxfd);
455
- if (mcode != CURLM_OK) {
456
- raise_curl_multi_error_exception(mcode);
457
- }
459
+ if (block != Qnil) { rb_funcall(block, rb_intern("call"), 1, self); }
458
460
 
459
- rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv);
460
- switch(rc) {
461
- case -1:
462
- rb_raise(rb_eRuntimeError, "select(): %s", strerror(errno));
463
- break;
464
- case 0:
465
- if (block != Qnil) {
466
- rb_funcall(block, rb_intern("call"), 1, self);
461
+ FD_ZERO(&fdread);
462
+ FD_ZERO(&fdwrite);
463
+ FD_ZERO(&fdexcep);
464
+ /* load the fd sets from the multi handle */
465
+ mcode = curl_multi_fdset(rbcm->handle, &fdread, &fdwrite, &fdexcep, &maxfd);
466
+ if (mcode != CURLM_OK) {
467
+ raise_curl_multi_error_exception(mcode);
467
468
  }
468
- // if (rb_block_given_p()) {
469
- // rb_yield(self);
470
- // }
471
- default:
472
- rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
473
- break;
474
- }
475
-
476
- }
477
469
 
470
+ rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv);
471
+ switch(rc) {
472
+ case -1:
473
+ rb_raise(rb_eRuntimeError, "select(): %s", strerror(errno));
474
+ break;
475
+ case 0:
476
+ rb_curl_multi_read_info( self, rbcm->handle );
477
+ if (block != Qnil) { rb_funcall(block, rb_intern("call"), 1, self); }
478
+ default:
479
+ rb_curl_multi_run( self, rbcm->handle, &(rbcm->running) );
480
+ break;
481
+ }
482
+ }
483
+ rb_curl_multi_read_info( self, rbcm->handle );
484
+ if (block != Qnil) { rb_funcall(block, rb_intern("call"), 1, self); }
485
+ } while( rbcm->running );
486
+
478
487
  return Qtrue;
479
488
  }
480
489
 
@@ -11,6 +11,7 @@ $:.unshift($EXTDIR)
11
11
 
12
12
  require 'curb'
13
13
  require 'test/unit'
14
+ require 'fileutils'
14
15
 
15
16
  $TEST_URL = "file://#{URI.escape(File.expand_path(__FILE__).tr('\\','/').tr(':','|'))}"
16
17
 
@@ -73,9 +74,7 @@ class TestServlet < WEBrick::HTTPServlet::AbstractServlet
73
74
  end
74
75
 
75
76
  def do_POST(req,res)
76
- if !req.query['filename'].nil?
77
- respond_with(req.query['filename'],req,res)
78
- else
77
+ if req.query['filename'].nil?
79
78
  if req.body
80
79
  params = {}
81
80
  req.body.split('&').map{|s| k,v=s.split('='); params[k] = v }
@@ -85,6 +84,8 @@ class TestServlet < WEBrick::HTTPServlet::AbstractServlet
85
84
  else
86
85
  respond_with("POST\n#{req.body}",req,res)
87
86
  end
87
+ else
88
+ respond_with(req.query['filename'],req,res)
88
89
  end
89
90
  end
90
91
 
@@ -674,7 +674,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
674
674
  #curl.verbose = true
675
675
  curl.perform
676
676
  assert_equal 'Basic Zm9vOmJhcg==', $auth_header
677
-
677
+ $auth_header = nil
678
678
  # curl checks the auth type supported by the server, so we have to create a
679
679
  # new easy handle if we're going to change the auth type...
680
680
 
@@ -712,6 +712,7 @@ class TestCurbCurlEasy < Test::Unit::TestCase
712
712
  assert_equal(easy.body_str,File.read(readme))
713
713
  end
714
714
 
715
+
715
716
  def test_easy_close
716
717
  easy = Curl::Easy.new
717
718
  easy.close
@@ -170,7 +170,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
170
170
 
171
171
  m.perform do
172
172
  # idle
173
- puts "idling..."
173
+ #puts "idling..."
174
174
  end
175
175
 
176
176
  assert success_called2
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 6
10
- version: 0.7.6
9
+ - 7
10
+ version: 0.7.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ross Bamford
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-11 00:00:00 -04:00
19
+ date: 2010-06-21 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -35,38 +35,38 @@ files:
35
35
  - Rakefile
36
36
  - doc.rb
37
37
  - ext/extconf.rb
38
- - lib/curb.rb
39
38
  - lib/curl.rb
39
+ - lib/curb.rb
40
40
  - ext/curb.c
41
+ - ext/curb_upload.c
42
+ - ext/curb_postfield.c
41
43
  - ext/curb_easy.c
42
- - ext/curb_errors.c
43
44
  - ext/curb_multi.c
44
- - ext/curb_postfield.c
45
- - ext/curb_upload.c
46
- - ext/curb.h
47
- - ext/curb_easy.h
45
+ - ext/curb_errors.c
48
46
  - ext/curb_errors.h
49
- - ext/curb_macros.h
50
47
  - ext/curb_multi.h
48
+ - ext/curb.h
49
+ - ext/curb_easy.h
51
50
  - ext/curb_postfield.h
52
51
  - ext/curb_upload.h
53
- - tests/alltests.rb
54
- - tests/bug_curb_easy_blocks_ruby_threads.rb
55
- - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
52
+ - ext/curb_macros.h
53
+ - tests/bugtests.rb
54
+ - tests/mem_check.rb
55
+ - tests/bug_require_last_or_segfault.rb
56
+ - tests/helper.rb
57
+ - tests/tc_curl_postfield.rb
56
58
  - tests/bug_instance_post_differs_from_class_post.rb
57
59
  - tests/bug_multi_segfault.rb
60
+ - tests/alltests.rb
58
61
  - tests/bug_postfields_crash.rb
59
- - tests/bug_postfields_crash2.rb
60
- - tests/bug_require_last_or_segfault.rb
61
- - tests/bugtests.rb
62
- - tests/helper.rb
63
- - tests/mem_check.rb
64
62
  - tests/require_last_or_segfault_script.rb
63
+ - tests/bug_postfields_crash2.rb
64
+ - tests/unittests.rb
65
+ - tests/tc_curl_multi.rb
66
+ - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
65
67
  - tests/tc_curl_download.rb
66
68
  - tests/tc_curl_easy.rb
67
- - tests/tc_curl_multi.rb
68
- - tests/tc_curl_postfield.rb
69
- - tests/unittests.rb
69
+ - tests/bug_curb_easy_blocks_ruby_threads.rb
70
70
  has_rdoc: true
71
71
  homepage: http://curb.rubyforge.org/
72
72
  licenses: []
@@ -104,20 +104,20 @@ signing_key:
104
104
  specification_version: 3
105
105
  summary: Ruby libcurl bindings
106
106
  test_files:
107
- - tests/alltests.rb
108
- - tests/bug_curb_easy_blocks_ruby_threads.rb
109
- - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
107
+ - tests/bugtests.rb
108
+ - tests/mem_check.rb
109
+ - tests/bug_require_last_or_segfault.rb
110
+ - tests/helper.rb
111
+ - tests/tc_curl_postfield.rb
110
112
  - tests/bug_instance_post_differs_from_class_post.rb
111
113
  - tests/bug_multi_segfault.rb
114
+ - tests/alltests.rb
112
115
  - tests/bug_postfields_crash.rb
113
- - tests/bug_postfields_crash2.rb
114
- - tests/bug_require_last_or_segfault.rb
115
- - tests/bugtests.rb
116
- - tests/helper.rb
117
- - tests/mem_check.rb
118
116
  - tests/require_last_or_segfault_script.rb
117
+ - tests/bug_postfields_crash2.rb
118
+ - tests/unittests.rb
119
+ - tests/tc_curl_multi.rb
120
+ - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
119
121
  - tests/tc_curl_download.rb
120
122
  - tests/tc_curl_easy.rb
121
- - tests/tc_curl_multi.rb
122
- - tests/tc_curl_postfield.rb
123
- - tests/unittests.rb
123
+ - tests/bug_curb_easy_blocks_ruby_threads.rb