curb 0.6.2.0 → 0.6.2.1

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/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.2.0"
24
- #define CURB_VER_NUM 620
23
+ #define CURB_VERSION "0.6.2.1"
24
+ #define CURB_VER_NUM 621
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 6
27
27
  #define CURB_VER_MIC 2
28
- #define CURB_VER_PATCH 0
28
+ #define CURB_VER_PATCH 1
29
29
 
30
30
 
31
31
  // Maybe not yet defined in Ruby
@@ -143,8 +143,12 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
143
143
  rb_gc_mark(rbce->debug_proc);
144
144
  rb_gc_mark(rbce->interface_hm);
145
145
  rb_gc_mark(rbce->userpwd);
146
+ #if HAVE_CURLOPT_USERNAME
146
147
  rb_gc_mark(rbce->username);
148
+ #endif
149
+ #if HAVE_CURLOPT_PASSWORD
147
150
  rb_gc_mark(rbce->password);
151
+ #endif
148
152
  rb_gc_mark(rbce->proxypwd);
149
153
  rb_gc_mark(rbce->headers);
150
154
  rb_gc_mark(rbce->cookies);
@@ -214,8 +218,12 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
214
218
  rbce->debug_proc = Qnil;
215
219
  rbce->interface_hm = Qnil;
216
220
  rbce->userpwd = Qnil;
221
+ #if HAVE_CURLOPT_USERNAME
217
222
  rbce->username = Qnil;
223
+ #endif
224
+ #if HAVE_CURLOPT_PASSWORD
218
225
  rbce->password = Qnil;
226
+ #endif
219
227
  rbce->proxypwd = Qnil;
220
228
  rbce->headers = rb_hash_new();
221
229
  rbce->cookies = Qnil;
@@ -1096,20 +1104,37 @@ static VALUE ruby_curl_easy_ftp_response_timeout_get(VALUE self, VALUE ftp_respo
1096
1104
  CURB_IMMED_GETTER(ruby_curl_easy, ftp_response_timeout, 0);
1097
1105
  }
1098
1106
 
1107
+
1099
1108
  static VALUE ruby_curl_easy_username_set(VALUE self, VALUE username) {
1109
+ #if HAVE_CURLOPT_USERNAME
1100
1110
  CURB_OBJECT_SETTER(ruby_curl_easy, username);
1111
+ #else
1112
+ return Qnil;
1113
+ #endif
1101
1114
  }
1102
1115
 
1103
1116
  static VALUE ruby_curl_easy_username_get(VALUE self, VALUE username) {
1117
+ #if HAVE_CURLOPT_USERNAME
1104
1118
  CURB_OBJECT_GETTER(ruby_curl_easy, username);
1119
+ #else
1120
+ return Qnil;
1121
+ #endif
1105
1122
  }
1106
1123
 
1107
1124
  static VALUE ruby_curl_easy_password_set(VALUE self, VALUE password) {
1125
+ #if HAVE_CURLOPT_PASSWORD
1108
1126
  CURB_OBJECT_SETTER(ruby_curl_easy, password);
1127
+ #else
1128
+ return Qnil;
1129
+ #endif
1109
1130
  }
1110
1131
 
1111
1132
  static VALUE ruby_curl_easy_password_get(VALUE self, VALUE password) {
1133
+ #if HAVE_CURLOPT_PASSWORD
1112
1134
  CURB_OBJECT_GETTER(ruby_curl_easy, password);
1135
+ #else
1136
+ return Qnil;
1137
+ #endif
1113
1138
  }
1114
1139
 
1115
1140
  /* ================== BOOL ATTRS ===================*/
@@ -1577,7 +1602,11 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1577
1602
 
1578
1603
  if (rbce->userpwd != Qnil) {
1579
1604
  curl_easy_setopt(curl, CURLOPT_USERPWD, StringValuePtr(rbce->userpwd));
1605
+ #if HAVE_CURLOPT_USERNAME
1580
1606
  } else if (rbce->username == Qnil && rbce->password == Qnil) { /* don't set this even to NULL if we have set username and password */
1607
+ #else
1608
+ } else {
1609
+ #endif
1581
1610
  curl_easy_setopt(curl, CURLOPT_USERPWD, NULL);
1582
1611
  }
1583
1612
 
@@ -23,6 +23,7 @@ VALUE eCurlErrTelnetError;
23
23
  VALUE eCurlErrTFTPError;
24
24
 
25
25
  /* Specific libcurl errors */
26
+ VALUE eCurlErrOK; /* not really an error but a return code */
26
27
  VALUE eCurlErrUnsupportedProtocol;
27
28
  VALUE eCurlErrFailedInit;
28
29
  VALUE eCurlErrMalformedURL;
@@ -127,6 +128,9 @@ VALUE rb_curl_easy_error(CURLcode code) {
127
128
  VALUE results;
128
129
 
129
130
  switch (code) {
131
+ case CURLE_OK: /* 0 */
132
+ exclz = eCurlErrOK;
133
+ break;
130
134
  case CURLE_UNSUPPORTED_PROTOCOL: /* 1 */
131
135
  exclz = eCurlErrUnsupportedProtocol;
132
136
  break;
@@ -509,6 +513,7 @@ void init_curb_errors() {
509
513
  eCurlErrTelnetError = rb_define_class_under(mCurlErr, "TelnetError", eCurlErrError);
510
514
  eCurlErrTFTPError = rb_define_class_under(mCurlErr, "TFTPError", eCurlErrError);
511
515
 
516
+ eCurlErrOK = rb_define_class_under(mCurlErr, "CurlOK", eCurlErrError);
512
517
  eCurlErrUnsupportedProtocol = rb_define_class_under(mCurlErr, "UnsupportedProtocolError", eCurlErrError);
513
518
  eCurlErrFailedInit = rb_define_class_under(mCurlErr, "FailedInitError", eCurlErrError);
514
519
  eCurlErrMalformedURL = rb_define_class_under(mCurlErr, "MalformedURLError", eCurlErrError);
@@ -659,10 +659,13 @@ class TestCurbCurlEasy < Test::Unit::TestCase
659
659
  curl = Curl::Easy.new(TestServlet.url)
660
660
  curl.username = "foo"
661
661
  curl.password = "bar"
662
- assert_equal "foo", curl.username
663
- assert_equal "bar", curl.password
662
+ if !curl.username.nil?
663
+ assert_equal "foo", curl.username
664
+ assert_equal "bar", curl.password
665
+ else
666
+ curl.userpwd = "foo:bar"
667
+ end
664
668
  curl.http_auth_types = :basic
665
- #curl.userpwd = "foo:bar"
666
669
  #curl.verbose = true
667
670
  curl.perform
668
671
  assert_equal 'Basic Zm9vOmJhcg==', $auth_header
@@ -673,6 +676,9 @@ class TestCurbCurlEasy < Test::Unit::TestCase
673
676
  curl = Curl::Easy.new(TestServlet.url)
674
677
  curl.username = "foo"
675
678
  curl.password = "bar"
679
+ if curl.username.nil?
680
+ curl.userpwd = "foo:bar"
681
+ end
676
682
  curl.http_auth_types = :ntlm
677
683
  curl.perform
678
684
  assert_equal 'NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=', $auth_header
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.2.0
4
+ version: 0.6.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Bamford