curb 0.7.5 → 0.7.6

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,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.5"
24
- #define CURB_VER_NUM 705
23
+ #define CURB_VERSION "0.7.6"
24
+ #define CURB_VER_NUM 706
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 7
27
- #define CURB_VER_MIC 5
27
+ #define CURB_VER_MIC 6
28
28
  #define CURB_VER_PATCH 0
29
29
 
30
30
 
@@ -1458,6 +1458,25 @@ static VALUE ruby_curl_easy_use_netrc_q(VALUE self) {
1458
1458
  static VALUE ruby_curl_easy_follow_location_set(VALUE self, VALUE follow_location) {
1459
1459
  CURB_BOOLEAN_SETTER(ruby_curl_easy, follow_location);
1460
1460
  }
1461
+ /*
1462
+ * call-seq:
1463
+ *
1464
+ * easy = Curl::Easy.new
1465
+ * easy.autoreferer=true
1466
+ */
1467
+ static VALUE ruby_curl_easy_autoreferer_set(VALUE self, VALUE autoreferer) {
1468
+ ruby_curl_easy *rbce;
1469
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
1470
+
1471
+ if (Qtrue == autoreferer) {
1472
+ curl_easy_setopt(rbce->curl, CURLOPT_AUTOREFERER, 1);
1473
+ }
1474
+ else {
1475
+ curl_easy_setopt(rbce->curl, CURLOPT_AUTOREFERER, 0);
1476
+ }
1477
+
1478
+ return autoreferer;
1479
+ }
1461
1480
 
1462
1481
  /*
1463
1482
  * call-seq:
@@ -1849,7 +1868,6 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce ) {
1849
1868
  /* general opts */
1850
1869
 
1851
1870
  curl_easy_setopt(curl, CURLOPT_HEADER, rbce->header_in_body);
1852
-
1853
1871
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, rbce->follow_location);
1854
1872
  curl_easy_setopt(curl, CURLOPT_MAXREDIRS, rbce->max_redirs);
1855
1873
 
@@ -2098,6 +2116,7 @@ static VALUE ruby_curl_easy_perform_get(VALUE self) {
2098
2116
  Data_Get_Struct(self, ruby_curl_easy, rbce);
2099
2117
  curl = rbce->curl;
2100
2118
 
2119
+ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL);
2101
2120
  curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
2102
2121
 
2103
2122
  return handle_perform(self,rbce);
@@ -2197,6 +2216,8 @@ static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
2197
2216
  Data_Get_Struct(self, ruby_curl_easy, rbce);
2198
2217
  curl = rbce->curl;
2199
2218
 
2219
+ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL);
2220
+
2200
2221
  if (rbce->multipart_form_post) {
2201
2222
  VALUE ret;
2202
2223
  struct curl_httppost *first = NULL, *last = NULL;
@@ -2358,6 +2379,7 @@ static VALUE ruby_curl_easy_perform_put(VALUE self, VALUE data) {
2358
2379
  Data_Get_Struct(self, ruby_curl_easy, rbce);
2359
2380
  curl = rbce->curl;
2360
2381
 
2382
+ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL);
2361
2383
  ruby_curl_easy_put_data_set(self, data);
2362
2384
 
2363
2385
  return handle_perform(self, rbce);
@@ -3261,6 +3283,7 @@ void init_curb_easy() {
3261
3283
  rb_define_method(cCurlEasy, "use_netrc?", ruby_curl_easy_use_netrc_q, 0);
3262
3284
  rb_define_method(cCurlEasy, "follow_location=", ruby_curl_easy_follow_location_set, 1);
3263
3285
  rb_define_method(cCurlEasy, "follow_location?", ruby_curl_easy_follow_location_q, 0);
3286
+ rb_define_method(cCurlEasy, "autoreferer=", ruby_curl_easy_autoreferer_set, 1);
3264
3287
  rb_define_method(cCurlEasy, "unrestricted_auth=", ruby_curl_easy_unrestricted_auth_set, 1);
3265
3288
  rb_define_method(cCurlEasy, "unrestricted_auth?", ruby_curl_easy_unrestricted_auth_q, 0);
3266
3289
  rb_define_method(cCurlEasy, "verbose=", ruby_curl_easy_verbose_set, 1);
@@ -325,14 +325,14 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
325
325
 
326
326
  Data_Get_Struct(easy, ruby_curl_easy, rbce);
327
327
 
328
- if (ecode != 0) {
329
- raise_curl_easy_error_exception(ecode);
330
- }
331
-
332
328
  rbce->last_result = result; /* save the last easy result code */
333
329
 
334
330
  ruby_curl_multi_remove( self, easy );
335
331
 
332
+ if (ecode != 0) {
333
+ raise_curl_easy_error_exception(ecode);
334
+ }
335
+
336
336
  if (!rb_easy_nil("complete_proc")) {
337
337
  rb_funcall( rb_easy_get("complete_proc"), idCall, 1, easy );
338
338
  }
@@ -742,6 +742,32 @@ class TestCurbCurlEasy < Test::Unit::TestCase
742
742
  easy.http_get
743
743
  end
744
744
 
745
+ def test_easy_http_verbs
746
+ curl = Curl::Easy.new(TestServlet.url)
747
+ curl.http_delete
748
+ assert_equal 'DELETE', curl.body_str
749
+ curl.http_get
750
+ assert_equal 'GET', curl.body_str
751
+ curl.http_post
752
+ assert_equal "POST\n", curl.body_str
753
+ curl.http('PURGE')
754
+ assert_equal 'PURGE', curl.body_str
755
+ curl.http_put('hello')
756
+ assert_equal "PUT\nhello", curl.body_str
757
+ end
758
+
759
+ # http://github.com/taf2/curb/issues/#issue/33
760
+ def test_easy_http_verbs_with_errors
761
+ curl = Curl::Easy.new("http://127.0.0.1:9012/") # test will fail if http server on port 9012
762
+ assert_raise Curl::Err::ConnectionFailedError do
763
+ curl.http_delete
764
+ end
765
+ curl.url = TestServlet.url
766
+ curl.http_get
767
+ assert_equal 'GET', curl.body_str
768
+ end
769
+
770
+
745
771
  include TestServerMethods
746
772
 
747
773
  def setup
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: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 5
10
- version: 0.7.5
9
+ - 6
10
+ version: 0.7.6
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-06 00:00:00 -04:00
19
+ date: 2010-06-11 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies: []
22
22