taf2-curb 0.4.1.0 → 0.4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/curb.h +3 -3
- data/ext/curb_easy.c +31 -17
- data/tests/helper.rb +1 -0
- data/tests/tc_curl_easy.rb +2 -0
- metadata +2 -2
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.
|
24
|
-
#define CURB_VER_NUM
|
23
|
+
#define CURB_VERSION "0.4.2.0"
|
24
|
+
#define CURB_VER_NUM 420
|
25
25
|
#define CURB_VER_MAJ 0
|
26
26
|
#define CURB_VER_MIN 4
|
27
|
-
#define CURB_VER_MIC
|
27
|
+
#define CURB_VER_MIC 2
|
28
28
|
#define CURB_VER_PATCH 0
|
29
29
|
|
30
30
|
|
data/ext/curb_easy.c
CHANGED
@@ -1568,27 +1568,27 @@ VALUE ruby_curl_easy_cleanup( VALUE self, ruby_curl_easy *rbce, VALUE bodybuf, V
|
|
1568
1568
|
*/
|
1569
1569
|
static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
|
1570
1570
|
|
1571
|
-
int msgs;
|
1572
|
-
int still_running = 1;
|
1573
1571
|
CURLcode result = -1;
|
1574
|
-
CURLMcode mcode = -1;
|
1575
|
-
CURLM *multi_handle = curl_multi_init();
|
1576
1572
|
struct curl_slist *headers = NULL;
|
1577
1573
|
VALUE bodybuf = Qnil, headerbuf = Qnil;
|
1578
|
-
long timeout;
|
1579
|
-
struct timeval tv = {0, 0};
|
1580
|
-
int rc; /* select() return code */
|
1581
|
-
int maxfd;
|
1582
1574
|
// char errors[CURL_ERROR_SIZE*2];
|
1583
1575
|
|
1584
1576
|
ruby_curl_easy_setup(rbce, &bodybuf, &headerbuf, &headers);
|
1585
1577
|
// curl_easy_setopt(rbce->curl, CURLOPT_ERRORBUFFER, errors);
|
1586
1578
|
// curl_easy_setopt(rbce->curl, CURLOPT_VERBOSE, 1);
|
1587
1579
|
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1580
|
+
if( rb_thread_alone() ) {
|
1581
|
+
result = curl_easy_perform(rbce->curl);
|
1582
|
+
}
|
1583
|
+
else {
|
1584
|
+
int msgs;
|
1585
|
+
int still_running = 1;
|
1586
|
+
CURLMcode mcode = -1;
|
1587
|
+
CURLM *multi_handle = curl_multi_init();
|
1588
|
+
long timeout;
|
1589
|
+
struct timeval tv = {0, 0};
|
1590
|
+
int rc; /* select() return code */
|
1591
|
+
int maxfd;
|
1592
1592
|
|
1593
1593
|
/* NOTE:
|
1594
1594
|
* We create an Curl multi handle here and use rb_thread_select allowing other ruby threads to
|
@@ -1679,7 +1679,7 @@ static VALUE handle_perform(VALUE self, ruby_curl_easy *rbce) {
|
|
1679
1679
|
|
1680
1680
|
curl_multi_remove_handle(multi_handle, rbce->curl);
|
1681
1681
|
curl_multi_cleanup(multi_handle);
|
1682
|
-
|
1682
|
+
}
|
1683
1683
|
|
1684
1684
|
ruby_curl_easy_cleanup(self, rbce, bodybuf, headerbuf, headers);
|
1685
1685
|
|
@@ -1918,20 +1918,34 @@ static VALUE ruby_curl_easy_perform_put(VALUE self, VALUE data) {
|
|
1918
1918
|
curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback)read_data_handler);
|
1919
1919
|
curl_easy_setopt(curl, CURLOPT_READDATA, rbce);
|
1920
1920
|
|
1921
|
+
/*
|
1922
|
+
* we need to set specific headers for the PUT to work... so
|
1923
|
+
* convert the internal headers structure to a HASH if one is set
|
1924
|
+
*/
|
1925
|
+
if (rbce->headers != Qnil) {
|
1926
|
+
if (rb_type(rbce->headers) == T_ARRAY || rb_type(rbce->headers) == T_STRING) {
|
1927
|
+
rb_raise(rb_eRuntimeError, "Must set headers as a HASH to modify the headers in an http_put request");
|
1928
|
+
}
|
1929
|
+
}
|
1930
|
+
|
1921
1931
|
if (rb_respond_to(data, rb_intern("read"))) {
|
1922
1932
|
VALUE stat = rb_funcall(data, rb_intern("stat"), 0);
|
1923
1933
|
if( stat ) {
|
1924
|
-
|
1934
|
+
if( rb_hash_aref(rbce->headers, rb_str_new2("Expect")) == Qnil ) {
|
1935
|
+
rb_hash_aset(rbce->headers, rb_str_new2("Expect"), rb_str_new2(""));
|
1936
|
+
}
|
1925
1937
|
VALUE size = rb_funcall(stat, rb_intern("size"), 0);
|
1926
1938
|
curl_easy_setopt(curl, CURLOPT_INFILESIZE, FIX2INT(size));
|
1927
1939
|
}
|
1928
|
-
else {
|
1929
|
-
|
1940
|
+
else if( rb_hash_aref(rbce->headers, rb_str_new2("Transfer-Encoding")) == Qnil ) {
|
1941
|
+
rb_hash_aset(rbce->headers, rb_str_new2("Transfer-Encoding"), rb_str_new2("chunked"));
|
1930
1942
|
}
|
1931
1943
|
}
|
1932
1944
|
else if (rb_respond_to(data, rb_intern("to_s"))) {
|
1933
1945
|
curl_easy_setopt(curl, CURLOPT_INFILESIZE, RSTRING_LEN(data));
|
1934
|
-
|
1946
|
+
if( rb_hash_aref(rbce->headers, rb_str_new2("Expect")) == Qnil ) {
|
1947
|
+
rb_hash_aset(rbce->headers, rb_str_new2("Expect"), rb_str_new2(""));
|
1948
|
+
}
|
1935
1949
|
}
|
1936
1950
|
else {
|
1937
1951
|
rb_raise(rb_eRuntimeError, "PUT data must respond to read or to_s");
|
data/tests/helper.rb
CHANGED
data/tests/tc_curl_easy.rb
CHANGED
@@ -532,9 +532,11 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
532
532
|
|
533
533
|
def test_put_remote
|
534
534
|
curl = Curl::Easy.new(TestServlet.url)
|
535
|
+
curl.headers['Content-Type'] = 'application/json'
|
535
536
|
assert curl.http_put("message")
|
536
537
|
assert_match /^PUT/, curl.body_str
|
537
538
|
assert_match /message$/, curl.body_str
|
539
|
+
assert_match /application\/json/, curl.header_str
|
538
540
|
end
|
539
541
|
|
540
542
|
def test_put_remote_file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taf2-curb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2.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-
|
13
|
+
date: 2009-06-22 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|