ghazel-curb 0.6.1.0 → 0.6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.6.1.0"
24
- #define CURB_VER_NUM 610
23
+ #define CURB_VERSION "0.6.4.0"
24
+ #define CURB_VER_NUM 640
25
25
  #define CURB_VER_MAJ 0
26
26
  #define CURB_VER_MIN 6
27
- #define CURB_VER_MIC 1
27
+ #define CURB_VER_MIC 4
28
28
  #define CURB_VER_PATCH 0
29
29
 
30
30
 
data/ext/curb_easy.c CHANGED
@@ -42,8 +42,9 @@ static size_t read_data_handler(void *ptr,
42
42
  size_t size,
43
43
  size_t nmemb,
44
44
  ruby_curl_easy *rbce) {
45
+ VALUE upload = rb_easy_get("upload");
45
46
  size_t read_bytes = (size*nmemb);
46
- VALUE stream = ruby_curl_upload_stream_get(rbce->upload);
47
+ VALUE stream = ruby_curl_upload_stream_get(upload);
47
48
 
48
49
  if (rb_respond_to(stream, rb_intern("read"))) {//if (rb_respond_to(stream, rb_intern("to_s"))) {
49
50
  /* copy read_bytes from stream into ptr */
@@ -62,7 +63,7 @@ static size_t read_data_handler(void *ptr,
62
63
  size_t len;
63
64
  size_t remaining;
64
65
  char *str_ptr;
65
- Data_Get_Struct(rbce->upload, ruby_curl_upload, rbcu);
66
+ Data_Get_Struct(upload, ruby_curl_upload, rbcu);
66
67
  str = rb_funcall(stream, rb_intern("to_s"), 0);
67
68
  len = RSTRING_LEN(str);
68
69
  remaining = len - rbcu->offset;
@@ -133,6 +134,7 @@ static int proc_debug_handler(CURL *curl,
133
134
 
134
135
  /* ================== MARK/FREE FUNC ==================*/
135
136
  void curl_easy_mark(ruby_curl_easy *rbce) {
137
+ #if 0
136
138
  rb_gc_mark(rbce->url);
137
139
  rb_gc_mark(rbce->proxy_url);
138
140
  rb_gc_mark(rbce->body_proc);
@@ -143,6 +145,12 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
143
145
  rb_gc_mark(rbce->debug_proc);
144
146
  rb_gc_mark(rbce->interface_hm);
145
147
  rb_gc_mark(rbce->userpwd);
148
+ #if HAVE_CURLOPT_USERNAME
149
+ rb_gc_mark(rbce->username);
150
+ #endif
151
+ #if HAVE_CURLOPT_PASSWORD
152
+ rb_gc_mark(rbce->password);
153
+ #endif
146
154
  rb_gc_mark(rbce->proxypwd);
147
155
  rb_gc_mark(rbce->headers);
148
156
  rb_gc_mark(rbce->cookies);
@@ -165,6 +173,8 @@ void curl_easy_mark(ruby_curl_easy *rbce) {
165
173
  if( rbce->upload != Qnil ) {
166
174
  rb_gc_mark(rbce->upload);
167
175
  }
176
+ #endif
177
+ rb_gc_mark(rbce->opts);
168
178
  }
169
179
 
170
180
  void curl_easy_free(ruby_curl_easy *rbce) {
@@ -201,31 +211,11 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
201
211
  /* handler */
202
212
  rbce->curl = curl_easy_init();
203
213
 
204
- /* assoc objects */
205
- rbce->url = url;
206
- rbce->proxy_url = Qnil;
207
- rbce->body_data = Qnil;
208
- rbce->body_proc = Qnil;
209
- rbce->header_data = Qnil;
210
- rbce->header_proc = Qnil;
211
- rbce->progress_proc = Qnil;
212
- rbce->debug_proc = Qnil;
213
- rbce->interface_hm = Qnil;
214
- rbce->userpwd = Qnil;
215
- rbce->proxypwd = Qnil;
216
- rbce->headers = rb_hash_new();
217
- rbce->cookies = Qnil;
218
- rbce->cookiefile = Qnil;
219
- rbce->cookiejar = Qnil;
220
- rbce->cert = Qnil;
221
- rbce->cacert = Qnil;
222
- rbce->certpassword = Qnil;
223
- rbce->certtype = rb_str_new2("PEM");
224
- rbce->encoding = Qnil;
225
- rbce->useragent = Qnil;
226
- rbce->success_proc = Qnil;
227
- rbce->failure_proc = Qnil;
228
- rbce->complete_proc = Qnil;
214
+ rbce->opts = rb_hash_new();
215
+
216
+ rb_easy_set("url", url);
217
+
218
+ rbce->curl_headers = NULL;
229
219
 
230
220
  /* various-typed opts */
231
221
  rbce->local_port = 0;
@@ -253,14 +243,6 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
253
243
  rbce->multipart_form_post = 0;
254
244
  rbce->enable_cookies = 0;
255
245
 
256
- /* buffers */
257
- rbce->postdata_buffer = Qnil;
258
- rbce->bodybuf = Qnil;
259
- rbce->headerbuf = Qnil;
260
- rbce->curl_headers = NULL;
261
-
262
- rbce->upload = Qnil;
263
-
264
246
  new_curl = Data_Wrap_Struct(klass, curl_easy_mark, curl_easy_free, rbce);
265
247
 
266
248
  /* set the new_curl pointer to the curl handle */
@@ -309,7 +291,7 @@ static VALUE ruby_curl_easy_clone(VALUE self) {
309
291
  * the URL between calls to +perform+.
310
292
  */
311
293
  static VALUE ruby_curl_easy_url_set(VALUE self, VALUE url) {
312
- CURB_OBJECT_SETTER(ruby_curl_easy, url);
294
+ CURB_OBJECT_HSETTER(ruby_curl_easy, url);
313
295
  }
314
296
 
315
297
  /*
@@ -319,7 +301,7 @@ static VALUE ruby_curl_easy_url_set(VALUE self, VALUE url) {
319
301
  * Obtain the URL that will be used by subsequent calls to +perform+.
320
302
  */
321
303
  static VALUE ruby_curl_easy_url_get(VALUE self) {
322
- CURB_OBJECT_GETTER(ruby_curl_easy, url);
304
+ CURB_OBJECT_HGETTER(ruby_curl_easy, url);
323
305
  }
324
306
 
325
307
  /*
@@ -348,7 +330,7 @@ static VALUE ruby_curl_easy_url_get(VALUE self) {
348
330
  * proxy_url, including protocol prefix (http://) and embedded user + password.
349
331
  */
350
332
  static VALUE ruby_curl_easy_proxy_url_set(VALUE self, VALUE proxy_url) {
351
- CURB_OBJECT_SETTER(ruby_curl_easy, proxy_url);
333
+ CURB_OBJECT_HSETTER(ruby_curl_easy, proxy_url);
352
334
  }
353
335
 
354
336
  /*
@@ -358,7 +340,7 @@ static VALUE ruby_curl_easy_proxy_url_set(VALUE self, VALUE proxy_url) {
358
340
  * Obtain the HTTP Proxy URL that will be used by subsequent calls to +perform+.
359
341
  */
360
342
  static VALUE ruby_curl_easy_proxy_url_get(VALUE self) {
361
- CURB_OBJECT_GETTER(ruby_curl_easy, proxy_url);
343
+ CURB_OBJECT_HGETTER(ruby_curl_easy, proxy_url);
362
344
  }
363
345
 
364
346
  /*
@@ -384,7 +366,7 @@ static VALUE ruby_curl_easy_proxy_url_get(VALUE self) {
384
366
  * the perform step.
385
367
  */
386
368
  static VALUE ruby_curl_easy_headers_set(VALUE self, VALUE headers) {
387
- CURB_OBJECT_SETTER(ruby_curl_easy, headers);
369
+ CURB_OBJECT_HSETTER(ruby_curl_easy, headers);
388
370
  }
389
371
 
390
372
  /*
@@ -394,7 +376,12 @@ static VALUE ruby_curl_easy_headers_set(VALUE self, VALUE headers) {
394
376
  * Obtain the custom HTTP headers for following requests.
395
377
  */
396
378
  static VALUE ruby_curl_easy_headers_get(VALUE self) {
397
- CURB_OBJECT_GETTER(ruby_curl_easy, headers);
379
+ ruby_curl_easy *rbce;
380
+ VALUE headers;
381
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
382
+ headers = rb_easy_get("headers");//rb_hash_aref(rbce->opts, rb_intern("headers"));
383
+ if (headers == Qnil) { headers = rb_easy_set("headers", rb_hash_new()); }
384
+ return headers;
398
385
  }
399
386
 
400
387
  /*
@@ -405,7 +392,7 @@ static VALUE ruby_curl_easy_headers_get(VALUE self) {
405
392
  * The name can be an interface name, an IP address or a host name.
406
393
  */
407
394
  static VALUE ruby_curl_easy_interface_set(VALUE self, VALUE interface_hm) {
408
- CURB_OBJECT_SETTER(ruby_curl_easy, interface_hm);
395
+ CURB_OBJECT_HSETTER(ruby_curl_easy, interface_hm);
409
396
  }
410
397
 
411
398
  /*
@@ -416,7 +403,7 @@ static VALUE ruby_curl_easy_interface_set(VALUE self, VALUE interface_hm) {
416
403
  * The name can be an interface name, an IP address or a host name.
417
404
  */
418
405
  static VALUE ruby_curl_easy_interface_get(VALUE self) {
419
- CURB_OBJECT_GETTER(ruby_curl_easy, interface_hm);
406
+ CURB_OBJECT_HGETTER(ruby_curl_easy, interface_hm);
420
407
  }
421
408
 
422
409
  /*
@@ -427,7 +414,7 @@ static VALUE ruby_curl_easy_interface_get(VALUE self) {
427
414
  * The supplied string should have the form "username:password"
428
415
  */
429
416
  static VALUE ruby_curl_easy_userpwd_set(VALUE self, VALUE userpwd) {
430
- CURB_OBJECT_SETTER(ruby_curl_easy, userpwd);
417
+ CURB_OBJECT_HSETTER(ruby_curl_easy, userpwd);
431
418
  }
432
419
 
433
420
  /*
@@ -438,7 +425,7 @@ static VALUE ruby_curl_easy_userpwd_set(VALUE self, VALUE userpwd) {
438
425
  * calls to +perform+.
439
426
  */
440
427
  static VALUE ruby_curl_easy_userpwd_get(VALUE self) {
441
- CURB_OBJECT_GETTER(ruby_curl_easy, userpwd);
428
+ CURB_OBJECT_HGETTER(ruby_curl_easy, userpwd);
442
429
  }
443
430
 
444
431
  /*
@@ -450,7 +437,7 @@ static VALUE ruby_curl_easy_userpwd_get(VALUE self) {
450
437
  * form "username:password"
451
438
  */
452
439
  static VALUE ruby_curl_easy_proxypwd_set(VALUE self, VALUE proxypwd) {
453
- CURB_OBJECT_SETTER(ruby_curl_easy, proxypwd);
440
+ CURB_OBJECT_HSETTER(ruby_curl_easy, proxypwd);
454
441
  }
455
442
 
456
443
  /*
@@ -462,7 +449,7 @@ static VALUE ruby_curl_easy_proxypwd_set(VALUE self, VALUE proxypwd) {
462
449
  * should have the form "username:password"
463
450
  */
464
451
  static VALUE ruby_curl_easy_proxypwd_get(VALUE self) {
465
- CURB_OBJECT_GETTER(ruby_curl_easy, proxypwd);
452
+ CURB_OBJECT_HGETTER(ruby_curl_easy, proxypwd);
466
453
  }
467
454
 
468
455
 
@@ -475,7 +462,7 @@ static VALUE ruby_curl_easy_proxypwd_get(VALUE self) {
475
462
  * Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
476
463
  */
477
464
  static VALUE ruby_curl_easy_cookies_set(VALUE self, VALUE cookies) {
478
- CURB_OBJECT_SETTER(ruby_curl_easy, cookies);
465
+ CURB_OBJECT_HSETTER(ruby_curl_easy, cookies);
479
466
  }
480
467
 
481
468
  /*
@@ -485,7 +472,7 @@ static VALUE ruby_curl_easy_cookies_set(VALUE self, VALUE cookies) {
485
472
  * Obtain the cookies for this Curl::Easy instance.
486
473
  */
487
474
  static VALUE ruby_curl_easy_cookies_get(VALUE self) {
488
- CURB_OBJECT_GETTER(ruby_curl_easy, cookies);
475
+ CURB_OBJECT_HGETTER(ruby_curl_easy, cookies);
489
476
  }
490
477
 
491
478
  /*
@@ -498,7 +485,7 @@ static VALUE ruby_curl_easy_cookies_get(VALUE self) {
498
485
  * engine, or this option will be ignored.
499
486
  */
500
487
  static VALUE ruby_curl_easy_cookiefile_set(VALUE self, VALUE cookiefile) {
501
- CURB_OBJECT_SETTER(ruby_curl_easy, cookiefile);
488
+ CURB_OBJECT_HSETTER(ruby_curl_easy, cookiefile);
502
489
  }
503
490
 
504
491
  /*
@@ -508,7 +495,7 @@ static VALUE ruby_curl_easy_cookiefile_set(VALUE self, VALUE cookiefile) {
508
495
  * Obtain the cookiefile file for this Curl::Easy instance.
509
496
  */
510
497
  static VALUE ruby_curl_easy_cookiefile_get(VALUE self) {
511
- CURB_OBJECT_GETTER(ruby_curl_easy, cookiefile);
498
+ CURB_OBJECT_HGETTER(ruby_curl_easy, cookiefile);
512
499
  }
513
500
 
514
501
  /*
@@ -522,7 +509,7 @@ static VALUE ruby_curl_easy_cookiefile_get(VALUE self) {
522
509
  * engine, or this option will be ignored.
523
510
  */
524
511
  static VALUE ruby_curl_easy_cookiejar_set(VALUE self, VALUE cookiejar) {
525
- CURB_OBJECT_SETTER(ruby_curl_easy, cookiejar);
512
+ CURB_OBJECT_HSETTER(ruby_curl_easy, cookiejar);
526
513
  }
527
514
 
528
515
  /*
@@ -532,7 +519,7 @@ static VALUE ruby_curl_easy_cookiejar_set(VALUE self, VALUE cookiejar) {
532
519
  * Obtain the cookiejar file to use for this Curl::Easy instance.
533
520
  */
534
521
  static VALUE ruby_curl_easy_cookiejar_get(VALUE self) {
535
- CURB_OBJECT_GETTER(ruby_curl_easy, cookiejar);
522
+ CURB_OBJECT_HGETTER(ruby_curl_easy, cookiejar);
536
523
  }
537
524
 
538
525
  /*
@@ -544,7 +531,7 @@ static VALUE ruby_curl_easy_cookiejar_get(VALUE self) {
544
531
  *
545
532
  */
546
533
  static VALUE ruby_curl_easy_cert_set(VALUE self, VALUE cert) {
547
- CURB_OBJECT_SETTER(ruby_curl_easy, cert);
534
+ CURB_OBJECT_HSETTER(ruby_curl_easy, cert);
548
535
  }
549
536
 
550
537
  /*
@@ -554,7 +541,7 @@ static VALUE ruby_curl_easy_cert_set(VALUE self, VALUE cert) {
554
541
  * Obtain the cert file to use for this Curl::Easy instance.
555
542
  */
556
543
  static VALUE ruby_curl_easy_cert_get(VALUE self) {
557
- CURB_OBJECT_GETTER(ruby_curl_easy, cert);
544
+ CURB_OBJECT_HGETTER(ruby_curl_easy, cert);
558
545
  }
559
546
 
560
547
  /*
@@ -566,7 +553,7 @@ static VALUE ruby_curl_easy_cert_get(VALUE self) {
566
553
  *
567
554
  */
568
555
  static VALUE ruby_curl_easy_cacert_set(VALUE self, VALUE cacert) {
569
- CURB_OBJECT_SETTER(ruby_curl_easy, cacert);
556
+ CURB_OBJECT_HSETTER(ruby_curl_easy, cacert);
570
557
  }
571
558
 
572
559
  /*
@@ -576,7 +563,7 @@ static VALUE ruby_curl_easy_cacert_set(VALUE self, VALUE cacert) {
576
563
  * Obtain the cacert file to use for this Curl::Easy instance.
577
564
  */
578
565
  static VALUE ruby_curl_easy_cacert_get(VALUE self) {
579
- CURB_OBJECT_GETTER(ruby_curl_easy, cacert);
566
+ CURB_OBJECT_HGETTER(ruby_curl_easy, cacert);
580
567
  }
581
568
 
582
569
  /*
@@ -586,7 +573,7 @@ static VALUE ruby_curl_easy_cacert_get(VALUE self) {
586
573
  * Set a password used to open the specified cert
587
574
  */
588
575
  static VALUE ruby_curl_easy_certpassword_set(VALUE self, VALUE certpassword) {
589
- CURB_OBJECT_SETTER(ruby_curl_easy, certpassword);
576
+ CURB_OBJECT_HSETTER(ruby_curl_easy, certpassword);
590
577
  }
591
578
 
592
579
  /*
@@ -598,7 +585,7 @@ static VALUE ruby_curl_easy_certpassword_set(VALUE self, VALUE certpassword) {
598
585
  *
599
586
  */
600
587
  static VALUE ruby_curl_easy_certtype_set(VALUE self, VALUE certtype) {
601
- CURB_OBJECT_SETTER(ruby_curl_easy, certtype);
588
+ CURB_OBJECT_HSETTER(ruby_curl_easy, certtype);
602
589
  }
603
590
 
604
591
  /*
@@ -608,7 +595,7 @@ static VALUE ruby_curl_easy_certtype_set(VALUE self, VALUE certtype) {
608
595
  * Obtain the cert type used for this Curl::Easy instance
609
596
  */
610
597
  static VALUE ruby_curl_easy_certtype_get(VALUE self) {
611
- CURB_OBJECT_GETTER(ruby_curl_easy, certtype);
598
+ CURB_OBJECT_HGETTER(ruby_curl_easy, certtype);
612
599
  }
613
600
 
614
601
  /*
@@ -619,7 +606,7 @@ static VALUE ruby_curl_easy_certtype_get(VALUE self) {
619
606
  *
620
607
  */
621
608
  static VALUE ruby_curl_easy_encoding_set(VALUE self, VALUE encoding) {
622
- CURB_OBJECT_SETTER(ruby_curl_easy, encoding);
609
+ CURB_OBJECT_HSETTER(ruby_curl_easy, encoding);
623
610
  }
624
611
  /*
625
612
  * call-seq:
@@ -629,7 +616,7 @@ static VALUE ruby_curl_easy_encoding_set(VALUE self, VALUE encoding) {
629
616
  *
630
617
  */
631
618
  static VALUE ruby_curl_easy_encoding_get(VALUE self) {
632
- CURB_OBJECT_GETTER(ruby_curl_easy, encoding);
619
+ CURB_OBJECT_HGETTER(ruby_curl_easy, encoding);
633
620
  }
634
621
 
635
622
  /*
@@ -640,7 +627,7 @@ static VALUE ruby_curl_easy_encoding_get(VALUE self) {
640
627
  *
641
628
  */
642
629
  static VALUE ruby_curl_easy_useragent_set(VALUE self, VALUE useragent) {
643
- CURB_OBJECT_SETTER(ruby_curl_easy, useragent);
630
+ CURB_OBJECT_HSETTER(ruby_curl_easy, useragent);
644
631
  }
645
632
 
646
633
  /*
@@ -650,7 +637,7 @@ static VALUE ruby_curl_easy_useragent_set(VALUE self, VALUE useragent) {
650
637
  * Obtain the user agent string used for this Curl::Easy instance
651
638
  */
652
639
  static VALUE ruby_curl_easy_useragent_get(VALUE self) {
653
- CURB_OBJECT_GETTER(ruby_curl_easy, useragent);
640
+ CURB_OBJECT_HGETTER(ruby_curl_easy, useragent);
654
641
  }
655
642
 
656
643
  /*
@@ -675,7 +662,8 @@ static VALUE ruby_curl_easy_post_body_set(VALUE self, VALUE post_body) {
675
662
  curl = rbce->curl;
676
663
 
677
664
  if ( post_body == Qnil ) {
678
- rbce->postdata_buffer = Qnil;
665
+ //rbce->postdata_buffer = Qnil;
666
+ rb_easy_del("postdata_buffer");
679
667
 
680
668
  } else {
681
669
  data = StringValuePtr(post_body);
@@ -683,7 +671,8 @@ static VALUE ruby_curl_easy_post_body_set(VALUE self, VALUE post_body) {
683
671
 
684
672
  // Store the string, since it has to hang around for the duration of the
685
673
  // request. See CURLOPT_POSTFIELDS in the libcurl docs.
686
- rbce->postdata_buffer = post_body;
674
+ //rbce->postdata_buffer = post_body;
675
+ rb_easy_set("postdata_buffer", post_body);
687
676
 
688
677
  curl_easy_setopt(curl, CURLOPT_POST, 1);
689
678
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
@@ -702,7 +691,7 @@ static VALUE ruby_curl_easy_post_body_set(VALUE self, VALUE post_body) {
702
691
  * Obtain the POST body used in this Curl::Easy instance.
703
692
  */
704
693
  static VALUE ruby_curl_easy_post_body_get(VALUE self) {
705
- CURB_OBJECT_GETTER(ruby_curl_easy, postdata_buffer);
694
+ CURB_OBJECT_HGETTER(ruby_curl_easy, postdata_buffer);
706
695
  }
707
696
 
708
697
  /*
@@ -724,9 +713,9 @@ static VALUE ruby_curl_easy_put_data_set(VALUE self, VALUE data) {
724
713
  ruby_curl_upload_stream_set(upload,data);
725
714
 
726
715
  curl = rbce->curl;
727
- rbce->upload = upload; /* keep the upload object alive as long as
728
- the easy handle is active or until the upload
729
- is complete or terminated... */
716
+ rb_easy_set("upload", upload); /* keep the upload object alive as long as
717
+ the easy handle is active or until the upload
718
+ is complete or terminated... */
730
719
 
731
720
  curl_easy_setopt(curl, CURLOPT_NOBODY,0);
732
721
  curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
@@ -737,35 +726,40 @@ static VALUE ruby_curl_easy_put_data_set(VALUE self, VALUE data) {
737
726
  * we need to set specific headers for the PUT to work... so
738
727
  * convert the internal headers structure to a HASH if one is set
739
728
  */
740
- if (rbce->headers != Qnil) {
741
- if (rb_type(rbce->headers) == T_ARRAY || rb_type(rbce->headers) == T_STRING) {
729
+ if (!rb_easy_nil("headers")) {
730
+ if (rb_easy_type_check("headers", T_ARRAY) || rb_easy_type_check("headers", T_STRING)) {
742
731
  rb_raise(rb_eRuntimeError, "Must set headers as a HASH to modify the headers in an PUT request");
743
732
  }
744
733
  }
745
734
 
735
+ VALUE headers = rb_easy_get("headers");
736
+ if( headers == Qnil ) {
737
+ headers = rb_hash_new();
738
+ }
746
739
  if (rb_respond_to(data, rb_intern("read"))) {
747
740
  VALUE stat = rb_funcall(data, rb_intern("stat"), 0);
748
741
  if( stat ) {
749
742
  VALUE size;
750
- if( rb_hash_aref(rbce->headers, rb_str_new2("Expect")) == Qnil ) {
751
- rb_hash_aset(rbce->headers, rb_str_new2("Expect"), rb_str_new2(""));
743
+ if( rb_hash_aref(headers, rb_str_new2("Expect")) == Qnil ) {
744
+ rb_hash_aset(headers, rb_str_new2("Expect"), rb_str_new2(""));
752
745
  }
753
746
  size = rb_funcall(stat, rb_intern("size"), 0);
754
747
  curl_easy_setopt(curl, CURLOPT_INFILESIZE, FIX2INT(size));
755
748
  }
756
- else if( rb_hash_aref(rbce->headers, rb_str_new2("Transfer-Encoding")) == Qnil ) {
757
- rb_hash_aset(rbce->headers, rb_str_new2("Transfer-Encoding"), rb_str_new2("chunked"));
749
+ else if( rb_hash_aref(headers, rb_str_new2("Transfer-Encoding")) == Qnil ) {
750
+ rb_hash_aset(headers, rb_str_new2("Transfer-Encoding"), rb_str_new2("chunked"));
758
751
  }
759
752
  }
760
753
  else if (rb_respond_to(data, rb_intern("to_s"))) {
761
754
  curl_easy_setopt(curl, CURLOPT_INFILESIZE, RSTRING_LEN(data));
762
- if( rb_hash_aref(rbce->headers, rb_str_new2("Expect")) == Qnil ) {
763
- rb_hash_aset(rbce->headers, rb_str_new2("Expect"), rb_str_new2(""));
755
+ if( rb_hash_aref(headers, rb_str_new2("Expect")) == Qnil ) {
756
+ rb_hash_aset(headers, rb_str_new2("Expect"), rb_str_new2(""));
764
757
  }
765
758
  }
766
759
  else {
767
760
  rb_raise(rb_eRuntimeError, "PUT data must respond to read or to_s");
768
761
  }
762
+ rb_easy_set("headers",headers);
769
763
 
770
764
  // if we made it this far, all should be well.
771
765
  return data;
@@ -872,16 +866,61 @@ static VALUE ruby_curl_easy_proxy_type_get(VALUE self) {
872
866
  CURB_IMMED_GETTER(ruby_curl_easy, proxy_type, -1);
873
867
  }
874
868
 
869
+ #if defined(HAVE_CURLAUTH_DIGEST_IE)
870
+ #define CURL_HTTPAUTH_STR_TO_NUM(node) \
871
+ (!strncmp("basic",node,5)) ? CURLAUTH_BASIC : \
872
+ (!strncmp("digest_ie",node,9)) ? CURLAUTH_DIGEST_IE : \
873
+ (!strncmp("digest",node,6)) ? CURLAUTH_DIGEST : \
874
+ (!strncmp("gssnegotiate",node,12)) ? CURLAUTH_GSSNEGOTIATE : \
875
+ (!strncmp("ntlm",node,4)) ? CURLAUTH_NTLM : \
876
+ (!strncmp("any",node,3)) ? CURLAUTH_ANY : \
877
+ (!strncmp("anysafe",node,7)) ? CURLAUTH_ANYSAFE : 0
878
+ #else
879
+ #define CURL_HTTPAUTH_STR_TO_NUM(node) \
880
+ (!strncmp("basic",node,5)) ? CURLAUTH_BASIC : \
881
+ (!strncmp("digest",node,6)) ? CURLAUTH_DIGEST : \
882
+ (!strncmp("gssnegotiate",node,12)) ? CURLAUTH_GSSNEGOTIATE : \
883
+ (!strncmp("ntlm",node,4)) ? CURLAUTH_NTLM : \
884
+ (!strncmp("any",node,3)) ? CURLAUTH_ANY : \
885
+ (!strncmp("anysafe",node,7)) ? CURLAUTH_ANYSAFE : 0
886
+ #endif
875
887
  /*
876
888
  * call-seq:
877
889
  * easy.http_auth_types = fixnum or nil => fixnum or nil
890
+ * easy.http_auth_types = [:basic,:digest,:digest_ie,:gssnegotiate, :ntlm, :any, :anysafe]
878
891
  *
879
892
  * Set the HTTP authentication types that may be used for the following
880
893
  * +perform+ calls. This is a bitmap made by ORing together the
881
894
  * Curl::CURLAUTH constants.
882
895
  */
883
- static VALUE ruby_curl_easy_http_auth_types_set(VALUE self, VALUE http_auth_types) {
884
- CURB_IMMED_SETTER(ruby_curl_easy, http_auth_types, 0);
896
+ static VALUE ruby_curl_easy_http_auth_types_set(int argc, VALUE *argv, VALUE self) {//VALUE self, VALUE http_auth_types) {
897
+ ruby_curl_easy *rbce;
898
+ VALUE args_ary;
899
+ rb_scan_args(argc, argv, "*", &args_ary);
900
+ Data_Get_Struct(self, ruby_curl_easy, rbce);
901
+ int i, len = RARRAY_LEN(args_ary);
902
+ char* node = NULL;
903
+ long mask = 0x000000;
904
+
905
+ if (len == 1 && (TYPE(rb_ary_entry(args_ary,0)) == T_FIXNUM || rb_ary_entry(args_ary,0) == Qnil)) {
906
+ if (rb_ary_entry(args_ary,0) == Qnil) {
907
+ rbce->http_auth_types = 0;
908
+ }
909
+ else {
910
+ rbce->http_auth_types = NUM2INT(rb_ary_entry(args_ary,0));
911
+ }
912
+ }
913
+ else {
914
+ // we could have multiple values, but they should be symbols
915
+ node = RSTRING_PTR(rb_funcall(rb_ary_entry(args_ary,0),rb_intern("to_s"),0));
916
+ mask = CURL_HTTPAUTH_STR_TO_NUM(node);
917
+ for( i = 1; i < len; ++i ) {
918
+ node = RSTRING_PTR(rb_funcall(rb_ary_entry(args_ary,i),rb_intern("to_s"),0));
919
+ mask |= CURL_HTTPAUTH_STR_TO_NUM(node);
920
+ }
921
+ rbce->http_auth_types = mask;
922
+ }
923
+ return INT2NUM(rbce->http_auth_types);
885
924
  }
886
925
 
887
926
  /*
@@ -1047,6 +1086,62 @@ static VALUE ruby_curl_easy_ftp_response_timeout_get(VALUE self, VALUE ftp_respo
1047
1086
  CURB_IMMED_GETTER(ruby_curl_easy, ftp_response_timeout, 0);
1048
1087
  }
1049
1088
 
1089
+ /*
1090
+ * call-seq:
1091
+ * easy.username = "foo" => String
1092
+ *
1093
+ * Set the HTTP Authentication username.
1094
+ */
1095
+ static VALUE ruby_curl_easy_username_set(VALUE self, VALUE username) {
1096
+ #if HAVE_CURLOPT_USERNAME
1097
+ CURB_OBJECT_HSETTER(ruby_curl_easy, username);
1098
+ #else
1099
+ return Qnil;
1100
+ #endif
1101
+ }
1102
+
1103
+ /*
1104
+ * call-seq:
1105
+ * easy.username => String
1106
+ *
1107
+ * Get the current username
1108
+ */
1109
+ static VALUE ruby_curl_easy_username_get(VALUE self, VALUE username) {
1110
+ #if HAVE_CURLOPT_USERNAME
1111
+ CURB_OBJECT_HGETTER(ruby_curl_easy, username);
1112
+ #else
1113
+ return Qnil;
1114
+ #endif
1115
+ }
1116
+
1117
+ /*
1118
+ * call-seq:
1119
+ * easy.password = "foo" => String
1120
+ *
1121
+ * Set the HTTP Authentication password.
1122
+ */
1123
+ static VALUE ruby_curl_easy_password_set(VALUE self, VALUE password) {
1124
+ #if HAVE_CURLOPT_PASSWORD
1125
+ CURB_OBJECT_HSETTER(ruby_curl_easy, password);
1126
+ #else
1127
+ return Qnil;
1128
+ #endif
1129
+ }
1130
+
1131
+ /*
1132
+ * call-seq:
1133
+ * easy.password => String
1134
+ *
1135
+ * Get the current password
1136
+ */
1137
+ static VALUE ruby_curl_easy_password_get(VALUE self, VALUE password) {
1138
+ #if HAVE_CURLOPT_PASSWORD
1139
+ CURB_OBJECT_HGETTER(ruby_curl_easy, password);
1140
+ #else
1141
+ return Qnil;
1142
+ #endif
1143
+ }
1144
+
1050
1145
  /* ================== BOOL ATTRS ===================*/
1051
1146
 
1052
1147
  /*
@@ -1330,12 +1425,12 @@ static VALUE ruby_curl_easy_enable_cookies_q(VALUE self) {
1330
1425
  * the processing with a Curl::Err::AbortedByCallbackError.
1331
1426
  */
1332
1427
  static VALUE ruby_curl_easy_on_body_set(int argc, VALUE *argv, VALUE self) {
1333
- CURB_HANDLER_PROC_SETTER(ruby_curl_easy, body_proc);
1428
+ CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, body_proc);
1334
1429
  }
1335
1430
 
1336
1431
  /*
1337
1432
  * call-seq:
1338
- * easy.on_success { ... } => &lt;old handler&gt;
1433
+ * easy.on_success { |easy| ... } => &lt;old handler&gt;
1339
1434
  *
1340
1435
  * Assign or remove the +on_success+ handler for this Curl::Easy instance.
1341
1436
  * To remove a previously-supplied handler, call this method with no
@@ -1345,12 +1440,12 @@ static VALUE ruby_curl_easy_on_body_set(int argc, VALUE *argv, VALUE self) {
1345
1440
  * status of 20x
1346
1441
  */
1347
1442
  static VALUE ruby_curl_easy_on_success_set(int argc, VALUE *argv, VALUE self) {
1348
- CURB_HANDLER_PROC_SETTER(ruby_curl_easy, success_proc);
1443
+ CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, success_proc);
1349
1444
  }
1350
1445
 
1351
1446
  /*
1352
1447
  * call-seq:
1353
- * easy.on_failure { ... } => &lt;old handler&gt;
1448
+ * easy.on_failure {|easy,code| ... } => &lt;old handler&gt;
1354
1449
  *
1355
1450
  * Assign or remove the +on_failure+ handler for this Curl::Easy instance.
1356
1451
  * To remove a previously-supplied handler, call this method with no
@@ -1360,12 +1455,12 @@ static VALUE ruby_curl_easy_on_success_set(int argc, VALUE *argv, VALUE self) {
1360
1455
  * status of 50x
1361
1456
  */
1362
1457
  static VALUE ruby_curl_easy_on_failure_set(int argc, VALUE *argv, VALUE self) {
1363
- CURB_HANDLER_PROC_SETTER(ruby_curl_easy, failure_proc);
1458
+ CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, failure_proc);
1364
1459
  }
1365
1460
 
1366
1461
  /*
1367
1462
  * call-seq:
1368
- * easy.on_complete { ... } => &lt;old handler&gt;
1463
+ * easy.on_complete {|easy| ... } => &lt;old handler&gt;
1369
1464
  *
1370
1465
  * Assign or remove the +on_complete+ handler for this Curl::Easy instance.
1371
1466
  * To remove a previously-supplied handler, call this method with no
@@ -1374,7 +1469,7 @@ static VALUE ruby_curl_easy_on_failure_set(int argc, VALUE *argv, VALUE self) {
1374
1469
  * The +on_complete+ handler is called when the request is finished.
1375
1470
  */
1376
1471
  static VALUE ruby_curl_easy_on_complete_set(int argc, VALUE *argv, VALUE self) {
1377
- CURB_HANDLER_PROC_SETTER(ruby_curl_easy, complete_proc);
1472
+ CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, complete_proc);
1378
1473
  }
1379
1474
 
1380
1475
  /*
@@ -1390,7 +1485,7 @@ static VALUE ruby_curl_easy_on_complete_set(int argc, VALUE *argv, VALUE self) {
1390
1485
  * block supplied to +on_body+.
1391
1486
  */
1392
1487
  static VALUE ruby_curl_easy_on_header_set(int argc, VALUE *argv, VALUE self) {
1393
- CURB_HANDLER_PROC_SETTER(ruby_curl_easy, header_proc);
1488
+ CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, header_proc);
1394
1489
  }
1395
1490
 
1396
1491
  /*
@@ -1411,7 +1506,7 @@ static VALUE ruby_curl_easy_on_header_set(int argc, VALUE *argv, VALUE self) {
1411
1506
  * throwing a Curl::Err::AbortedByCallbackError.
1412
1507
  */
1413
1508
  static VALUE ruby_curl_easy_on_progress_set(int argc, VALUE *argv, VALUE self) {
1414
- CURB_HANDLER_PROC_SETTER(ruby_curl_easy, progress_proc);
1509
+ CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, progress_proc);
1415
1510
  }
1416
1511
 
1417
1512
  /*
@@ -1432,7 +1527,7 @@ static VALUE ruby_curl_easy_on_progress_set(int argc, VALUE *argv, VALUE self) {
1432
1527
  * data. The data is passed as a String.
1433
1528
  */
1434
1529
  static VALUE ruby_curl_easy_on_debug_set(int argc, VALUE *argv, VALUE self) {
1435
- CURB_HANDLER_PROC_SETTER(ruby_curl_easy, debug_proc);
1530
+ CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, debug_proc);
1436
1531
  }
1437
1532
 
1438
1533
 
@@ -1473,85 +1568,105 @@ static VALUE cb_each_http_header(VALUE header, struct curl_slist **list) {
1473
1568
  *
1474
1569
  * Always returns Qtrue, rb_raise on error.
1475
1570
  */
1476
- VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *header_buffer, struct curl_slist **hdrs ) {
1571
+ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, struct curl_slist **hdrs ) {
1477
1572
  // TODO this could do with a bit of refactoring...
1478
1573
  CURL *curl;
1479
- VALUE url;
1574
+ VALUE url, _url = rb_easy_get("url");
1480
1575
 
1481
1576
  curl = rbce->curl;
1482
1577
 
1483
- if (rbce->url == Qnil) {
1578
+ if (_url == Qnil) {
1484
1579
  rb_raise(eCurlErrError, "No URL supplied");
1485
1580
  }
1486
1581
 
1487
- url = rb_check_string_type(rbce->url);
1582
+ url = rb_check_string_type(_url);
1488
1583
 
1489
1584
  // Need to configure the handler as per settings in rbce
1490
1585
  curl_easy_setopt(curl, CURLOPT_URL, StringValuePtr(url));
1491
1586
 
1492
1587
  // network stuff and auth
1493
- if (rbce->interface_hm != Qnil) {
1494
- curl_easy_setopt(curl, CURLOPT_INTERFACE, StringValuePtr(rbce->interface_hm));
1588
+ if (!rb_easy_nil("interface_hm")) {
1589
+ curl_easy_setopt(curl, CURLOPT_INTERFACE, rb_easy_get_str("interface_hm"));
1495
1590
  } else {
1496
1591
  curl_easy_setopt(curl, CURLOPT_INTERFACE, NULL);
1497
1592
  }
1498
1593
 
1499
- if (rbce->userpwd != Qnil) {
1500
- curl_easy_setopt(curl, CURLOPT_USERPWD, StringValuePtr(rbce->userpwd));
1594
+ #if HAVE_CURLOPT_USERNAME == 1 && HAVE_CURLOPT_PASSWORD == 1
1595
+ if (!rb_easy_nil("username")) {
1596
+ curl_easy_setopt(curl, CURLOPT_USERNAME, rb_easy_get_str("username"));
1597
+ } else {
1598
+ curl_easy_setopt(curl, CURLOPT_USERNAME, NULL);
1599
+ }
1600
+ if (!rb_easy_nil("password")) {
1601
+ curl_easy_setopt(curl, CURLOPT_PASSWORD, rb_easy_get_str("password"));
1602
+ }
1603
+ else {
1604
+ curl_easy_setopt(curl, CURLOPT_PASSWORD, NULL);
1605
+ }
1606
+ #endif
1607
+
1608
+ if (!rb_easy_nil("userpwd")) {
1609
+ curl_easy_setopt(curl, CURLOPT_USERPWD, rb_easy_get_str("userpwd"));
1610
+ #if HAVE_CURLOPT_USERNAME == 1
1611
+ } else if (rb_easy_nil("username") && rb_easy_nil("password")) { /* don't set this even to NULL if we have set username and password */
1612
+ #else
1501
1613
  } else {
1614
+ #endif
1502
1615
  curl_easy_setopt(curl, CURLOPT_USERPWD, NULL);
1503
1616
  }
1504
1617
 
1505
- if (rbce->proxy_url != Qnil) {
1506
- curl_easy_setopt(curl, CURLOPT_PROXY, StringValuePtr(rbce->proxy_url));
1618
+ if (!rb_easy_nil("proxy_url")) {
1619
+ curl_easy_setopt(curl, CURLOPT_PROXY, rb_easy_get_str("proxy_url"));
1507
1620
  } else {
1508
1621
  curl_easy_setopt(curl, CURLOPT_PROXY, NULL);
1509
1622
  }
1510
1623
 
1511
- if (rbce->proxypwd != Qnil) {
1512
- curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, StringValuePtr(rbce->proxypwd));
1624
+ if (!rb_easy_nil("proxypwd")) {
1625
+ curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, rb_easy_get_str("proxy_pwd"));
1513
1626
  } else {
1514
1627
  curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, NULL);
1515
1628
  }
1516
1629
 
1517
1630
  // body/header procs
1518
- if (rbce->body_proc != Qnil) {
1519
- *body_buffer = Qnil;
1631
+ if (!rb_easy_nil("body_proc")) {
1520
1632
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)&proc_data_handler);
1521
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, rbce->body_proc);
1633
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, rb_easy_get("body_proc"));//rbce->body_proc);
1634
+ /* clear out the body_data if it was set */
1635
+ rb_easy_del("body_data");
1522
1636
  } else {
1523
- *body_buffer = rb_str_buf_new(32768);
1637
+ VALUE body_buffer = rb_easy_set("body_data", rb_str_buf_new(32768));
1524
1638
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)&default_data_handler);
1525
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, *body_buffer);
1639
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, body_buffer);
1526
1640
  }
1527
1641
 
1528
- if (rbce->header_proc != Qnil) {
1529
- *header_buffer = Qnil;
1642
+ if (!rb_easy_nil("header_proc")) {
1530
1643
  curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)&proc_data_handler);
1531
- curl_easy_setopt(curl, CURLOPT_HEADERDATA, rbce->header_proc);
1644
+ curl_easy_setopt(curl, CURLOPT_HEADERDATA, rb_easy_get("header_proc"));
1645
+ /* clear out the header_data if it was set */
1646
+ rb_easy_del("header_data");
1532
1647
  } else {
1533
- *header_buffer = rb_str_buf_new(32768);
1648
+ VALUE header_buffer = rb_easy_set("header_data", rb_str_buf_new(16384));
1534
1649
  curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)&default_data_handler);
1535
- curl_easy_setopt(curl, CURLOPT_HEADERDATA, *header_buffer);
1650
+ curl_easy_setopt(curl, CURLOPT_HEADERDATA, header_buffer);
1536
1651
  }
1537
1652
 
1538
1653
  /* encoding */
1539
- if (rbce->encoding != Qnil) {
1540
- curl_easy_setopt(curl, CURLOPT_ENCODING, StringValuePtr(rbce->encoding));
1654
+ if (!rb_easy_nil("encoding")) {
1655
+ curl_easy_setopt(curl, CURLOPT_ENCODING, rb_easy_get_str("encoding"));
1541
1656
  }
1542
1657
 
1543
1658
  // progress and debug procs
1544
- if (rbce->progress_proc != Qnil) {
1659
+ if (!rb_easy_nil("progress_proc")) {
1545
1660
  curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, (curl_progress_callback)&proc_progress_handler);
1546
- curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, rbce->progress_proc);
1661
+ curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, rb_easy_get("progress_proc"));
1547
1662
  curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
1548
1663
  } else {
1549
1664
  curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
1550
1665
  }
1551
1666
 
1552
- if (rbce->debug_proc != Qnil) {
1667
+ if (!rb_easy_nil("debug_proc")) {
1553
1668
  curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, (curl_debug_callback)&proc_debug_handler);
1554
- curl_easy_setopt(curl, CURLOPT_DEBUGDATA, rbce->debug_proc);
1669
+ curl_easy_setopt(curl, CURLOPT_DEBUGDATA, rb_easy_get("debug_proc"));
1555
1670
  curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
1556
1671
  } else {
1557
1672
  // have to remove handler to re-enable standard verbosity
@@ -1648,30 +1763,30 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1648
1763
  FIXME this may not get disabled if it's enabled, the disabled again from ruby.
1649
1764
  */
1650
1765
  if (rbce->enable_cookies) {
1651
- if (rbce->cookiejar != Qnil) {
1652
- curl_easy_setopt(curl, CURLOPT_COOKIEJAR, StringValuePtr(rbce->cookiejar));
1766
+ if (!rb_easy_nil("cookiejar")) {
1767
+ curl_easy_setopt(curl, CURLOPT_COOKIEJAR, rb_easy_get_str("cookiejar"));
1653
1768
  }
1654
1769
 
1655
- if (rbce->cookiefile != Qnil) {
1656
- curl_easy_setopt(curl, CURLOPT_COOKIEFILE, StringValuePtr(rbce->cookiefile));
1770
+ if (!rb_easy_nil("cookiefile")) {
1771
+ curl_easy_setopt(curl, CURLOPT_COOKIEFILE, rb_easy_get_str("cookiefile"));
1657
1772
  } else {
1658
1773
  curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* "" = magic to just enable */
1659
1774
  }
1660
1775
  }
1661
1776
 
1662
- if (rbce->cookies != Qnil) {
1663
- curl_easy_setopt(curl, CURLOPT_COOKIE, StringValuePtr(rbce->cookies));
1777
+ if (!rb_easy_nil("cookies")) {
1778
+ curl_easy_setopt(curl, CURLOPT_COOKIE, rb_easy_get_str("cookies"));
1664
1779
  }
1665
1780
 
1666
1781
  /* Set up HTTPS cert handling if necessary */
1667
- if (rbce->cert != Qnil) {
1668
- curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, StringValuePtr(rbce->certtype));
1669
- curl_easy_setopt(curl, CURLOPT_SSLCERT, StringValuePtr(rbce->cert));
1670
- if (rbce->certpassword != Qnil) {
1671
- curl_easy_setopt(curl, CURLOPT_SSLCERTPASSWD, StringValuePtr(rbce->certpassword));
1782
+ if (!rb_easy_nil("cert")) {
1783
+ curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, rb_easy_get_str("certtype"));
1784
+ curl_easy_setopt(curl, CURLOPT_SSLCERT, rb_easy_get_str("cert"));
1785
+ if (!rb_easy_nil("certpassword")) {
1786
+ curl_easy_setopt(curl, CURLOPT_SSLCERTPASSWD, rb_easy_get_str("certpassword"));
1672
1787
  }
1673
1788
  }
1674
- if (rbce->cacert != Qnil) {
1789
+ if (!rb_easy_nil("cacert")) {
1675
1790
  #ifdef HAVE_CURL_CONFIG_CA
1676
1791
  curl_easy_setopt(curl, CURLOPT_CAINFO, CURL_CONFIG_CA);
1677
1792
  #else
@@ -1680,18 +1795,18 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1680
1795
  }
1681
1796
 
1682
1797
  /* Set the user-agent string if specified */
1683
- if (rbce->useragent != Qnil) {
1684
- curl_easy_setopt(curl, CURLOPT_USERAGENT, StringValuePtr(rbce->useragent));
1798
+ if (!rb_easy_nil("useragent")) {
1799
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, rb_easy_get_str("useragent"));
1685
1800
  }
1686
1801
 
1687
1802
  /* Setup HTTP headers if necessary */
1688
1803
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL); // XXX: maybe we shouldn't be clearing this?
1689
1804
 
1690
- if (rbce->headers != Qnil) {
1691
- if ((rb_type(rbce->headers) == T_ARRAY) || (rb_type(rbce->headers) == T_HASH)) {
1692
- rb_iterate(rb_each, rbce->headers, cb_each_http_header, (VALUE)hdrs);
1805
+ if (!rb_easy_nil("headers")) {
1806
+ if (rb_easy_type_check("headers", T_ARRAY) || rb_easy_type_check("headers", T_HASH)) {
1807
+ rb_iterate(rb_each, rb_easy_get("headers"), cb_each_http_header, (VALUE)hdrs);
1693
1808
  } else {
1694
- VALUE headers_str = rb_obj_as_string(rbce->headers);
1809
+ VALUE headers_str = rb_obj_as_string(rb_easy_get("headers"));
1695
1810
  *hdrs = curl_slist_append(*hdrs, StringValuePtr(headers_str));
1696
1811
  }
1697
1812
 
@@ -1708,7 +1823,7 @@ VALUE ruby_curl_easy_setup( ruby_curl_easy *rbce, VALUE *body_buffer, VALUE *hea
1708
1823
  *
1709
1824
  * Always returns Qtrue.
1710
1825
  */
1711
- VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce, VALUE bodybuf, VALUE headerbuf, struct curl_slist *headers ) {
1826
+ VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce, struct curl_slist *headers ) {
1712
1827
 
1713
1828
  CURL *curl = rbce->curl;
1714
1829
 
@@ -1718,38 +1833,9 @@ VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce, VALUE bodybuf, V
1718
1833
  rbce->curl_headers = NULL;
1719
1834
  }
1720
1835
 
1721
- // Sort out the built-in body/header data.
1722
- if (bodybuf != Qnil) {
1723
- if (TYPE(bodybuf) == T_STRING) {
1724
- rbce->body_data = rb_str_to_str(bodybuf);
1725
- }
1726
- else if (rb_respond_to(bodybuf, rb_intern("to_s"))) {
1727
- rbce->body_data = rb_funcall(bodybuf, rb_intern("to_s"), 0);
1728
- }
1729
- else {
1730
- rbce->body_data = Qnil;
1731
- }
1732
- } else {
1733
- rbce->body_data = Qnil;
1734
- }
1735
-
1736
- if (headerbuf != Qnil) {
1737
- if (TYPE(headerbuf) == T_STRING) {
1738
- rbce->header_data = rb_str_to_str(headerbuf);
1739
- }
1740
- else if (rb_respond_to(headerbuf, rb_intern("to_s"))) {
1741
- rbce->header_data = rb_funcall(headerbuf, rb_intern("to_s"), 0);
1742
- }
1743
- else {
1744
- rbce->header_data = Qnil;
1745
- }
1746
- } else {
1747
- rbce->header_data = Qnil;
1748
- }
1749
-
1750
1836
  // clean up a PUT request's curl options.
1751
- if (rbce->upload != Qnil) {
1752
- rbce->upload = Qnil; // set the upload object to Qnil to let the GC clean up
1837
+ if (!rb_easy_nil("upload")) {
1838
+ rb_easy_del("upload"); // set the upload object to Qnil to let the GC clean up
1753
1839
  curl_easy_setopt(curl, CURLOPT_UPLOAD, 0);
1754
1840
  curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
1755
1841
  curl_easy_setopt(curl, CURLOPT_READDATA, NULL);
@@ -1778,7 +1864,7 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
1778
1864
  ret = rb_funcall(multi, rb_intern("perform"), 0);
1779
1865
 
1780
1866
  /* check for errors in the easy response and raise exceptions if anything went wrong and their is no on_failure handler */
1781
- if( rbce->last_result != 0 && rbce->failure_proc == Qnil ) {
1867
+ if (rbce->last_result != 0 && rb_easy_nil("failure_proc")) {
1782
1868
  raise_curl_easy_error_exception(rbce->last_result);
1783
1869
  }
1784
1870
 
@@ -2026,7 +2112,7 @@ static VALUE ruby_curl_easy_class_perform_put(VALUE klass, VALUE url, VALUE data
2026
2112
  * your own body handler, this string will be empty.
2027
2113
  */
2028
2114
  static VALUE ruby_curl_easy_body_str_get(VALUE self) {
2029
- CURB_OBJECT_GETTER(ruby_curl_easy, body_data);
2115
+ CURB_OBJECT_HGETTER(ruby_curl_easy, body_data);
2030
2116
  }
2031
2117
 
2032
2118
  /*
@@ -2038,7 +2124,7 @@ static VALUE ruby_curl_easy_body_str_get(VALUE self) {
2038
2124
  * your own header handler, this string will be empty.
2039
2125
  */
2040
2126
  static VALUE ruby_curl_easy_header_str_get(VALUE self) {
2041
- CURB_OBJECT_GETTER(ruby_curl_easy, header_data);
2127
+ CURB_OBJECT_HGETTER(ruby_curl_easy, header_data);
2042
2128
  }
2043
2129
 
2044
2130
 
@@ -2583,11 +2669,12 @@ static VALUE ruby_curl_easy_inspect(VALUE self) {
2583
2669
  ruby_curl_easy *rbce;
2584
2670
  Data_Get_Struct(self, ruby_curl_easy, rbce);
2585
2671
  /* if we don't have a url set... we'll crash... */
2586
- if(rbce->url != Qnil && rb_type(rbce->url) == T_STRING) {
2587
- size_t len = 13+((RSTRING_LEN(rbce->url) > 50) ? 50 : RSTRING_LEN(rbce->url));
2672
+ if( !rb_easy_nil("url") && rb_easy_type_check("url", T_STRING)) {
2673
+ VALUE url = rb_easy_get("url");
2674
+ size_t len = 13+((RSTRING_LEN(url) > 50) ? 50 : RSTRING_LEN(url));
2588
2675
  /* "#<Net::HTTP http://www.google.com/:80 open=false>" */
2589
2676
  memcpy(buf,"#<Curl::Easy ", 13);
2590
- memcpy(buf+13,RSTRING_PTR(rbce->url), (len - 13));
2677
+ memcpy(buf+13,RSTRING_PTR(url), (len - 13));
2591
2678
  buf[len-1] = '>';
2592
2679
  return rb_str_new(buf,len);
2593
2680
  }
@@ -2832,7 +2919,7 @@ void init_curb_easy() {
2832
2919
  rb_define_method(cCurlEasy, "proxy_port", ruby_curl_easy_proxy_port_get, 0);
2833
2920
  rb_define_method(cCurlEasy, "proxy_type=", ruby_curl_easy_proxy_type_set, 1);
2834
2921
  rb_define_method(cCurlEasy, "proxy_type", ruby_curl_easy_proxy_type_get, 0);
2835
- rb_define_method(cCurlEasy, "http_auth_types=", ruby_curl_easy_http_auth_types_set, 1);
2922
+ rb_define_method(cCurlEasy, "http_auth_types=", ruby_curl_easy_http_auth_types_set, -1);
2836
2923
  rb_define_method(cCurlEasy, "http_auth_types", ruby_curl_easy_http_auth_types_get, 0);
2837
2924
  rb_define_method(cCurlEasy, "proxy_auth_types=", ruby_curl_easy_proxy_auth_types_set, 1);
2838
2925
  rb_define_method(cCurlEasy, "proxy_auth_types", ruby_curl_easy_proxy_auth_types_get, 0);
@@ -2847,6 +2934,11 @@ void init_curb_easy() {
2847
2934
  rb_define_method(cCurlEasy, "ftp_response_timeout=", ruby_curl_easy_ftp_response_timeout_set, 1);
2848
2935
  rb_define_method(cCurlEasy, "ftp_response_timeout", ruby_curl_easy_ftp_response_timeout_get, 0);
2849
2936
 
2937
+ rb_define_method(cCurlEasy, "username=", ruby_curl_easy_username_set, 1);
2938
+ rb_define_method(cCurlEasy, "username", ruby_curl_easy_username_get, 0);
2939
+ rb_define_method(cCurlEasy, "password=", ruby_curl_easy_password_set, 1);
2940
+ rb_define_method(cCurlEasy, "password", ruby_curl_easy_password_get, 0);
2941
+
2850
2942
  rb_define_method(cCurlEasy, "proxy_tunnel=", ruby_curl_easy_proxy_tunnel_set, 1);
2851
2943
  rb_define_method(cCurlEasy, "proxy_tunnel?", ruby_curl_easy_proxy_tunnel_q, 0);
2852
2944
  rb_define_method(cCurlEasy, "fetch_file_time=", ruby_curl_easy_fetch_file_time_set, 1);
data/ext/curb_easy.h CHANGED
@@ -18,33 +18,7 @@ typedef struct {
18
18
  /* The handler */
19
19
  CURL *curl;
20
20
 
21
- /* Objects we associate */
22
- VALUE url;
23
- VALUE proxy_url;
24
-
25
- VALUE body_proc;
26
- VALUE header_proc;
27
- VALUE body_data; /* Holds the response body from the last call to curl_easy_perform */
28
- VALUE header_data; /* unless a block is supplied (they'll be nil) */
29
- VALUE progress_proc;
30
- VALUE debug_proc;
31
- VALUE interface_hm;
32
- VALUE userpwd;
33
- VALUE proxypwd;
34
- VALUE headers; /* ruby array of strings with headers to set */
35
- VALUE cookies; /* string */
36
- VALUE cookiefile; /* filename */
37
- VALUE cookiejar; /* filename */
38
- VALUE cert;
39
- VALUE cacert;
40
- VALUE certpassword;
41
- VALUE certtype;
42
- VALUE encoding;
43
- VALUE useragent;
44
-
45
- VALUE success_proc;
46
- VALUE failure_proc;
47
- VALUE complete_proc;
21
+ VALUE opts; /* rather then allocate everything we might need to store, allocate a Hash and only store objects we actually use... */
48
22
 
49
23
  /* Other opts */
50
24
  unsigned short local_port; // 0 is no port
@@ -71,32 +45,16 @@ typedef struct {
71
45
  char verbose;
72
46
  char multipart_form_post;
73
47
  char enable_cookies;
74
-
75
- /* this is sometimes used as a buffer for a form data string,
76
- * which we alloc in C and need to hang around for the call,
77
- * and in case it's asked for before the next call.
78
- */
79
- VALUE postdata_buffer;
80
-
81
- /* when added to a multi handle these buffers are needed
82
- * when the easy handle isn't supplied the body proc
83
- * or a custom http header is passed.
84
- */
85
- VALUE bodybuf;
86
- VALUE headerbuf;
87
48
  struct curl_slist *curl_headers;
88
49
 
89
- // VALUE self; /* pointer to self, used by multi interface */
90
- VALUE upload; /* pointer to an active upload otherwise Qnil */
91
-
92
50
  int last_result; /* last result code from multi loop */
93
51
 
94
52
  } ruby_curl_easy;
95
53
 
96
54
  extern VALUE cCurlEasy;
97
55
 
98
- VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce, VALUE *bodybuf, VALUE *headerbuf, struct curl_slist **headers);
99
- VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce, VALUE bodybuf, VALUE headerbuf, struct curl_slist *headers);
56
+ VALUE ruby_curl_easy_setup(ruby_curl_easy *rbce, struct curl_slist **headers);
57
+ VALUE ruby_curl_easy_cleanup(VALUE self, ruby_curl_easy *rbce, struct curl_slist *headers);
100
58
 
101
59
  void init_curb_easy();
102
60
 
data/ext/curb_errors.c CHANGED
@@ -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);
data/ext/curb_macros.h CHANGED
@@ -8,6 +8,17 @@
8
8
  #ifndef __CURB_MACROS_H
9
9
  #define __CURB_MACROS_H
10
10
 
11
+ #define rb_easy_hkey(key) ID2SYM(rb_intern(key))
12
+ #define rb_easy_set(key,val) rb_hash_aset(rbce->opts, rb_easy_hkey(key) , val)
13
+ #define rb_easy_get(key) rb_hash_aref(rbce->opts, rb_easy_hkey(key))
14
+ #define rb_easy_del(key) rb_hash_delete(rbce->opts, rb_easy_hkey(key))
15
+ #define rb_easy_nil(key) (rb_hash_lookup(rbce->opts, rb_easy_hkey(key)) == Qnil)
16
+ #define rb_easy_type_check(key,type) (rb_type(rb_hash_aref(rbce->opts, rb_easy_hkey(key))) == type)
17
+
18
+ // TODO: rb_sym_to_s may not be defined?
19
+ #define rb_easy_get_str(key) \
20
+ RSTRING_PTR((rb_easy_type_check(key,T_STRING) ? rb_easy_get(key) : rb_str_to_str(rb_easy_get(key))))
21
+
11
22
  /* getter/setter macros for various things */
12
23
  /* setter for anything that stores a ruby VALUE in the struct */
13
24
  #define CURB_OBJECT_SETTER(type, attr) \
@@ -25,6 +36,22 @@
25
36
  Data_Get_Struct(self, type, ptr); \
26
37
  return ptr->attr;
27
38
 
39
+ /* setter for anything that stores a ruby VALUE in the struct opts hash */
40
+ #define CURB_OBJECT_HSETTER(type, attr) \
41
+ type *ptr; \
42
+ \
43
+ Data_Get_Struct(self, type, ptr); \
44
+ rb_hash_aset(ptr->opts, rb_easy_hkey(#attr), attr); \
45
+ \
46
+ return attr;
47
+
48
+ /* getter for anything that stores a ruby VALUE in the struct opts hash */
49
+ #define CURB_OBJECT_HGETTER(type, attr) \
50
+ type *ptr; \
51
+ \
52
+ Data_Get_Struct(self, type, ptr); \
53
+ return rb_hash_aref(ptr->opts, rb_easy_hkey(#attr));
54
+
28
55
  /* setter for bool flags */
29
56
  #define CURB_BOOLEAN_SETTER(type, attr) \
30
57
  type *ptr; \
@@ -57,6 +84,20 @@
57
84
  \
58
85
  return oldproc; \
59
86
 
87
+ /* special setter for on_event handlers that take a block, same as above but stores int he opts hash */
88
+ #define CURB_HANDLER_PROC_HSETTER(type, handler) \
89
+ type *ptr; \
90
+ VALUE oldproc, newproc; \
91
+ \
92
+ Data_Get_Struct(self, type, ptr); \
93
+ \
94
+ oldproc = rb_hash_aref(ptr->opts, rb_easy_hkey(#handler)); \
95
+ rb_scan_args(argc, argv, "0&", &newproc); \
96
+ \
97
+ rb_hash_aset(ptr->opts, rb_easy_hkey(#handler), newproc); \
98
+ \
99
+ return oldproc;
100
+
60
101
  /* setter for numerics that are kept in c ints */
61
102
  #define CURB_IMMED_SETTER(type, attr, nilval) \
62
103
  type *ptr; \
data/ext/curb_multi.c CHANGED
@@ -200,7 +200,7 @@ VALUE ruby_curl_multi_add(VALUE self, VALUE easy) {
200
200
  }
201
201
 
202
202
  /* setup the easy handle */
203
- ruby_curl_easy_setup( rbce, &(rbce->bodybuf), &(rbce->headerbuf), &(rbce->curl_headers) );
203
+ ruby_curl_easy_setup( rbce, &(rbce->curl_headers) );
204
204
 
205
205
  rbcm->active++;
206
206
 
@@ -253,14 +253,12 @@ static void rb_curl_multi_remove(ruby_curl_multi *rbcm, VALUE easy) {
253
253
 
254
254
  rbcm->active--;
255
255
 
256
- ruby_curl_easy_cleanup( easy, rbce, rbce->bodybuf, rbce->headerbuf, rbce->curl_headers );
257
- rbce->headerbuf = Qnil;
258
- rbce->bodybuf = Qnil;
256
+ ruby_curl_easy_cleanup( easy, rbce, rbce->curl_headers );
259
257
 
260
258
  // active should equal INT2FIX(RHASH(rbcm->requests)->tbl->num_entries)
261
259
  r = rb_hash_delete( rbcm->requests, easy );
262
260
  if( r != easy || r == Qnil ) {
263
- rb_warn("Possibly lost tack of Curl::Easy VALUE, it may not be reclaimed by GC");
261
+ rb_warn("Possibly lost track of Curl::Easy VALUE, it may not be reclaimed by GC");
264
262
  }
265
263
  }
266
264
 
@@ -306,25 +304,25 @@ static void rb_curl_mutli_handle_complete(VALUE self, CURL *easy_handle, int res
306
304
 
307
305
  ruby_curl_multi_remove( self, easy );
308
306
 
309
- if (rbce->complete_proc != Qnil) {
310
- rb_funcall( rbce->complete_proc, idCall, 1, easy );
307
+ if (!rb_easy_nil("complete_proc")) {
308
+ rb_funcall( rb_easy_get("complete_proc"), idCall, 1, easy );
311
309
  }
312
310
 
313
311
  curl_easy_getinfo(rbce->curl, CURLINFO_RESPONSE_CODE, &response_code);
314
312
 
315
313
  if (result != 0) {
316
- if (rbce->failure_proc != Qnil) {
317
- rb_funcall( rbce->failure_proc, idCall, 2, easy, rb_curl_easy_error(result) );
314
+ if (!rb_easy_nil("failure_proc")) {
315
+ rb_funcall( rb_easy_get("failure_proc"), idCall, 2, easy, rb_curl_easy_error(result) );
318
316
  }
319
317
  }
320
- else if (rbce->success_proc != Qnil &&
318
+ else if (!rb_easy_nil("success_proc") &&
321
319
  ((response_code >= 200 && response_code < 300) || response_code == 0)) {
322
320
  /* NOTE: we allow response_code == 0, in the case of non http requests e.g. reading from disk */
323
- rb_funcall( rbce->success_proc, idCall, 1, easy );
321
+ rb_funcall( rb_easy_get("success_proc"), idCall, 1, easy );
324
322
  }
325
- else if (rbce->failure_proc != Qnil &&
323
+ else if (!rb_easy_nil("failure_proc") &&
326
324
  (response_code >= 300 && response_code <= 999)) {
327
- rb_funcall( rbce->failure_proc, idCall, 2, easy, rb_curl_easy_error(result) );
325
+ rb_funcall( rb_easy_get("failure_proc"), idCall, 2, easy, rb_curl_easy_error(result) );
328
326
  }
329
327
  }
330
328
 
data/ext/curb_postfield.c CHANGED
@@ -41,7 +41,7 @@ void append_to_form(VALUE self,
41
41
  // is a file upload field
42
42
  if (rbcpf->content_proc != Qnil) {
43
43
  // with content proc
44
- rbcpf->buffer_str = rb_funcall(rbcpf->content_proc, idCall, self);
44
+ rbcpf->buffer_str = rb_funcall(rbcpf->content_proc, idCall, 1, self);
45
45
 
46
46
  if (rbcpf->remote_file == Qnil) {
47
47
  rb_raise(eCurlErrInvalidPostField, "Cannot post file upload field with no filename");
@@ -468,10 +468,10 @@ static VALUE ruby_curl_postfield_to_str(VALUE self) {
468
468
  }
469
469
  }
470
470
  } else {
471
- rb_raise(eCurlErrInvalidPostField, "Cannot convert unnamed field to string");
471
+ rb_raise(eCurlErrInvalidPostField, "Cannot convert unnamed field to string %s:%d", __FILE__, __LINE__);
472
472
  }
473
473
  } else {
474
- rb_raise(eCurlErrInvalidPostField, "Cannot convert non-content field to string");
474
+ rb_raise(eCurlErrInvalidPostField, "Cannot convert non-content field to string %s:%d", __FILE__, __LINE__);
475
475
  }
476
476
 
477
477
  return result;
data/ext/extconf.rb CHANGED
@@ -111,6 +111,13 @@ have_constant "curle_again"
111
111
  have_constant "curle_ssl_crl_badfile"
112
112
  have_constant "curle_ssl_issuer_error"
113
113
 
114
+ # username/password added in 7.19.1
115
+ have_constant "curlopt_username"
116
+ have_constant "curlopt_password"
117
+
118
+ # ie quirk added in 7.19.3
119
+ have_constant "curlauth_digest_ie"
120
+
114
121
  # centos 4.5 build of libcurl
115
122
  have_constant "curlm_bad_socket"
116
123
  have_constant "curlm_unknown_option"
data/tests/helper.rb CHANGED
@@ -59,6 +59,7 @@ class TestServlet < WEBrick::HTTPServlet::AbstractServlet
59
59
 
60
60
  def respond_with(method,req,res)
61
61
  res.body = method.to_s
62
+ $auth_header = req['Authorization']
62
63
  res['Content-Type'] = "text/plain"
63
64
  end
64
65
 
@@ -655,6 +655,35 @@ class TestCurbCurlEasy < Test::Unit::TestCase
655
655
  assert /ScrubDog$/,curl.useragent
656
656
  end
657
657
 
658
+ def test_username_password
659
+ curl = Curl::Easy.new(TestServlet.url)
660
+ curl.username = "foo"
661
+ curl.password = "bar"
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
668
+ curl.http_auth_types = :basic
669
+ #curl.verbose = true
670
+ curl.perform
671
+ assert_equal 'Basic Zm9vOmJhcg==', $auth_header
672
+
673
+ # curl checks the auth type supported by the server, so we have to create a
674
+ # new easy handle if we're going to change the auth type...
675
+
676
+ curl = Curl::Easy.new(TestServlet.url)
677
+ curl.username = "foo"
678
+ curl.password = "bar"
679
+ if curl.username.nil?
680
+ curl.userpwd = "foo:bar"
681
+ end
682
+ curl.http_auth_types = :ntlm
683
+ curl.perform
684
+ assert_equal 'NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=', $auth_header
685
+ end
686
+
658
687
  include TestServerMethods
659
688
 
660
689
  def setup
@@ -44,7 +44,7 @@ class TestCurbCurlMulti < Test::Unit::TestCase
44
44
 
45
45
  m.perform do
46
46
  # idle
47
- puts "idling..."
47
+ #puts "idling..."
48
48
  end
49
49
 
50
50
  assert_match(/^# DO NOT REMOVE THIS COMMENT/, c1.body_str)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghazel-curb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.0
4
+ version: 0.6.2.1
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-12-06 00:00:00 -08:00
13
+ date: 2009-12-26 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16