curb 0.7.11 → 0.7.12
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 +3 -3
- data/ext/curb_easy.c +6 -2
- data/tests/tc_curl_easy.rb +31 -4
- metadata +3 -3
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.
|
24
|
-
#define CURB_VER_NUM
|
23
|
+
#define CURB_VERSION "0.7.12"
|
24
|
+
#define CURB_VER_NUM 712
|
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
|
28
|
+
#define CURB_VER_PATCH 2
|
29
29
|
|
30
30
|
|
31
31
|
// Maybe not yet defined in Ruby
|
data/ext/curb_easy.c
CHANGED
@@ -815,7 +815,7 @@ static VALUE ruby_curl_easy_put_data_set(VALUE self, VALUE data) {
|
|
815
815
|
the easy handle is active or until the upload
|
816
816
|
is complete or terminated... */
|
817
817
|
|
818
|
-
curl_easy_setopt(curl, CURLOPT_NOBODY,0);
|
818
|
+
curl_easy_setopt(curl, CURLOPT_NOBODY, 0);
|
819
819
|
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
|
820
820
|
curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback)read_data_handler);
|
821
821
|
curl_easy_setopt(curl, CURLOPT_READDATA, rbce);
|
@@ -840,7 +840,7 @@ static VALUE ruby_curl_easy_put_data_set(VALUE self, VALUE data) {
|
|
840
840
|
|
841
841
|
if (rb_respond_to(data, rb_intern("read"))) {
|
842
842
|
VALUE stat = rb_funcall(data, rb_intern("stat"), 0);
|
843
|
-
if( stat ) {
|
843
|
+
if( stat && rb_hash_aref(headers, rb_str_new2("Content-Length")) == Qnil) {
|
844
844
|
VALUE size;
|
845
845
|
if( rb_hash_aref(headers, rb_str_new2("Expect")) == Qnil ) {
|
846
846
|
rb_hash_aset(headers, rb_str_new2("Expect"), rb_str_new2(""));
|
@@ -851,6 +851,10 @@ static VALUE ruby_curl_easy_put_data_set(VALUE self, VALUE data) {
|
|
851
851
|
else if( rb_hash_aref(headers, rb_str_new2("Content-Length")) == Qnil && rb_hash_aref(headers, rb_str_new2("Transfer-Encoding")) == Qnil ) {
|
852
852
|
rb_hash_aset(headers, rb_str_new2("Transfer-Encoding"), rb_str_new2("chunked"));
|
853
853
|
}
|
854
|
+
else if( rb_hash_aref(headers, rb_str_new2("Content-Length")) ) {
|
855
|
+
VALUE size = rb_funcall(rb_hash_aref(headers, rb_str_new2("Content-Length")), rb_intern("to_i"), 0);
|
856
|
+
curl_easy_setopt(curl, CURLOPT_INFILESIZE, FIX2LONG(size));
|
857
|
+
}
|
854
858
|
}
|
855
859
|
else if (rb_respond_to(data, rb_intern("to_s"))) {
|
856
860
|
curl_easy_setopt(curl, CURLOPT_INFILESIZE, RSTRING_LEN(data));
|
data/tests/tc_curl_easy.rb
CHANGED
@@ -855,10 +855,37 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
855
855
|
|
856
856
|
def test_easy_can_put_with_content_length
|
857
857
|
curl = Curl::Easy.new(TestServlet.url)
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
858
|
+
rd, wr = IO.pipe
|
859
|
+
buf = (("hello")* (1000 / 5))
|
860
|
+
|
861
|
+
producer = Thread.new do
|
862
|
+
5.times do
|
863
|
+
wr << buf
|
864
|
+
sleep 0.1 # act as a slow producer
|
865
|
+
end
|
866
|
+
end
|
867
|
+
|
868
|
+
consumer = Thread.new do
|
869
|
+
|
870
|
+
#curl.verbose = true
|
871
|
+
curl.headers['Content-Length'] = buf.size * 5
|
872
|
+
curl.headers['User-Agent'] = "Something else"
|
873
|
+
curl.headers['Content-Type'] = "text/javascript"
|
874
|
+
curl.headers['Date'] = Time.now.httpdate
|
875
|
+
curl.headers['Host'] = 's3.amazonaws.com'
|
876
|
+
curl.headers['Accept'] = '*/*'
|
877
|
+
curl.headers['Authorization'] = 'Foo Bar Biz Baz'
|
878
|
+
curl.http_put(rd)
|
879
|
+
assert_match /^PUT/, curl.body_str
|
880
|
+
assert_match /hello$/, curl.body_str
|
881
|
+
curl.header_str
|
882
|
+
curl.body_str
|
883
|
+
end
|
884
|
+
|
885
|
+
producer.join
|
886
|
+
wr.close
|
887
|
+
consumer.join
|
888
|
+
|
862
889
|
end
|
863
890
|
|
864
891
|
include TestServerMethods
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 12
|
10
|
+
version: 0.7.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ross Bamford
|