curb 0.7.16 → 0.7.17

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/clean'
4
4
  require 'rake/testtask'
5
5
  begin
6
6
  require 'rdoc/task'
7
- rescue LoadError
7
+ rescue LoadError => e
8
8
  require 'rake/rdoctask'
9
9
  end
10
10
 
data/ext/curb.c CHANGED
@@ -363,12 +363,24 @@ void Init_curb_core() {
363
363
  CURB_DEFINE(CURLOPT_READDATA);
364
364
  CURB_DEFINE(CURLOPT_IOCTLFUNCTION);
365
365
  CURB_DEFINE(CURLOPT_IOCTLDATA);
366
+ #if HAVE_CURLOPT_SEEKFUNCTION
366
367
  CURB_DEFINE(CURLOPT_SEEKFUNCTION);
368
+ #endif
369
+ #if HAVE_CURLOPT_SEEKDATA
367
370
  CURB_DEFINE(CURLOPT_SEEKDATA);
371
+ #endif
372
+ #if HAVE_CURLOPT_SOCKOPTFUNCTION
368
373
  CURB_DEFINE(CURLOPT_SOCKOPTFUNCTION);
374
+ #endif
375
+ #if HAVE_CURLOPT_SOCKOPTDATA
369
376
  CURB_DEFINE(CURLOPT_SOCKOPTDATA);
377
+ #endif
378
+ #if HAVE_CURLOPT_OPENSOCKETFUNCTION
370
379
  CURB_DEFINE(CURLOPT_OPENSOCKETFUNCTION);
380
+ #endif
381
+ #if HAVE_CURLOPT_OPENSOCKETDATA
371
382
  CURB_DEFINE(CURLOPT_OPENSOCKETDATA);
383
+ #endif
372
384
  CURB_DEFINE(CURLOPT_PROGRESSFUNCTION);
373
385
  CURB_DEFINE(CURLOPT_PROGRESSDATA);
374
386
  CURB_DEFINE(CURLOPT_HEADERFUNCTION);
@@ -838,9 +850,6 @@ void Init_curb_core() {
838
850
  #if HAVE_CURLOPT_SSLVERSION
839
851
  CURB_DEFINE(CURLOPT_SSLVERSION);
840
852
  #endif
841
- #if HAVE_CURL_SSLVERSION_DEFAULT
842
- CURB_DEFINE(CURL_SSLVERSION_DEFAULT);
843
- #endif
844
853
  #if HAVE_CURL_SSLVERSION_TLSv1
845
854
  CURB_DEFINE(CURL_SSLVERSION_TLSv1);
846
855
  #endif
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.7.16"
24
- #define CURB_VER_NUM 716
23
+ #define CURB_VERSION "0.7.17"
24
+ #define CURB_VER_NUM 717
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 7
27
27
  #define CURB_VER_MIC 1
28
- #define CURB_VER_PATCH 6
28
+ #define CURB_VER_PATCH 7
29
29
 
30
30
 
31
31
  // Maybe not yet defined in Ruby
data/ext/curb_easy.c CHANGED
@@ -54,7 +54,7 @@ static size_t read_data_handler(void *ptr,
54
54
  /* copy read_bytes from stream into ptr */
55
55
  VALUE str = rb_funcall(stream, rb_intern("read"), 1, rb_int_new(read_bytes) );
56
56
  if( str != Qnil ) {
57
- memcpy(ptr, RSTRING_PTR(str), RSTRING_LEN(str));
57
+ memcpy(ptr, StringValueCStr(str), RSTRING_LEN(str));
58
58
  return RSTRING_LEN(str);
59
59
  }
60
60
  else {
@@ -71,7 +71,7 @@ static size_t read_data_handler(void *ptr,
71
71
  str = rb_funcall(stream, rb_intern("to_s"), 0);
72
72
  len = RSTRING_LEN(str);
73
73
  remaining = len - rbcu->offset;
74
- str_ptr = RSTRING_PTR(str);
74
+ str_ptr = StringValueCStr(str);
75
75
 
76
76
  if( remaining < read_bytes ) {
77
77
  if( remaining > 0 ) {
@@ -157,11 +157,13 @@ static int proc_debug_handler(CURL *curl,
157
157
  char *data,
158
158
  size_t data_len,
159
159
  VALUE proc) {
160
+ VALUE procret;
160
161
  VALUE callargs = rb_ary_new2(3);
161
162
  rb_ary_store(callargs, 0, proc);
162
163
  rb_ary_store(callargs, 1, INT2FIX(type));
163
164
  rb_ary_store(callargs, 2, rb_str_new(data, data_len));
164
165
  rb_rescue(call_debug_handler, callargs, callback_exception, Qnil);
166
+ // XXX: no way to indicate to libcurl that we should break out given an exception in the on_debug handler... this means exceptions will be swallowed
165
167
  //rb_funcall(proc, idCall, 2, INT2FIX(type), rb_str_new(data, data_len));
166
168
  return 0;
167
169
  }
@@ -222,7 +224,7 @@ static void ruby_curl_easy_zero(ruby_curl_easy *rbce) {
222
224
  rbce->proxy_tunnel = 0;
223
225
  rbce->fetch_file_time = 0;
224
226
  rbce->ssl_verify_peer = 1;
225
- rbce->ssl_verify_host = 1;
227
+ rbce->ssl_verify_host = 2;
226
228
  rbce->header_in_body = 0;
227
229
  rbce->use_netrc = 0;
228
230
  rbce->follow_location = 0;
@@ -1957,12 +1959,12 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
1957
1959
  curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, rbce->proxy_tunnel);
1958
1960
  curl_easy_setopt(curl, CURLOPT_FILETIME, rbce->fetch_file_time);
1959
1961
  curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, rbce->ssl_verify_peer);
1960
- curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, rbce->ssl_verify_peer);
1962
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, rbce->ssl_verify_host);
1961
1963
 
1962
1964
  if ((rbce->use_netrc != Qnil) && (rbce->use_netrc != Qfalse)) {
1963
- curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, CURL_NETRC_OPTIONAL);
1965
+ curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
1964
1966
  } else {
1965
- curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, CURL_NETRC_IGNORED);
1967
+ curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_IGNORED);
1966
1968
  }
1967
1969
 
1968
1970
  curl_easy_setopt(curl, CURLOPT_UNRESTRICTED_AUTH, rbce->unrestricted_auth);
@@ -2233,11 +2235,11 @@ static VALUE ruby_curl_easy_perform_delete(VALUE self) {
2233
2235
  static VALUE ruby_curl_easy_perform_verb(VALUE self, VALUE verb) {
2234
2236
  VALUE str_verb;
2235
2237
  if (rb_type(verb) == T_STRING) {
2236
- return ruby_curl_easy_perform_verb_str(self, RSTRING_PTR(verb));
2238
+ return ruby_curl_easy_perform_verb_str(self, StringValueCStr(verb));
2237
2239
  }
2238
2240
  else if (rb_respond_to(verb,rb_intern("to_s"))) {
2239
2241
  str_verb = rb_funcall(verb, rb_intern("to_s"), 0);
2240
- return ruby_curl_easy_perform_verb_str(self, RSTRING_PTR(str_verb));
2242
+ return ruby_curl_easy_perform_verb_str(self, StringValueCStr(str_verb));
2241
2243
  }
2242
2244
  else {
2243
2245
  rb_raise(rb_eRuntimeError, "Invalid HTTP VERB, must response to 'to_s'");
@@ -3106,7 +3108,7 @@ static VALUE ruby_curl_easy_inspect(VALUE self) {
3106
3108
  size_t len = 13+((RSTRING_LEN(url) > 50) ? 50 : RSTRING_LEN(url));
3107
3109
  /* "#<Net::HTTP http://www.google.com/:80 open=false>" */
3108
3110
  memcpy(buf,"#<Curl::Easy ", 13);
3109
- memcpy(buf+13,RSTRING_PTR(url), (len - 13));
3111
+ memcpy(buf+13,StringValueCStr(url), (len - 13));
3110
3112
  buf[len++] = '>';
3111
3113
  return rb_str_new(buf,len);
3112
3114
  }
data/ext/curb_multi.c CHANGED
@@ -332,7 +332,7 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
332
332
  long response_code = -1;
333
333
  VALUE easy;
334
334
  ruby_curl_easy *rbce = NULL;
335
- VALUE callargs;
335
+ VALUE callargs, val = Qtrue;
336
336
 
337
337
  CURLcode ecode = curl_easy_getinfo(easy_handle, CURLINFO_PRIVATE, (char**)&easy);
338
338
 
@@ -354,7 +354,7 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
354
354
 
355
355
  if (!rb_easy_nil("complete_proc")) {
356
356
  callargs = rb_ary_new3(2, rb_easy_get("complete_proc"), easy);
357
- rb_rescue(call_status_handler1, callargs, callback_exception, Qnil);
357
+ val = rb_rescue(call_status_handler1, callargs, callback_exception, Qnil);
358
358
  //rb_funcall( rb_easy_get("complete_proc"), idCall, 1, easy );
359
359
  }
360
360
 
@@ -363,7 +363,7 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
363
363
  if (result != 0) {
364
364
  if (!rb_easy_nil("failure_proc")) {
365
365
  callargs = rb_ary_new3(3, rb_easy_get("failure_proc"), easy, rb_curl_easy_error(result));
366
- rb_rescue(call_status_handler2, callargs, callback_exception, Qnil);
366
+ val = rb_rescue(call_status_handler2, callargs, callback_exception, Qnil);
367
367
  //rb_funcall( rb_easy_get("failure_proc"), idCall, 2, easy, rb_curl_easy_error(result) );
368
368
  }
369
369
  }
@@ -371,16 +371,22 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
371
371
  ((response_code >= 200 && response_code < 300) || response_code == 0)) {
372
372
  /* NOTE: we allow response_code == 0, in the case of non http requests e.g. reading from disk */
373
373
  callargs = rb_ary_new3(2, rb_easy_get("success_proc"), easy);
374
- rb_rescue(call_status_handler1, callargs, callback_exception, Qnil);
374
+ val = rb_rescue(call_status_handler1, callargs, callback_exception, Qnil);
375
375
  //rb_funcall( rb_easy_get("success_proc"), idCall, 1, easy );
376
376
  }
377
377
  else if (!rb_easy_nil("failure_proc") &&
378
378
  (response_code >= 300 && response_code <= 999)) {
379
379
  callargs = rb_ary_new3(3, rb_easy_get("failure_proc"), easy, rb_curl_easy_error(result));
380
- rb_rescue(call_status_handler2, callargs, callback_exception, Qnil);
380
+ val = rb_rescue(call_status_handler2, callargs, callback_exception, Qnil);
381
381
  //rb_funcall( rb_easy_get("failure_proc"), idCall, 2, easy, rb_curl_easy_error(result) );
382
382
  }
383
383
 
384
+ if (val == Qfalse) {
385
+ rb_warn("uncaught exception from callback");
386
+ // exception was raised?
387
+ //fprintf(stderr, "exception raised from callback\n");
388
+ }
389
+
384
390
  }
385
391
 
386
392
  static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) {
@@ -443,6 +449,20 @@ void cleanup_crt_fd(fd_set *os_set, fd_set *crt_set)
443
449
  }
444
450
  #endif
445
451
 
452
+ #ifdef HAVE_RB_THREAD_BLOCKING_REGION
453
+ struct _select_set {
454
+ int maxfd;
455
+ fd_set *fdread, *fdwrite, *fdexcep;
456
+ struct timeval *tv;
457
+ };
458
+
459
+ static VALUE curb_select(void *args) {
460
+ struct _select_set* set = args;
461
+ int rc = select(set->maxfd, set->fdread, set->fdwrite, set->fdexcep, set->tv);
462
+ return INT2FIX(rc);
463
+ }
464
+ #endif
465
+
446
466
  /*
447
467
  * call-seq:
448
468
  * multi = Curl::Multi.new
@@ -466,10 +486,12 @@ VALUE ruby_curl_multi_perform(int argc, VALUE *argv, VALUE self) {
466
486
  #ifdef _WIN32
467
487
  fd_set crt_fdread, crt_fdwrite, crt_fdexcep;
468
488
  #endif
469
-
470
489
  long timeout_milliseconds;
471
490
  struct timeval tv = {0, 0};
472
491
  VALUE block = Qnil;
492
+ #ifdef HAVE_RB_THREAD_BLOCKING_REGION
493
+ struct _select_set fdset_args;
494
+ #endif
473
495
 
474
496
  rb_scan_args(argc, argv, "0&", &block);
475
497
 
@@ -526,7 +548,16 @@ VALUE ruby_curl_multi_perform(int argc, VALUE *argv, VALUE self) {
526
548
  create_crt_fd(&fdexcep, &crt_fdexcep);
527
549
  #endif
528
550
 
551
+ #ifdef HAVE_RB_THREAD_BLOCKING_REGION
552
+ fdset_args.maxfd = maxfd+1;
553
+ fdset_args.fdread = &fdread;
554
+ fdset_args.fdwrite = &fdwrite;
555
+ fdset_args.fdexcep = &fdexcep;
556
+ fdset_args.tv = &tv;
557
+ rc = rb_thread_blocking_region(curb_select, &fdset_args, RUBY_UBF_IO, 0);
558
+ #else
529
559
  rc = rb_thread_select(maxfd+1, &fdread, &fdwrite, &fdexcep, &tv);
560
+ #endif
530
561
 
531
562
  #ifdef _WIN32
532
563
  cleanup_crt_fd(&fdread, &crt_fdread);
data/ext/extconf.rb CHANGED
@@ -101,6 +101,13 @@ have_constant "curle_login_denied"
101
101
  # older than 7.16.3
102
102
  have_constant "curlmopt_maxconnects"
103
103
 
104
+ have_constant "curlopt_seekfunction"
105
+ have_constant "curlopt_seekdata"
106
+ have_constant "curlopt_sockoptfunction"
107
+ have_constant "curlopt_sockoptdata"
108
+ have_constant "curlopt_opensocketfunction"
109
+ have_constant "curlopt_opensocketdata"
110
+
104
111
  # additional consts
105
112
  have_constant "curle_conv_failed"
106
113
  have_constant "curle_conv_reqd"
@@ -381,5 +388,7 @@ test_for("curl_easy_escape", "CURL_EASY_ESCAPE", %{
381
388
  }
382
389
  })
383
390
 
391
+ have_func('rb_thread_blocking_region')
392
+
384
393
  create_header('curb_config.h')
385
394
  create_makefile('curb_core')
@@ -20,14 +20,14 @@ class BugCrashOnDebug < Test::Unit::TestCase
20
20
  c.on_progress do|x|
21
21
  raise "error"
22
22
  end
23
- c.easy.on_debug { |type, data| puts "debug: #{type.inspect}, #{data.inspect}" }
24
23
  c.perform
25
24
 
25
+ assert false, "should not reach this point"
26
+
26
27
  rescue => e
27
28
  assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
28
29
  c.close
29
30
  ensure
30
- puts "shutdown server"
31
31
  server.shutdown
32
32
  end
33
33
  end
@@ -918,24 +918,31 @@ class TestCurbCurlEasy < Test::Unit::TestCase
918
918
  assert_equal multi, easy.multi
919
919
  end
920
920
 
921
- def test_handle_exceptions_in_progress_callbacks
921
+ def test_raise_on_progress
922
922
  c = Curl::Easy.new($TEST_URL)
923
- c.on_progress {|x| raise "error" }
923
+ c.on_progress {|w,x,y,z| raise "error" }
924
924
  c.perform
925
925
  rescue => e
926
926
  assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
927
927
  c.close
928
928
  end
929
929
 
930
- def test_handle_exceptions_in_debug_callbacks
930
+ def test_raise_on_success
931
931
  c = Curl::Easy.new($TEST_URL)
932
- c.on_debug {|x| raise "error" }
932
+ c.on_success {|x| raise "error" }
933
933
  c.perform
934
934
  rescue => e
935
935
  assert_equal 'Curl::Err::AbortedByCallbackError', e.class.to_s
936
936
  c.close
937
937
  end
938
938
 
939
+ def test_raise_on_debug
940
+ c = Curl::Easy.new($TEST_URL)
941
+ c.on_debug { raise "error" }
942
+ c.perform
943
+ assert true, "raise in on debug has no effect"
944
+ end
945
+
939
946
  include TestServerMethods
940
947
 
941
948
  def setup
metadata CHANGED
@@ -1,28 +1,35 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: curb
3
- version: !ruby/object:Gem::Version
4
- version: 0.7.16
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 33
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 17
10
+ version: 0.7.17
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Ross Bamford
9
14
  - Todd A. Fisher
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2011-11-03 00:00:00.000000000 Z
18
+
19
+ date: 2012-01-09 00:00:00 -05:00
20
+ default_executable:
14
21
  dependencies: []
15
- description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings
16
- for the libcurl(3), a fully-featured client-side URL transfer library. cURL and
17
- libcurl live at http://curl.haxx.se/
22
+
23
+ description: Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the libcurl(3), a fully-featured client-side URL transfer library. cURL and libcurl live at http://curl.haxx.se/
18
24
  email: todd.fisher@gmail.com
19
25
  executables: []
20
- extensions:
26
+
27
+ extensions:
21
28
  - ext/extconf.rb
22
- extra_rdoc_files:
29
+ extra_rdoc_files:
23
30
  - LICENSE
24
31
  - README
25
- files:
32
+ files:
26
33
  - LICENSE
27
34
  - README
28
35
  - Rakefile
@@ -46,7 +53,7 @@ files:
46
53
  - ext/curb_postfield.h
47
54
  - ext/curb_upload.h
48
55
  - tests/alltests.rb
49
- - tests/bug_crash_on_debug.rb
56
+ - tests/bug_crash_on_progress.rb
50
57
  - tests/bug_curb_easy_blocks_ruby_threads.rb
51
58
  - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
52
59
  - tests/bug_instance_post_differs_from_class_post.rb
@@ -66,36 +73,45 @@ files:
66
73
  - tests/timeout.rb
67
74
  - tests/timeout_server.rb
68
75
  - tests/unittests.rb
76
+ has_rdoc: true
69
77
  homepage: http://curb.rubyforge.org/
70
78
  licenses: []
79
+
71
80
  post_install_message:
72
- rdoc_options:
81
+ rdoc_options:
73
82
  - --main
74
83
  - README
75
- require_paths:
84
+ require_paths:
76
85
  - lib
77
86
  - ext
78
- required_ruby_version: !ruby/object:Gem::Requirement
87
+ required_ruby_version: !ruby/object:Gem::Requirement
79
88
  none: false
80
- requirements:
81
- - - ! '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
- required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
97
  none: false
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
90
105
  requirements: []
106
+
91
107
  rubyforge_project: curb
92
- rubygems_version: 1.8.10
108
+ rubygems_version: 1.3.7
93
109
  signing_key:
94
110
  specification_version: 3
95
111
  summary: Ruby libcurl bindings
96
- test_files:
112
+ test_files:
97
113
  - tests/alltests.rb
98
- - tests/bug_crash_on_debug.rb
114
+ - tests/bug_crash_on_progress.rb
99
115
  - tests/bug_curb_easy_blocks_ruby_threads.rb
100
116
  - tests/bug_curb_easy_post_with_string_no_content_length_header.rb
101
117
  - tests/bug_instance_post_differs_from_class_post.rb