curb 0.1.0
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/LICENSE +51 -0
- data/README +106 -0
- data/Rakefile +302 -0
- data/doc.rb +42 -0
- data/ext/curb.c +333 -0
- data/ext/curb.h +39 -0
- data/ext/curb.rb +46 -0
- data/ext/curb_easy.c +2138 -0
- data/ext/curb_easy.h +73 -0
- data/ext/curb_errors.c +471 -0
- data/ext/curb_errors.h +106 -0
- data/ext/curb_macros.h +114 -0
- data/ext/curb_postfield.c +499 -0
- data/ext/curb_postfield.h +40 -0
- data/ext/curl.rb +2 -0
- data/ext/extconf.rb +24 -0
- data/samples/gmail.rb +46 -0
- data/tests/alltests.rb +3 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +53 -0
- data/tests/bug_require_last_or_segfault.rb +40 -0
- data/tests/helper.rb +15 -0
- data/tests/require_last_or_segfault_script.rb +36 -0
- data/tests/tc_curl_easy.rb +415 -0
- data/tests/tc_curl_postfield.rb +141 -0
- data/tests/unittests.rb +2 -0
- metadata +80 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
/* curb_postfield.h - Field class for POST method
|
2
|
+
* Copyright (c)2006 Ross Bamford.
|
3
|
+
* Licensed under the Ruby License. See LICENSE for details.
|
4
|
+
*
|
5
|
+
* $Id: curb_postfield.h 4 2006-11-17 18:35:31Z roscopeco $
|
6
|
+
*/
|
7
|
+
#ifndef __CURB_POSTFIELD_H
|
8
|
+
#define __CURB_POSTFIELD_H
|
9
|
+
|
10
|
+
#include "curb.h"
|
11
|
+
|
12
|
+
/*
|
13
|
+
* postfield doesn't actually wrap a curl_httppost - instead,
|
14
|
+
* it just holds together some ruby objects and has a C-side
|
15
|
+
* method to add it to a given form list during the perform.
|
16
|
+
*/
|
17
|
+
typedef struct {
|
18
|
+
/* Objects we associate */
|
19
|
+
VALUE name;
|
20
|
+
VALUE content;
|
21
|
+
VALUE content_type;
|
22
|
+
VALUE content_proc;
|
23
|
+
VALUE local_file;
|
24
|
+
VALUE remote_file;
|
25
|
+
|
26
|
+
/* this will sometimes hold a string, which is the result
|
27
|
+
* of the content_proc invocation. We need it to hang around.
|
28
|
+
*/
|
29
|
+
VALUE buffer_str;
|
30
|
+
} ruby_curl_postfield;
|
31
|
+
|
32
|
+
extern VALUE cCurlPostField;
|
33
|
+
|
34
|
+
void append_to_form(VALUE self,
|
35
|
+
struct curl_httppost **first,
|
36
|
+
struct curl_httppost **last);
|
37
|
+
|
38
|
+
void init_curb_postfield();
|
39
|
+
|
40
|
+
#endif
|
data/ext/curl.rb
ADDED
data/ext/extconf.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
dir_config('curl')
|
4
|
+
|
5
|
+
unless have_library('curl') &&
|
6
|
+
have_header('curl/curl.h')
|
7
|
+
fail <<-EOM
|
8
|
+
Can't find libcurl or curl/curl.h
|
9
|
+
|
10
|
+
Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
|
11
|
+
options to extconf.
|
12
|
+
EOM
|
13
|
+
end
|
14
|
+
|
15
|
+
#install_rb("curb.rb", "$(RUBYLIBDIR)", '../lib')
|
16
|
+
#install_rb("curl.rb", "$(RUBYLIBDIR)", '../lib')
|
17
|
+
$INSTALLFILES = [["curb.rb", "$(RUBYLIBDIR)", "../ext"], ["curl.rb", "$(RUBYLIBDIR)", "../ext"]]
|
18
|
+
|
19
|
+
if try_compile('int main() { return 0; }','-Wall')
|
20
|
+
$CFLAGS << ' -Wall'
|
21
|
+
end
|
22
|
+
|
23
|
+
create_makefile('curb_core')
|
24
|
+
|
data/samples/gmail.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# This logs into gmail, up to the point where it hits the
|
2
|
+
# security redirect implemented as a refresh. It will probably
|
3
|
+
# stop working altogether when they next change gmail but
|
4
|
+
# it's still an example of posting with curb...
|
5
|
+
|
6
|
+
require '../curb'
|
7
|
+
|
8
|
+
$EMAIL = '<YOUR GMAIL LOGIN>'
|
9
|
+
$PASSWD = '<YOUR GMAIL PASSWORD>'
|
10
|
+
|
11
|
+
url = 'https://www.google.com/accounts/ServiceLoginAuth'
|
12
|
+
|
13
|
+
fields = [
|
14
|
+
Curl::PostField.content('ltmpl','m_blanco'),
|
15
|
+
Curl::PostField.content('ltmplcache', '2'),
|
16
|
+
Curl::PostField.content('continue',
|
17
|
+
'http://mail.google.com/mail/?ui.html&zy=l'),
|
18
|
+
Curl::PostField.content('service', 'mail'),
|
19
|
+
Curl::PostField.content('rm', 'false'),
|
20
|
+
Curl::PostField.content('rmShown', '1'),
|
21
|
+
Curl::PostField.content('PersistentCookie', ''),
|
22
|
+
Curl::PostField.content('Email', $EMAIL),
|
23
|
+
Curl::PostField.content('Passwd', $PASSWD)
|
24
|
+
]
|
25
|
+
|
26
|
+
c = Curl::Easy.http_post(url, *fields) do |curl|
|
27
|
+
# Gotta put yourself out there...
|
28
|
+
curl.headers["User-Agent"] = "Curl/Ruby"
|
29
|
+
|
30
|
+
# Let's see what happens under the hood
|
31
|
+
curl.verbose = true
|
32
|
+
|
33
|
+
# Google will redirect us a bit
|
34
|
+
curl.follow_location = true
|
35
|
+
|
36
|
+
# Google will make sure we retain cookies
|
37
|
+
curl.enable_cookies = true
|
38
|
+
end
|
39
|
+
|
40
|
+
puts "FINISHED: HTTP #{c.response_code}"
|
41
|
+
puts c.body_str
|
42
|
+
|
43
|
+
# As an alternative to passing the PostFields, we could have supplied
|
44
|
+
# individual pre-encoded option strings, or a single string with the
|
45
|
+
# entire form data.
|
46
|
+
|
data/tests/alltests.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# From Vlad Jebelev:
|
2
|
+
#
|
3
|
+
# - Second thing - I think you just probably didn't have the time to update
|
4
|
+
# instance methods yet but when I POST with a reusal of a previous curl
|
5
|
+
# instance, it doesnt' work for me, e.g. when I create a curl previously and
|
6
|
+
# then issue:
|
7
|
+
#
|
8
|
+
# c.http_post(login_url, *fields)
|
9
|
+
#
|
10
|
+
# instead of:
|
11
|
+
#
|
12
|
+
# c = Curl::Easy.http_post(login_url, *fields) do |curl|
|
13
|
+
# ...
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# then the result I am getting is quite different.
|
17
|
+
#
|
18
|
+
# ================
|
19
|
+
#
|
20
|
+
# Update:
|
21
|
+
#
|
22
|
+
# It seems that class httpost is incorrectly passing arguments down to
|
23
|
+
# instance httppost. This bug is intermittent, but results in an
|
24
|
+
# exception from the first post when it occurs.
|
25
|
+
#
|
26
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
27
|
+
|
28
|
+
class BugTestInstancePostDiffersFromClassPost < Test::Unit::TestCase
|
29
|
+
def test_bug
|
30
|
+
5.times do |i|
|
31
|
+
puts "Test ##{i}"
|
32
|
+
do_test
|
33
|
+
sleep 2
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def do_test
|
38
|
+
c = Curl::Easy.http_post('https://www.google.com/accounts/ServiceLoginAuth',
|
39
|
+
Curl::PostField.content('ltmpl','m_blanco'))
|
40
|
+
body_c, header_c = c.body_str, c.header_str
|
41
|
+
|
42
|
+
sleep 2
|
43
|
+
|
44
|
+
c.http_post('https://www.google.com/accounts/ServiceLoginAuth',
|
45
|
+
Curl::PostField.content('ltmpl','m_blanco'))
|
46
|
+
body_i, header_i = c.body_str, c.header_str
|
47
|
+
|
48
|
+
# timestamps will differ, just check first bit. We wont get here if
|
49
|
+
# the bug bites anyway...
|
50
|
+
assert_equal header_c[0..50], header_i[0..50]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# From Vlad Jebelev:
|
2
|
+
#
|
3
|
+
# - if I have a require statement after "require 'curb'" and there is a
|
4
|
+
# POST with at least 1 field, the script will fail with a segmentation
|
5
|
+
# fault, e.g. the following sequence fails every time for me (Ruby 1.8.5):
|
6
|
+
# -----------------------------------------------------------------
|
7
|
+
# require 'curb'
|
8
|
+
# require 'uri'
|
9
|
+
#
|
10
|
+
# url = 'https://www.google.com/accounts/ServiceLoginAuth'
|
11
|
+
#
|
12
|
+
# c = Curl::Easy.http_post(
|
13
|
+
# 'https://www.google.com/accounts/ServiceLoginAuth',
|
14
|
+
# [Curl:: PostField.content('ltmpl','m_blanco')] ) do |curl|
|
15
|
+
# end
|
16
|
+
# ------------------------------------------------------------------
|
17
|
+
# :..dev/util$ ruby seg.rb
|
18
|
+
# seg.rb:6: [BUG] Segmentation fault
|
19
|
+
# ruby 1.8.5 (2006-08-25) [i686-linux]
|
20
|
+
#
|
21
|
+
# Aborted
|
22
|
+
# ------------------------------------------------------------------
|
23
|
+
#
|
24
|
+
require 'test/unit'
|
25
|
+
require 'rbconfig'
|
26
|
+
|
27
|
+
$rubycmd = Config::CONFIG['RUBY_INSTALL_NAME'] || 'ruby'
|
28
|
+
|
29
|
+
class BugTestRequireLastOrSegfault < Test::Unit::TestCase
|
30
|
+
def test_bug
|
31
|
+
5.times do |i|
|
32
|
+
puts "Test ##{i}"
|
33
|
+
|
34
|
+
# will be empty string if it segfaults...
|
35
|
+
assert_equal 'success', `#$rubycmd #{File.dirname(__FILE__)}/require_last_or_segfault_script.rb`.chomp
|
36
|
+
sleep 5
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
data/tests/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# DO NOT REMOVE THIS COMMENT - PART OF TESTMODEL.
|
2
|
+
# Copyright (c)2006 Ross Bamford. See LICENSE.
|
3
|
+
$CURB_TESTING = true
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
$TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
7
|
+
$EXTDIR = File.join($TOPDIR, 'ext')
|
8
|
+
$LIBDIR = File.join($TOPDIR, 'lib')
|
9
|
+
$:.unshift($LIBDIR)
|
10
|
+
$:.unshift($EXTDIR)
|
11
|
+
|
12
|
+
require 'curb'
|
13
|
+
require 'test/unit'
|
14
|
+
|
15
|
+
$TEST_URL = "file://#{URI.escape(File.expand_path(__FILE__).tr('\\','/').tr(':','|'))}"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# From Vlad Jebelev:
|
2
|
+
#
|
3
|
+
# - if I have a require statement after "require 'curb'" and there is a
|
4
|
+
# POST with at least 1 field, the script will fail with a segmentation
|
5
|
+
# fault, e.g. the following sequence fails every time for me (Ruby 1.8.5):
|
6
|
+
# -----------------------------------------------------------------
|
7
|
+
# require 'curb'
|
8
|
+
# require 'uri'
|
9
|
+
#
|
10
|
+
# url = 'https://www.google.com/accounts/ServiceLoginAuth'
|
11
|
+
#
|
12
|
+
# c = Curl::Easy.http_post(
|
13
|
+
# 'https://www.google.com/accounts/ServiceLoginAuth',
|
14
|
+
# [Curl:: PostField.content('ltmpl','m_blanco')] ) do |curl|
|
15
|
+
# end
|
16
|
+
# ------------------------------------------------------------------
|
17
|
+
# :..dev/util$ ruby seg.rb
|
18
|
+
# seg.rb:6: [BUG] Segmentation fault
|
19
|
+
# ruby 1.8.5 (2006-08-25) [i686-linux]
|
20
|
+
#
|
21
|
+
# Aborted
|
22
|
+
# ------------------------------------------------------------------
|
23
|
+
#
|
24
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'ext'))
|
25
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
26
|
+
require 'curb'
|
27
|
+
require 'uri'
|
28
|
+
|
29
|
+
url = 'https://www.google.com/accounts/ServiceLoginAuth'
|
30
|
+
|
31
|
+
c = Curl::Easy.http_post('https://www.google.com/accounts/ServiceLoginAuth',
|
32
|
+
Curl:: PostField.content('ltmpl','m_blanco')) #do
|
33
|
+
# end
|
34
|
+
|
35
|
+
puts "success"
|
36
|
+
|
@@ -0,0 +1,415 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'helper')
|
2
|
+
|
3
|
+
class TestCurbCurlEasy < Test::Unit::TestCase
|
4
|
+
def test_class_perform_01
|
5
|
+
assert_instance_of Curl::Easy, c = Curl::Easy.perform($TEST_URL)
|
6
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
|
7
|
+
assert_equal "", c.header_str
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_class_perform_02
|
11
|
+
data = ""
|
12
|
+
assert_instance_of Curl::Easy, c = Curl::Easy.perform($TEST_URL) { |curl| curl.on_body { |d| data << d; d.length } }
|
13
|
+
|
14
|
+
assert_nil c.body_str
|
15
|
+
assert_equal "", c.header_str
|
16
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, data)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_class_perform_03
|
20
|
+
assert_raise(Curl::Err::CouldntReadError) { c = Curl::Easy.perform($TEST_URL + "nonexistent") }
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_new_01
|
24
|
+
c = Curl::Easy.new
|
25
|
+
assert_nil c.url
|
26
|
+
assert_nil c.body_str
|
27
|
+
assert_nil c.header_str
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_new_02
|
31
|
+
c = Curl::Easy.new($TEST_URL)
|
32
|
+
assert_equal $TEST_URL, c.url
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_new_03
|
36
|
+
blk = lambda { |i| i.length }
|
37
|
+
|
38
|
+
c = Curl::Easy.new do |curl|
|
39
|
+
curl.on_body(&blk)
|
40
|
+
end
|
41
|
+
|
42
|
+
assert_nil c.url
|
43
|
+
assert_equal blk, c.on_body # sets handler nil, returns old handler
|
44
|
+
assert_equal nil, c.on_body
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_new_04
|
48
|
+
blk = lambda { |i| i.length }
|
49
|
+
|
50
|
+
c = Curl::Easy.new($TEST_URL) do |curl|
|
51
|
+
curl.on_body(&blk)
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_equal $TEST_URL, c.url
|
55
|
+
assert_equal blk, c.on_body # sets handler nil, returns old handler
|
56
|
+
assert_equal nil, c.on_body
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_escape
|
60
|
+
c = Curl::Easy.new
|
61
|
+
|
62
|
+
assert_equal "one%20two", c.escape('one two')
|
63
|
+
assert_equal "one%00two%20three", c.escape("one\000two three")
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_unescape
|
67
|
+
c = Curl::Easy.new
|
68
|
+
|
69
|
+
assert_equal "one two", c.unescape('one%20two')
|
70
|
+
assert_equal "one\000two three", c.unescape("one%00two%20three")
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_headers
|
74
|
+
c = Curl::Easy.new($TEST_URL)
|
75
|
+
|
76
|
+
assert_equal({}, c.headers)
|
77
|
+
c.headers = "Expect:"
|
78
|
+
assert_equal "Expect:", c.headers
|
79
|
+
c.headers = ["Expect:", "User-Agent: myapp-0.0.0"]
|
80
|
+
assert_equal ["Expect:", "User-Agent: myapp-0.0.0"], c.headers
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_get_01
|
84
|
+
c = Curl::Easy.new($TEST_URL)
|
85
|
+
assert_equal true, c.http_get
|
86
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
|
87
|
+
assert_equal "", c.header_str
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_get_02
|
91
|
+
data = ""
|
92
|
+
c = Curl::Easy.new($TEST_URL) do |curl|
|
93
|
+
curl.on_body { |d| data << d; d.length }
|
94
|
+
end
|
95
|
+
|
96
|
+
assert_equal true, c.http_get
|
97
|
+
|
98
|
+
assert_nil c.body_str
|
99
|
+
assert_equal "", c.header_str
|
100
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, data)
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_get_03
|
104
|
+
c = Curl::Easy.new($TEST_URL + "nonexistent")
|
105
|
+
assert_raise(Curl::Err::CouldntReadError) { c.http_get }
|
106
|
+
assert_equal "", c.body_str
|
107
|
+
assert_equal "", c.header_str
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_last_effective_url_01
|
111
|
+
c = Curl::Easy.new($TEST_URL)
|
112
|
+
|
113
|
+
assert_equal $TEST_URL, c.url
|
114
|
+
assert_nil c.last_effective_url
|
115
|
+
|
116
|
+
assert c.http_get
|
117
|
+
|
118
|
+
assert_equal c.url, c.last_effective_url
|
119
|
+
c.url = "file://some/new.url"
|
120
|
+
|
121
|
+
assert_not_equal c.last_effective_url, c.url
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_local_port_01
|
125
|
+
c = Curl::Easy.new($TEST_URL)
|
126
|
+
|
127
|
+
assert_nil c.local_port
|
128
|
+
assert_nil c.local_port_range
|
129
|
+
assert_nil c.proxy_port
|
130
|
+
|
131
|
+
c.local_port = 88
|
132
|
+
|
133
|
+
assert_equal 88, c.local_port
|
134
|
+
assert_nil c.local_port_range
|
135
|
+
assert_nil c.proxy_port
|
136
|
+
|
137
|
+
c.local_port = nil
|
138
|
+
|
139
|
+
assert_nil c.local_port
|
140
|
+
assert_nil c.local_port_range
|
141
|
+
assert_nil c.proxy_port
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_local_port_02
|
145
|
+
c = Curl::Easy.new($TEST_URL)
|
146
|
+
|
147
|
+
assert_nil c.local_port
|
148
|
+
assert_raise(ArgumentError) { c.local_port = 0 }
|
149
|
+
assert_raise(ArgumentError) { c.local_port = 65536 }
|
150
|
+
assert_raise(ArgumentError) { c.local_port = -1 }
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_local_port_range_01
|
154
|
+
c = Curl::Easy.new($TEST_URL)
|
155
|
+
|
156
|
+
assert_nil c.local_port_range
|
157
|
+
assert_nil c.local_port
|
158
|
+
assert_nil c.proxy_port
|
159
|
+
|
160
|
+
c.local_port_range = 88
|
161
|
+
assert_equal 88, c.local_port_range
|
162
|
+
assert_nil c.local_port
|
163
|
+
assert_nil c.proxy_port
|
164
|
+
|
165
|
+
c.local_port_range = nil
|
166
|
+
|
167
|
+
assert_nil c.local_port_range
|
168
|
+
assert_nil c.local_port
|
169
|
+
assert_nil c.proxy_port
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_local_port_range_02
|
173
|
+
c = Curl::Easy.new($TEST_URL)
|
174
|
+
|
175
|
+
assert_nil c.local_port_range
|
176
|
+
assert_raise(ArgumentError) { c.local_port_range = 0 }
|
177
|
+
assert_raise(ArgumentError) { c.local_port_range = 65536 }
|
178
|
+
assert_raise(ArgumentError) { c.local_port_range = -1 }
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_proxy_port_01
|
182
|
+
c = Curl::Easy.new($TEST_URL)
|
183
|
+
|
184
|
+
assert_nil c.local_port
|
185
|
+
assert_nil c.local_port_range
|
186
|
+
assert_nil c.proxy_port
|
187
|
+
|
188
|
+
c.proxy_port = 88
|
189
|
+
|
190
|
+
assert_equal 88, c.proxy_port
|
191
|
+
assert_nil c.local_port
|
192
|
+
assert_nil c.local_port_range
|
193
|
+
|
194
|
+
c.proxy_port = nil
|
195
|
+
assert_nil c.proxy_port
|
196
|
+
assert_nil c.local_port
|
197
|
+
assert_nil c.local_port_range
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_proxy_port_02
|
201
|
+
c = Curl::Easy.new($TEST_URL)
|
202
|
+
|
203
|
+
assert_nil c.proxy_port
|
204
|
+
assert_raise(ArgumentError) { c.proxy_port = 0 }
|
205
|
+
assert_raise(ArgumentError) { c.proxy_port = 65536 }
|
206
|
+
assert_raise(ArgumentError) { c.proxy_port = -1 }
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_proxy_type_01
|
210
|
+
c = Curl::Easy.new($TEST_URL)
|
211
|
+
|
212
|
+
assert_nil c.proxy_type
|
213
|
+
|
214
|
+
c.proxy_type = 3
|
215
|
+
assert_equal 3, c.proxy_type
|
216
|
+
|
217
|
+
c.proxy_type = nil
|
218
|
+
assert_nil c.proxy_type
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_http_auth_types_01
|
222
|
+
c = Curl::Easy.new($TEST_URL)
|
223
|
+
|
224
|
+
assert_nil c.http_auth_types
|
225
|
+
|
226
|
+
c.http_auth_types = 3
|
227
|
+
assert_equal 3, c.http_auth_types
|
228
|
+
|
229
|
+
c.http_auth_types = nil
|
230
|
+
assert_nil c.http_auth_types
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_proxy_auth_types_01
|
234
|
+
c = Curl::Easy.new($TEST_URL)
|
235
|
+
|
236
|
+
assert_nil c.proxy_auth_types
|
237
|
+
|
238
|
+
c.proxy_auth_types = 3
|
239
|
+
assert_equal 3, c.proxy_auth_types
|
240
|
+
|
241
|
+
c.proxy_auth_types = nil
|
242
|
+
assert_nil c.proxy_auth_types
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_max_redirects_01
|
246
|
+
c = Curl::Easy.new($TEST_URL)
|
247
|
+
|
248
|
+
assert_nil c.max_redirects
|
249
|
+
|
250
|
+
c.max_redirects = 3
|
251
|
+
assert_equal 3, c.max_redirects
|
252
|
+
|
253
|
+
c.max_redirects = nil
|
254
|
+
assert_nil c.max_redirects
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_timeout_01
|
258
|
+
c = Curl::Easy.new($TEST_URL)
|
259
|
+
|
260
|
+
assert_nil c.timeout
|
261
|
+
|
262
|
+
c.timeout = 3
|
263
|
+
assert_equal 3, c.timeout
|
264
|
+
|
265
|
+
c.timeout = nil
|
266
|
+
assert_nil c.timeout
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_connect_timeout_01
|
270
|
+
c = Curl::Easy.new($TEST_URL)
|
271
|
+
|
272
|
+
assert_nil c.connect_timeout
|
273
|
+
|
274
|
+
c.connect_timeout = 3
|
275
|
+
assert_equal 3, c.connect_timeout
|
276
|
+
|
277
|
+
c.connect_timeout = nil
|
278
|
+
assert_nil c.connect_timeout
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_ftp_response_timeout_01
|
282
|
+
c = Curl::Easy.new($TEST_URL)
|
283
|
+
|
284
|
+
assert_nil c.ftp_response_timeout
|
285
|
+
|
286
|
+
c.ftp_response_timeout = 3
|
287
|
+
assert_equal 3, c.ftp_response_timeout
|
288
|
+
|
289
|
+
c.ftp_response_timeout = nil
|
290
|
+
assert_nil c.ftp_response_timeout
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_dns_cache_timeout_01
|
294
|
+
c = Curl::Easy.new($TEST_URL)
|
295
|
+
|
296
|
+
assert_equal 60, c.dns_cache_timeout
|
297
|
+
|
298
|
+
c.dns_cache_timeout = nil
|
299
|
+
assert_nil c.dns_cache_timeout
|
300
|
+
|
301
|
+
c.dns_cache_timeout = 30
|
302
|
+
assert_equal 30, c.dns_cache_timeout
|
303
|
+
end
|
304
|
+
|
305
|
+
def test_on_body
|
306
|
+
blk = lambda { |i| i.length }
|
307
|
+
|
308
|
+
c = Curl::Easy.new
|
309
|
+
c.on_body(&blk)
|
310
|
+
|
311
|
+
assert_equal blk, c.on_body # sets handler nil, returns old handler
|
312
|
+
assert_equal nil, c.on_body
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_on_header
|
316
|
+
blk = lambda { |i| i.length }
|
317
|
+
|
318
|
+
c = Curl::Easy.new
|
319
|
+
c.on_header(&blk)
|
320
|
+
|
321
|
+
assert_equal blk, c.on_header # sets handler nil, returns old handler
|
322
|
+
assert_equal nil, c.on_header
|
323
|
+
end
|
324
|
+
|
325
|
+
def test_on_progress
|
326
|
+
blk = lambda { |*args| true }
|
327
|
+
|
328
|
+
c = Curl::Easy.new
|
329
|
+
c.on_progress(&blk)
|
330
|
+
|
331
|
+
assert_equal blk, c.on_progress # sets handler nil, returns old handler
|
332
|
+
assert_equal nil, c.on_progress
|
333
|
+
end
|
334
|
+
|
335
|
+
def test_on_debug
|
336
|
+
blk = lambda { |*args| true }
|
337
|
+
|
338
|
+
c = Curl::Easy.new
|
339
|
+
c.on_debug(&blk)
|
340
|
+
|
341
|
+
assert_equal blk, c.on_debug # sets handler nil, returns old handler
|
342
|
+
assert_equal nil, c.on_debug
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_proxy_tunnel
|
346
|
+
c = Curl::Easy.new
|
347
|
+
assert !c.proxy_tunnel?
|
348
|
+
assert c.proxy_tunnel = true
|
349
|
+
assert c.proxy_tunnel?
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_fetch_file_time
|
353
|
+
c = Curl::Easy.new
|
354
|
+
assert !c.fetch_file_time?
|
355
|
+
assert c.fetch_file_time = true
|
356
|
+
assert c.fetch_file_time?
|
357
|
+
end
|
358
|
+
|
359
|
+
def test_ssl_verify_peer
|
360
|
+
c = Curl::Easy.new
|
361
|
+
assert !c.ssl_verify_peer?
|
362
|
+
assert c.ssl_verify_peer = true
|
363
|
+
assert c.ssl_verify_peer?
|
364
|
+
end
|
365
|
+
|
366
|
+
def test_header_in_body
|
367
|
+
c = Curl::Easy.new
|
368
|
+
assert !c.header_in_body?
|
369
|
+
assert c.header_in_body = true
|
370
|
+
assert c.header_in_body?
|
371
|
+
end
|
372
|
+
|
373
|
+
def test_use_netrc
|
374
|
+
c = Curl::Easy.new
|
375
|
+
assert !c.use_netrc?
|
376
|
+
assert c.use_netrc = true
|
377
|
+
assert c.use_netrc?
|
378
|
+
end
|
379
|
+
|
380
|
+
def test_follow_location
|
381
|
+
c = Curl::Easy.new
|
382
|
+
assert !c.follow_location?
|
383
|
+
assert c.follow_location = true
|
384
|
+
assert c.follow_location?
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_unrestricted_auth
|
388
|
+
c = Curl::Easy.new
|
389
|
+
assert !c.unrestricted_auth?
|
390
|
+
assert c.unrestricted_auth = true
|
391
|
+
assert c.unrestricted_auth?
|
392
|
+
end
|
393
|
+
|
394
|
+
def test_multipart_form_post
|
395
|
+
c = Curl::Easy.new
|
396
|
+
assert !c.multipart_form_post?
|
397
|
+
assert c.multipart_form_post = true
|
398
|
+
assert c.multipart_form_post?
|
399
|
+
end
|
400
|
+
|
401
|
+
def test_enable_cookies
|
402
|
+
c = Curl::Easy.new
|
403
|
+
assert !c.enable_cookies?
|
404
|
+
assert c.enable_cookies = true
|
405
|
+
assert c.enable_cookies?
|
406
|
+
end
|
407
|
+
|
408
|
+
def test_cookiejar
|
409
|
+
c = Curl::Easy.new
|
410
|
+
assert_nil c.cookiejar
|
411
|
+
assert_equal "some.file", c.cookiejar = "some.file"
|
412
|
+
assert_equal "some.file", c.cookiejar
|
413
|
+
end
|
414
|
+
|
415
|
+
end
|