curb 0.4.2.0 → 0.4.4.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
@@ -4,12 +4,6 @@ require 'rake/clean'
4
4
  require 'rake/testtask'
5
5
  require 'rake/rdoctask'
6
6
 
7
- #begin
8
- # require 'rake/gempackagetask'
9
- #rescue LoadError
10
- # $stderr.puts("Rubygems support disabled")
11
- #end
12
-
13
7
  CLEAN.include '**/*.o'
14
8
  CLEAN.include "**/*.#{Config::MAKEFILE_CONFIG['DLEXT']}"
15
9
  CLOBBER.include 'doc'
data/ext/curb.c CHANGED
@@ -278,7 +278,7 @@ void Init_curb_core() {
278
278
  #ifdef HAVE_CURLAUTH_BASIC
279
279
  rb_define_const(mCurl, "CURLAUTH_BASIC", INT2FIX(CURLAUTH_BASIC));
280
280
  #else
281
- rb_define_const(mCurl, "CURLAUTH_BASIC", INT2FIX(0);
281
+ rb_define_const(mCurl, "CURLAUTH_BASIC", INT2FIX(0));
282
282
  #endif
283
283
 
284
284
  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use Digest authentication. */
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.4.2"
24
- #define CURB_VER_NUM 420
23
+ #define CURB_VERSION "0.4.4"
24
+ #define CURB_VER_NUM 440
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 4
27
- #define CURB_VER_MIC 2
27
+ #define CURB_VER_MIC 4
28
28
  #define CURB_VER_PATCH 0
29
29
 
30
30
 
@@ -170,7 +170,11 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
170
170
  rb_gc_mark(rbce->cookiefile);
171
171
  rb_gc_mark(rbce->cookiejar);
172
172
  rb_gc_mark(rbce->cert);
173
+ rb_gc_mark(rbce->cacert);
174
+ rb_gc_mark(rbce->certpassword);
175
+ rb_gc_mark(rbce->certtype);
173
176
  rb_gc_mark(rbce->encoding);
177
+ rb_gc_mark(rbce->useragent);
174
178
  rb_gc_mark(rbce->success_proc);
175
179
  rb_gc_mark(rbce->failure_proc);
176
180
  rb_gc_mark(rbce->complete_proc);
@@ -238,7 +242,11 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
238
242
  rbce->cookiefile = Qnil;
239
243
  rbce->cookiejar = Qnil;
240
244
  rbce->cert = Qnil;
245
+ rbce->cacert = Qnil;
246
+ rbce->certpassword = Qnil;
247
+ rbce->certtype = rb_str_new2("PEM");
241
248
  rbce->encoding = Qnil;
249
+ rbce->useragent = Qnil;
242
250
  rbce->success_proc = Qnil;
243
251
  rbce->failure_proc = Qnil;
244
252
  rbce->complete_proc = Qnil;
@@ -574,6 +582,60 @@ static VALUE ruby_curl_easy_cert_get(VALUE self) {
574
582
  CURB_OBJECT_GETTER(ruby_curl_easy, cert);
575
583
  }
576
584
 
585
+ /*
586
+ * call-seq:
587
+ * easy.cacert = "cacert.file" => ""
588
+ *
589
+ * Set a cacert bundle to use for this Curl::Easy instance. This file
590
+ * will be used to validate SSL certificates.
591
+ *
592
+ */
593
+ static VALUE ruby_curl_easy_cacert_set(VALUE self, VALUE cacert) {
594
+ CURB_OBJECT_SETTER(ruby_curl_easy, cacert);
595
+ }
596
+
597
+ /*
598
+ * call-seq:
599
+ * easy.cacert => "cacert.file"
600
+ *
601
+ * Obtain the cacert file to use for this Curl::Easy instance.
602
+ */
603
+ static VALUE ruby_curl_easy_cacert_get(VALUE self) {
604
+ CURB_OBJECT_GETTER(ruby_curl_easy, cacert);
605
+ }
606
+
607
+ /*
608
+ * call-seq:
609
+ * easy.certpassword = "cert password" => ""
610
+ *
611
+ * Set a password used to open the specified cert
612
+ */
613
+ static VALUE ruby_curl_easy_certpassword_set(VALUE self, VALUE certpassword) {
614
+ CURB_OBJECT_SETTER(ruby_curl_easy, certpassword);
615
+ }
616
+
617
+ /*
618
+ * call-seq:
619
+ * easy.certtype = "PEM|DER" => ""
620
+ *
621
+ * Set a cert type to use for this Curl::Easy instance.
622
+ * Default is PEM
623
+ *
624
+ */
625
+ static VALUE ruby_curl_easy_certtype_set(VALUE self, VALUE certtype) {
626
+ CURB_OBJECT_SETTER(ruby_curl_easy, certtype);
627
+ }
628
+
629
+ /*
630
+ * call-seq:
631
+ * easy.certtype => "cert.type"
632
+ *
633
+ * Obtain the cert type used for this Curl::Easy instance
634
+ */
635
+ static VALUE ruby_curl_easy_certtype_get(VALUE self) {
636
+ CURB_OBJECT_GETTER(ruby_curl_easy, certtype);
637
+ }
638
+
577
639
  /*
578
640
  * call-seq:
579
641
  * easy.encoding= => "string"
@@ -595,6 +657,79 @@ static VALUE ruby_curl_easy_encoding_get(VALUE self) {
595
657
  CURB_OBJECT_GETTER(ruby_curl_easy, encoding);
596
658
  }
597
659
 
660
+ /*
661
+ * call-seq:
662
+ * easy.useragent = "Ruby/Curb" => ""
663
+ *
664
+ * Set the user agent string for this Curl::Easy instance
665
+ *
666
+ */
667
+ static VALUE ruby_curl_easy_useragent_set(VALUE self, VALUE useragent) {
668
+ CURB_OBJECT_SETTER(ruby_curl_easy, useragent);
669
+ }
670
+
671
+ /*
672
+ * call-seq:
673
+ * easy.useragent => "Ruby/Curb"
674
+ *
675
+ * Obtain the user agent string used for this Curl::Easy instance
676
+ */
677
+ static VALUE ruby_curl_easy_useragent_get(VALUE self) {
678
+ CURB_OBJECT_GETTER(ruby_curl_easy, useragent);
679
+ }
680
+
681
+ /*
682
+ * call-seq:
683
+ * easy.post_body = "some=form%20data&to=send" => string or nil
684
+ *
685
+ * Sets the POST body of this Curl::Easy instance. This is expected to be
686
+ * URL encoded; no additional processing or encoding is done on the string.
687
+ * The content-type header will be set to application/x-www-form-urlencoded.
688
+ *
689
+ * This is handy if you want to perform a POST against a Curl::Multi instance.
690
+ */
691
+ static VALUE ruby_curl_easy_post_body_set(VALUE self, VALUE post_body) {
692
+ ruby_curl_easy *rbce;
693
+ CURL *curl;
694
+
695
+ char *data;
696
+ long len;
697
+
698
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
699
+
700
+ curl = rbce->curl;
701
+
702
+ if ( post_body == Qnil ) {
703
+ rbce->postdata_buffer = Qnil;
704
+
705
+ } else {
706
+ data = StringValuePtr(post_body);
707
+ len = RSTRING_LEN(post_body);
708
+
709
+ // Store the string, since it has to hang around for the duration of the
710
+ // request. See CURLOPT_POSTFIELDS in the libcurl docs.
711
+ rbce->postdata_buffer = post_body;
712
+
713
+ curl_easy_setopt(curl, CURLOPT_POST, 1);
714
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
715
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, len);
716
+
717
+ return post_body;
718
+ }
719
+
720
+ return Qnil;
721
+ }
722
+
723
+ /*
724
+ * call-seq:
725
+ * easy.post_body => "string" or nil
726
+ *
727
+ * Obtain the POST body used in this Curl::Easy instance.
728
+ */
729
+ static VALUE ruby_curl_easy_post_body_get(VALUE self) {
730
+ CURB_OBJECT_GETTER(ruby_curl_easy, postdata_buffer);
731
+ }
732
+
598
733
  /* ================== IMMED ATTRS ==================*/
599
734
 
600
735
  /*
@@ -1488,9 +1623,22 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1488
1623
 
1489
1624
  /* Set up HTTPS cert handling if necessary */
1490
1625
  if (rbce->cert != Qnil) {
1626
+ curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, StringValuePtr(rbce->certtype));
1491
1627
  curl_easy_setopt(curl, CURLOPT_SSLCERT, StringValuePtr(rbce->cert));
1628
+ if (rbce->certpassword != Qnil) {
1629
+ curl_easy_setopt(curl, CURLOPT_SSLCERTPASSWD, StringValuePtr(rbce->certpassword));
1630
+ }
1631
+ }
1632
+ if (rbce->cacert != Qnil) {
1633
+ // XXX: This should really be using the output of 'curl-config --ca'
1492
1634
  curl_easy_setopt(curl, CURLOPT_CAINFO, "/usr/local/share/curl/curl-ca-bundle.crt");
1493
1635
  }
1636
+
1637
+ /* Set the user-agent string if specified */
1638
+ if (rbce->useragent != Qnil) {
1639
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, StringValuePtr(rbce->useragent));
1640
+ }
1641
+
1494
1642
 
1495
1643
  /* Setup HTTP headers if necessary */
1496
1644
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL); // XXX: maybe we shouldn't be clearing this?
@@ -1693,7 +1841,7 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1693
1841
  if (result != 0) {
1694
1842
  // printf("error: %s\n", errors);
1695
1843
  if (rbce->failure_proc != Qnil) {
1696
- rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, INT2FIX(result) );
1844
+ rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, rb_curl_easy_error(result) );
1697
1845
  } else {
1698
1846
  raise_curl_easy_error_exception(result);
1699
1847
  }
@@ -1705,7 +1853,7 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1705
1853
  }
1706
1854
  else if (rbce->failure_proc != Qnil &&
1707
1855
  (response_code >= 300 && response_code <= 999)) {
1708
- rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, INT2FIX(result) );
1856
+ rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, rb_curl_easy_error(result) );
1709
1857
  }
1710
1858
 
1711
1859
  return Qtrue;
@@ -1829,19 +1977,12 @@ static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
1829
1977
 
1830
1978
  return ret;
1831
1979
  } else {
1832
- long len;
1833
- char *data;
1834
-
1835
- if ((rbce->postdata_buffer = rb_funcall(args_ary, idJoin, 1, rbstrAmp)) == Qnil) {
1980
+ VALUE post_body;
1981
+ if ((post_body = rb_funcall(args_ary, idJoin, 1, rbstrAmp)) == Qnil) {
1836
1982
  rb_raise(eCurlErrError, "Failed to join arguments");
1837
1983
  return Qnil;
1838
1984
  } else {
1839
- data = StringValuePtr(rbce->postdata_buffer);
1840
- len = RSTRING_LEN(rbce->postdata_buffer);
1841
-
1842
- curl_easy_setopt(curl, CURLOPT_POST, 1);
1843
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
1844
- curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, len);
1985
+ ruby_curl_easy_post_body_set(self, post_body);
1845
1986
 
1846
1987
  return handle_perform(self,rbce);
1847
1988
  }
@@ -2742,8 +2883,17 @@ void init_curb_easy() {
2742
2883
  rb_define_method(cCurlEasy, "cookiejar", ruby_curl_easy_cookiejar_get, 0);
2743
2884
  rb_define_method(cCurlEasy, "cert=", ruby_curl_easy_cert_set, 1);
2744
2885
  rb_define_method(cCurlEasy, "cert", ruby_curl_easy_cert_get, 0);
2886
+ rb_define_method(cCurlEasy, "cacert=", ruby_curl_easy_cacert_set, 1);
2887
+ rb_define_method(cCurlEasy, "cacert", ruby_curl_easy_cacert_get, 0);
2888
+ rb_define_method(cCurlEasy, "certpassword=", ruby_curl_easy_certpassword_set, 1);
2889
+ rb_define_method(cCurlEasy, "certtype=", ruby_curl_easy_certtype_set, 1);
2890
+ rb_define_method(cCurlEasy, "certtype", ruby_curl_easy_certtype_get, 0);
2745
2891
  rb_define_method(cCurlEasy, "encoding=", ruby_curl_easy_encoding_set, 1);
2746
2892
  rb_define_method(cCurlEasy, "encoding", ruby_curl_easy_encoding_get, 0);
2893
+ rb_define_method(cCurlEasy, "useragent=", ruby_curl_easy_useragent_set, 1);
2894
+ rb_define_method(cCurlEasy, "useragent", ruby_curl_easy_useragent_get, 0);
2895
+ rb_define_method(cCurlEasy, "post_body=", ruby_curl_easy_post_body_set, 1);
2896
+ rb_define_method(cCurlEasy, "post_body", ruby_curl_easy_post_body_get, 0);
2747
2897
 
2748
2898
  rb_define_method(cCurlEasy, "local_port=", ruby_curl_easy_local_port_set, 1);
2749
2899
  rb_define_method(cCurlEasy, "local_port", ruby_curl_easy_local_port_get, 0);
@@ -36,7 +36,11 @@ typedef struct {
36
36
  VALUE cookiefile; /* filename */
37
37
  VALUE cookiejar; /* filename */
38
38
  VALUE cert;
39
+ VALUE cacert;
40
+ VALUE certpassword;
41
+ VALUE certtype;
39
42
  VALUE encoding;
43
+ VALUE useragent;
40
44
 
41
45
  VALUE success_proc;
42
46
  VALUE failure_proc;
@@ -121,8 +121,7 @@ VALUE mCurlErrUnknownOption;
121
121
  VALUE eCurlErrInvalidPostField;
122
122
 
123
123
 
124
- /* rb_raise an approriate exception for the supplied CURLcode */
125
- void raise_curl_easy_error_exception(CURLcode code) {
124
+ VALUE rb_curl_easy_error(CURLcode code) {
126
125
  VALUE exclz;
127
126
  const char *exmsg = NULL;
128
127
 
@@ -437,9 +436,17 @@ void raise_curl_easy_error_exception(CURLcode code) {
437
436
  exmsg = curl_easy_strerror(code);
438
437
  }
439
438
 
440
- rb_raise(exclz, exmsg);
439
+ VALUE results = rb_ary_new2(2);
440
+ rb_ary_push(results, exclz);
441
+ rb_ary_push(results, rb_str_new2(exmsg));
442
+ return results;
441
443
  }
442
- void raise_curl_multi_error_exception(CURLMcode code) {
444
+ /* rb_raise an approriate exception for the supplied CURLcode */
445
+ void raise_curl_easy_error_exception(CURLcode code) {
446
+ VALUE obj = rb_curl_easy_error(code);
447
+ rb_raise(rb_ary_entry(obj,0), RSTRING_PTR(rb_ary_entry(obj,1)));
448
+ }
449
+ VALUE rb_curl_multi_error(CURLMcode code) {
443
450
  VALUE exclz;
444
451
  const char *exmsg = NULL;
445
452
 
@@ -478,7 +485,14 @@ void raise_curl_multi_error_exception(CURLMcode code) {
478
485
  exmsg = curl_multi_strerror(code);
479
486
  }
480
487
 
481
- rb_raise(exclz, exmsg);
488
+ VALUE results = rb_ary_new2(2);
489
+ rb_ary_push(results, exclz);
490
+ rb_ary_push(results, rb_str_new2(exmsg));
491
+ return results;
492
+ }
493
+ void raise_curl_multi_error_exception(CURLMcode code) {
494
+ VALUE obj = rb_curl_multi_error(code);
495
+ rb_raise(rb_ary_entry(obj,0), RSTRING_PTR(rb_ary_entry(obj,1)));
482
496
  }
483
497
 
484
498
  void init_curb_errors() {
@@ -122,5 +122,7 @@ extern VALUE eCurlErrInvalidPostField;
122
122
  void init_curb_errors();
123
123
  void raise_curl_easy_error_exception(CURLcode code);
124
124
  void raise_curl_multi_error_exception(CURLMcode code);
125
+ VALUE rb_curl_easy_error(CURLcode code);
126
+ VALUE rb_curl_multi_error(CURLMcode code);
125
127
 
126
128
  #endif
@@ -1,8 +1,7 @@
1
- /* curb_easy.c - Curl easy mode
1
+ /* curb_multi.c - Curl multi mode
2
2
  * Copyright (c)2008 Todd A. Fisher.
3
3
  * Licensed under the Ruby License. See LICENSE for details.
4
4
  *
5
- * $Id$
6
5
  */
7
6
 
8
7
  #include "curb_config.h"
@@ -58,14 +57,16 @@ static void curl_multi_flush_easy(VALUE key, VALUE easy, ruby_curl_multi *rbcm)
58
57
  }
59
58
 
60
59
  static void curl_multi_free(ruby_curl_multi *rbcm) {
60
+
61
61
  //printf("hash entries: %d\n", RHASH(rbcm->requests)->tbl->num_entries );
62
- if (rbcm && RHASH_LEN(rbcm->requests) > 0) {
62
+ if (rbcm && !rbcm->requests == Qnil && rb_type(rbcm->requests) == T_HASH && RHASH_LEN(rbcm->requests) > 0) {
63
+
63
64
  rb_hash_foreach( rbcm->requests, (int (*)())curl_multi_flush_easy, (VALUE)rbcm );
64
65
 
65
- curl_multi_cleanup(rbcm->handle);
66
66
  //rb_hash_clear(rbcm->requests)
67
67
  rbcm->requests = Qnil;
68
68
  }
69
+ curl_multi_cleanup(rbcm->handle);
69
70
  free(rbcm);
70
71
  }
71
72
 
@@ -257,7 +258,7 @@ static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) {
257
258
 
258
259
  if (result != 0) {
259
260
  if (rbce->failure_proc != Qnil) {
260
- rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, INT2FIX(result) );
261
+ rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, rb_curl_easy_error(result) );
261
262
  }
262
263
  }
263
264
  else if (rbce->success_proc != Qnil &&
@@ -267,7 +268,7 @@ static void rb_curl_multi_read_info(VALUE self, CURLM *multi_handle) {
267
268
  }
268
269
  else if (rbce->failure_proc != Qnil &&
269
270
  (response_code >= 300 && response_code <= 999)) {
270
- rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, INT2FIX(result) );
271
+ rb_funcall( rbce->failure_proc, idCall, 2, rbce->self, rb_curl_easy_error(result) );
271
272
  }
272
273
  rbce->self = Qnil;
273
274
  }
@@ -38,6 +38,21 @@ module Curl
38
38
  return curl
39
39
  end
40
40
  end
41
+
42
+ # Allow the incoming cert string to be file:password
43
+ # but be careful to not use a colon from a windows file path
44
+ # as the split point. Mimic what curl's main does
45
+ alias_method :native_cert=, :cert=
46
+ def cert=(cert_file)
47
+ pos = cert_file.rindex(':')
48
+ if pos && pos > 1
49
+ self.native_cert= cert_file[0..pos-1]
50
+ self.certpassword= cert_file[pos+1..-1]
51
+ else
52
+ self.native_cert= cert_file
53
+ end
54
+ self.cert
55
+ end
41
56
  end
42
57
  class Multi
43
58
  class << self
@@ -72,7 +72,7 @@ class TestServlet < WEBrick::HTTPServlet::AbstractServlet
72
72
  end
73
73
 
74
74
  def do_POST(req,res)
75
- respond_with(:POST,req,res)
75
+ respond_with("POST\n#{req.body}",req,res)
76
76
  end
77
77
 
78
78
  def do_PUT(req,res)
@@ -4,11 +4,11 @@ class TestCurbCurlDownload < Test::Unit::TestCase
4
4
  include TestServerMethods
5
5
 
6
6
  def setup
7
- server_setup(9130)
7
+ server_setup
8
8
  end
9
9
 
10
10
  def test_download_url_to_file
11
- dl_url = "http://127.0.0.1:9130/ext/curb_easy.c"
11
+ dl_url = "http://127.0.0.1:9129/ext/curb_easy.c"
12
12
  dl_path = File.join("/tmp/dl_url_test.file")
13
13
 
14
14
  curb = Curl::Easy.download(dl_url, dl_path)
@@ -19,7 +19,7 @@ class TestCurbCurlDownload < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  def test_download_bad_url_gives_404
22
- dl_url = "http://127.0.0.1:9130/this_file_does_not_exist.html"
22
+ dl_url = "http://127.0.0.1:9129/this_file_does_not_exist.html"
23
23
  dl_path = File.join("/tmp/dl_url_test.file")
24
24
 
25
25
  curb = Curl::Easy.download(dl_url, dl_path)
@@ -497,7 +497,25 @@ class TestCurbCurlEasy < Test::Unit::TestCase
497
497
  def test_post_remote
498
498
  curl = Curl::Easy.new(TestServlet.url)
499
499
  curl.http_post
500
- assert_equal 'POST', curl.body_str
500
+ assert_equal "POST\n", curl.body_str
501
+ end
502
+
503
+ def test_post_with_body_remote
504
+ curl = Curl::Easy.new(TestServlet.url)
505
+ curl.post_body = 'foo=bar&encoded%20string=val'
506
+
507
+ curl.perform
508
+
509
+ assert_equal "POST\nfoo=bar&encoded%20string=val", curl.body_str
510
+ assert_equal 'foo=bar&encoded%20string=val', curl.post_body
511
+ end
512
+
513
+ def test_form_post_body_remote
514
+ curl = Curl::Easy.new(TestServlet.url)
515
+ curl.http_post('foo=bar', 'encoded%20string=val')
516
+
517
+ assert_equal "POST\nfoo=bar&encoded%20string=val", curl.body_str
518
+ assert_equal 'foo=bar&encoded%20string=val', curl.post_body
501
519
  end
502
520
 
503
521
  def test_delete_remote
@@ -547,6 +565,46 @@ class TestCurbCurlEasy < Test::Unit::TestCase
547
565
  assert_equal "PUT\n#{File.read(__FILE__)}", curl.body_str
548
566
  end
549
567
 
568
+ # Generate a self-signed cert with
569
+ # openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 \
570
+ # -keyout tests/cert.pem -out tests/cert.pem
571
+ def test_cert
572
+ curl = Curl::Easy.new(TestServlet.url)
573
+ curl.cert= File.join(File.dirname(__FILE__),"cert.pem")
574
+ assert /cert.pem$/,curl.cert
575
+ end
576
+
577
+ def test_cert_with_password
578
+ curl = Curl::Easy.new(TestServlet.url)
579
+ curl.cert= File.join(File.dirname(__FILE__),"cert.pem:password")
580
+ assert /cert.pem$/,curl.cert
581
+ end
582
+
583
+ def test_cert_type
584
+ curl = Curl::Easy.new(TestServlet.url)
585
+ curl.certtype= "DER"
586
+ assert "DER", curl.certtype
587
+ end
588
+
589
+ def test_default_certtype
590
+ curl = Curl::Easy.new(TestServlet.url)
591
+ assert "PEM", curl.certtype
592
+ end
593
+
594
+ # Generate a CA cert with instructions at
595
+ # http://technocage.com/~caskey/openssl/
596
+ def test_ca_cert
597
+ curl = Curl::Easy.new(TestServlet.url)
598
+ curl.cacert= File.join(File.dirname(__FILE__),"cacert.pem")
599
+ assert /cacert.pem$/, curl.cacert
600
+ end
601
+
602
+ def test_user_agent
603
+ curl = Curl::Easy.new(TestServlet.url)
604
+ curl.useragent= "Curb-Easy/Ruby"
605
+ assert /ScrubDog$/,curl.useragent
606
+ end
607
+
550
608
  include TestServerMethods
551
609
 
552
610
  def setup
@@ -89,7 +89,6 @@ class TestCurbCurlMulti < Test::Unit::TestCase
89
89
  end
90
90
  m.add c
91
91
  end
92
-
93
92
  m.perform
94
93
 
95
94
  assert n, responses.size
@@ -147,7 +146,10 @@ class TestCurbCurlMulti < Test::Unit::TestCase
147
146
  end
148
147
 
149
148
  c1.on_failure do|c,rc|
150
- #puts "failure called: #{c.body_str.inspect}"
149
+ # rc => [Curl::Err::MalformedURLError, "URL using bad/illegal format or missing URL"]
150
+ assert_equal Curl::Easy, c.class
151
+ assert_equal Curl::Err::MalformedURLError, rc.first
152
+ assert_equal "URL using bad/illegal format or missing URL", rc.last
151
153
  end
152
154
 
153
155
  c2.on_success do|c|
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.2.0
4
+ version: 0.4.4.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-06-25 00:00:00 -04:00
13
+ date: 2009-07-12 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -32,19 +32,19 @@ files:
32
32
  - lib/curb.rb
33
33
  - lib/curl.rb
34
34
  - ext/curb.c
35
- - ext/curb_easy.c
36
- - ext/curb_errors.c
37
- - ext/curb_multi.c
38
35
  - ext/curb_postfield.c
36
+ - ext/curb_multi.c
37
+ - ext/curb_errors.c
38
+ - ext/curb_easy.c
39
39
  - ext/curb_upload.c
40
- - ext/curb.h
41
- - ext/curb_config.h
42
40
  - ext/curb_easy.h
43
41
  - ext/curb_errors.h
42
+ - ext/curb_upload.h
44
43
  - ext/curb_macros.h
45
- - ext/curb_multi.h
44
+ - ext/curb.h
46
45
  - ext/curb_postfield.h
47
- - ext/curb_upload.h
46
+ - ext/curb_config.h
47
+ - ext/curb_multi.h
48
48
  has_rdoc: true
49
49
  homepage: http://curb.rubyforge.org/
50
50
  licenses: []
@@ -71,19 +71,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements: []
72
72
 
73
73
  rubyforge_project: curb
74
- rubygems_version: 1.3.2
74
+ rubygems_version: 1.3.4
75
75
  signing_key:
76
76
  specification_version: 3
77
77
  summary: Ruby libcurl bindings
78
78
  test_files:
79
- - tests/alltests.rb
79
+ - tests/tc_curl_multi.rb
80
+ - tests/tc_curl_postfield.rb
80
81
  - tests/bug_curb_easy_blocks_ruby_threads.rb
81
- - tests/bug_instance_post_differs_from_class_post.rb
82
+ - tests/unittests.rb
82
83
  - tests/bug_require_last_or_segfault.rb
83
- - tests/helper.rb
84
- - tests/require_last_or_segfault_script.rb
84
+ - tests/bug_instance_post_differs_from_class_post.rb
85
85
  - tests/tc_curl_download.rb
86
+ - tests/alltests.rb
87
+ - tests/helper.rb
86
88
  - tests/tc_curl_easy.rb
87
- - tests/tc_curl_multi.rb
88
- - tests/tc_curl_postfield.rb
89
- - tests/unittests.rb
89
+ - tests/require_last_or_segfault_script.rb