curb 0.1.2 → 0.1.4
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/Rakefile +6 -5
- data/ext/curb.h +3 -3
- data/ext/curb.rb +2 -2
- data/ext/curb_easy.c +51 -11
- data/ext/curb_easy.h +1 -0
- data/tests/tc_curl_easy.rb +9 -2
- metadata +2 -2
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ rescue LoadError
|
|
11
11
|
end
|
12
12
|
|
13
13
|
CLEAN.include '**/*.o'
|
14
|
-
CLEAN.include '
|
14
|
+
CLEAN.include "**/*.#{Config::MAKEFILE_CONFIG['DLEXT']}"
|
15
15
|
CLOBBER.include 'doc'
|
16
16
|
CLOBBER.include '**/*.log'
|
17
17
|
CLOBBER.include '**/Makefile'
|
@@ -45,6 +45,8 @@ end
|
|
45
45
|
MAKECMD = ENV['MAKE_CMD'] || 'make'
|
46
46
|
MAKEOPTS = ENV['MAKE_OPTS'] || ''
|
47
47
|
|
48
|
+
CURB_SO = "ext/curb_core.#{Config::MAKEFILE_CONFIG['DLEXT']}"
|
49
|
+
|
48
50
|
file 'ext/Makefile' => 'ext/extconf.rb' do
|
49
51
|
Dir.chdir('ext') do
|
50
52
|
ruby "extconf.rb #{ENV['EXTCONF_OPTS']}"
|
@@ -53,20 +55,19 @@ end
|
|
53
55
|
|
54
56
|
def make(target = '')
|
55
57
|
Dir.chdir('ext') do
|
56
|
-
pid =
|
57
|
-
Process.waitpid pid
|
58
|
+
pid = system("#{MAKECMD} #{MAKEOPTS} #{target}")
|
58
59
|
$?.exitstatus
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
62
63
|
# Let make handle dependencies between c/o/so - we'll just run it.
|
63
|
-
file
|
64
|
+
file CURB_SO => 'ext/Makefile' do
|
64
65
|
m = make
|
65
66
|
fail "Make failed (status #{m})" unless m == 0
|
66
67
|
end
|
67
68
|
|
68
69
|
desc "Compile the shared object"
|
69
|
-
task :compile =>
|
70
|
+
task :compile => CURB_SO
|
70
71
|
|
71
72
|
desc "Install to your site_ruby directory"
|
72
73
|
task :install => :alltests do
|
data/ext/curb.h
CHANGED
@@ -18,11 +18,11 @@
|
|
18
18
|
#include "curb_macros.h"
|
19
19
|
|
20
20
|
// These should be managed from the Rake 'release' task.
|
21
|
-
#define CURB_VERSION "0.1.
|
22
|
-
#define CURB_VER_NUM
|
21
|
+
#define CURB_VERSION "0.1.4"
|
22
|
+
#define CURB_VER_NUM 140
|
23
23
|
#define CURB_VER_MAJ 0
|
24
24
|
#define CURB_VER_MIN 1
|
25
|
-
#define CURB_VER_MIC
|
25
|
+
#define CURB_VER_MIC 4
|
26
26
|
#define CURB_VER_PATCH 0
|
27
27
|
|
28
28
|
|
data/ext/curb.rb
CHANGED
@@ -27,8 +27,8 @@ module Curl
|
|
27
27
|
# returns a size that differs from the data chunk size - in this case, the
|
28
28
|
# offending chunk will *not* be written to the file, the file will be closed,
|
29
29
|
# and a Curl::Err::AbortedByCallbackError will be raised.
|
30
|
-
def download(url, filename = url.split(/\?/).first.split(/\//).last)
|
31
|
-
curl = Curl::Easy.new(url)
|
30
|
+
def download(url, filename = url.split(/\?/).first.split(/\//).last, &blk)
|
31
|
+
curl = Curl::Easy.new(url, &blk)
|
32
32
|
|
33
33
|
File.open(filename, "wb") do |output|
|
34
34
|
old_on_body = curl.on_body do |data|
|
data/ext/curb_easy.c
CHANGED
@@ -156,7 +156,8 @@ static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) {
|
|
156
156
|
/* bool opts */
|
157
157
|
rbce->proxy_tunnel = 0;
|
158
158
|
rbce->fetch_file_time = 0;
|
159
|
-
rbce->ssl_verify_peer =
|
159
|
+
rbce->ssl_verify_peer = 1;
|
160
|
+
rbce->ssl_verify_host = 1;
|
160
161
|
rbce->header_in_body = 0;
|
161
162
|
rbce->use_netrc = 0;
|
162
163
|
rbce->follow_location = 0;
|
@@ -715,7 +716,14 @@ static VALUE ruby_curl_easy_fetch_file_time_q(VALUE self) {
|
|
715
716
|
* ssl_verify_peer = boolean => boolean
|
716
717
|
*
|
717
718
|
* Configure whether this Curl instance will verify the SSL peer
|
718
|
-
* certificate.
|
719
|
+
* certificate. When true (the default), and the verification fails to
|
720
|
+
* prove that the certificate is authentic, the connection fails. When
|
721
|
+
* false, the connection succeeds regardless.
|
722
|
+
*
|
723
|
+
* Authenticating the certificate is not by itself very useful. You
|
724
|
+
* typically want to ensure that the server, as authentically identified
|
725
|
+
* by its certificate, is the server you mean to be talking to.
|
726
|
+
* The ssl_verify_host? options controls that.
|
719
727
|
*/
|
720
728
|
static VALUE ruby_curl_easy_ssl_verify_peer_set(VALUE self, VALUE ssl_verify_peer) {
|
721
729
|
CURB_BOOLEAN_SETTER(ruby_curl_easy, ssl_verify_peer);
|
@@ -732,6 +740,34 @@ static VALUE ruby_curl_easy_ssl_verify_peer_q(VALUE self) {
|
|
732
740
|
CURB_BOOLEAN_GETTER(ruby_curl_easy, ssl_verify_peer);
|
733
741
|
}
|
734
742
|
|
743
|
+
/*
|
744
|
+
* call-seq:
|
745
|
+
* ssl_verify_host = boolean => boolean
|
746
|
+
*
|
747
|
+
* Configure whether this Curl instance will verify that the server cert
|
748
|
+
* is for the server it is known as. When true (the default) the server
|
749
|
+
* certificate must indicate that the server is the server to which you
|
750
|
+
* meant to connect, or the connection fails. When false, the connection
|
751
|
+
* will succeed regardless of the names in the certificate.
|
752
|
+
*
|
753
|
+
* this option controls is of the identity that the server claims.
|
754
|
+
* The server could be lying. To control lying, see ssl_verify_peer? .
|
755
|
+
*/
|
756
|
+
static VALUE ruby_curl_easy_ssl_verify_host_set(VALUE self, VALUE ssl_verify_host) {
|
757
|
+
CURB_BOOLEAN_SETTER(ruby_curl_easy, ssl_verify_host);
|
758
|
+
}
|
759
|
+
|
760
|
+
/*
|
761
|
+
* call-seq:
|
762
|
+
* ssl_verify_host? => boolean
|
763
|
+
*
|
764
|
+
* Determine whether this Curl instance will verify that the server cert
|
765
|
+
* is for the server it is known as.
|
766
|
+
*/
|
767
|
+
static VALUE ruby_curl_easy_ssl_verify_host_q(VALUE self) {
|
768
|
+
CURB_BOOLEAN_GETTER(ruby_curl_easy, ssl_verify_host);
|
769
|
+
}
|
770
|
+
|
735
771
|
/*
|
736
772
|
* call-seq:
|
737
773
|
* header_in_body = boolean => boolean
|
@@ -984,7 +1020,7 @@ static VALUE ruby_curl_easy_on_debug_set(int argc, VALUE *argv, VALUE self) {
|
|
984
1020
|
static VALUE cb_each_http_header(VALUE header, struct curl_slist **list) {
|
985
1021
|
VALUE header_str = Qnil;
|
986
1022
|
|
987
|
-
rb_p(header);
|
1023
|
+
//rb_p(header);
|
988
1024
|
|
989
1025
|
if (rb_type(header) == T_ARRAY) {
|
990
1026
|
// we're processing a hash, header is [name, val]
|
@@ -1001,7 +1037,7 @@ static VALUE cb_each_http_header(VALUE header, struct curl_slist **list) {
|
|
1001
1037
|
header_str = rb_obj_as_string(header);
|
1002
1038
|
}
|
1003
1039
|
|
1004
|
-
rb_p(header_str);
|
1040
|
+
//rb_p(header_str);
|
1005
1041
|
|
1006
1042
|
*list = curl_slist_append(*list, StringValuePtr(header_str));
|
1007
1043
|
return header_str;
|
@@ -1108,6 +1144,7 @@ static VALUE handle_perform(ruby_curl_easy *rbce) {
|
|
1108
1144
|
curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, rbce->proxy_tunnel);
|
1109
1145
|
curl_easy_setopt(curl, CURLOPT_FILETIME, rbce->fetch_file_time);
|
1110
1146
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, rbce->ssl_verify_peer);
|
1147
|
+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, rbce->ssl_verify_peer);
|
1111
1148
|
|
1112
1149
|
if ((rbce->use_netrc != Qnil) && (rbce->use_netrc != Qfalse)) {
|
1113
1150
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, CURL_NETRC_OPTIONAL);
|
@@ -1263,8 +1300,9 @@ static VALUE ruby_curl_easy_perform_get(VALUE self) {
|
|
1263
1300
|
* easy.perform => true
|
1264
1301
|
*
|
1265
1302
|
* Transfer the currently configured URL using the options set for this
|
1266
|
-
* Curl::Easy instance. If this is
|
1267
|
-
* the GET request method.
|
1303
|
+
* Curl::Easy instance. If this is an HTTP URL, it will be transferred via
|
1304
|
+
* the GET request method (i.e. this method is a synonym for +http_get+
|
1305
|
+
* when using HTTP URLs).
|
1268
1306
|
*/
|
1269
1307
|
static VALUE ruby_curl_easy_perform(VALUE self) {
|
1270
1308
|
return ruby_curl_easy_perform_get(self);
|
@@ -1861,7 +1899,7 @@ static VALUE ruby_curl_easy_os_errno_get(VALUE self) {
|
|
1861
1899
|
|
1862
1900
|
/*
|
1863
1901
|
* call-seq:
|
1864
|
-
* easy.
|
1902
|
+
* easy.num_connects => integer
|
1865
1903
|
*
|
1866
1904
|
* Retrieve the number of new connections libcurl had to create to achieve
|
1867
1905
|
* the previous transfer (only the successful connects are counted).
|
@@ -2041,10 +2079,10 @@ static VALUE ruby_curl_easy_class_perform_get(int argc, VALUE *argv, VALUE klass
|
|
2041
2079
|
|
2042
2080
|
/*
|
2043
2081
|
* call-seq:
|
2044
|
-
* Curl::Easy.http_post("
|
2045
|
-
* Curl::Easy.http_post("
|
2046
|
-
* Curl::Easy.http_post("
|
2047
|
-
* Curl::Easy.http_post(Curl::PostField, Curl::PostField ..., Curl::PostField) => true
|
2082
|
+
* Curl::Easy.http_post(url, "some=urlencoded%20form%20data&and=so%20on") => true
|
2083
|
+
* Curl::Easy.http_post(url, "some=urlencoded%20form%20data", "and=so%20on", ...) => true
|
2084
|
+
* Curl::Easy.http_post(url, "some=urlencoded%20form%20data", Curl::PostField, "and=so%20on", ...) => true
|
2085
|
+
* Curl::Easy.http_post(url, Curl::PostField, Curl::PostField ..., Curl::PostField) => true
|
2048
2086
|
*
|
2049
2087
|
* POST the specified formdata to the currently configured URL using
|
2050
2088
|
* the current options set for this Curl::Easy instance. This method
|
@@ -2133,6 +2171,8 @@ void init_curb_easy() {
|
|
2133
2171
|
rb_define_method(cCurlEasy, "fetch_file_time?", ruby_curl_easy_fetch_file_time_q, 0);
|
2134
2172
|
rb_define_method(cCurlEasy, "ssl_verify_peer=", ruby_curl_easy_ssl_verify_peer_set, 1);
|
2135
2173
|
rb_define_method(cCurlEasy, "ssl_verify_peer?", ruby_curl_easy_ssl_verify_peer_q, 0);
|
2174
|
+
rb_define_method(cCurlEasy, "ssl_verify_host=", ruby_curl_easy_ssl_verify_host_set, 1);
|
2175
|
+
rb_define_method(cCurlEasy, "ssl_verify_host?", ruby_curl_easy_ssl_verify_host_q, 0);
|
2136
2176
|
rb_define_method(cCurlEasy, "header_in_body=", ruby_curl_easy_header_in_body_set, 1);
|
2137
2177
|
rb_define_method(cCurlEasy, "header_in_body?", ruby_curl_easy_header_in_body_q, 0);
|
2138
2178
|
rb_define_method(cCurlEasy, "use_netrc=", ruby_curl_easy_use_netrc_set, 1);
|
data/ext/curb_easy.h
CHANGED
data/tests/tc_curl_easy.rb
CHANGED
@@ -378,9 +378,16 @@ class TestCurbCurlEasy < Test::Unit::TestCase
|
|
378
378
|
|
379
379
|
def test_ssl_verify_peer
|
380
380
|
c = Curl::Easy.new
|
381
|
-
assert !c.ssl_verify_peer?
|
382
|
-
assert c.ssl_verify_peer = true
|
383
381
|
assert c.ssl_verify_peer?
|
382
|
+
assert !c.ssl_verify_peer = false
|
383
|
+
assert !c.ssl_verify_peer?
|
384
|
+
end
|
385
|
+
|
386
|
+
def test_ssl_verify_host
|
387
|
+
c = Curl::Easy.new
|
388
|
+
assert c.ssl_verify_host?
|
389
|
+
assert !c.ssl_verify_host = false
|
390
|
+
assert !c.ssl_verify_host?
|
384
391
|
end
|
385
392
|
|
386
393
|
def test_header_in_body
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: curb
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.1.4
|
7
|
+
date: 2007-08-08 00:00:00 +01:00
|
8
8
|
summary: Ruby bindings for the libcurl(3) URL transfer library.
|
9
9
|
require_paths:
|
10
10
|
- lib
|