curb 0.5.8.0-x86-linux
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 +157 -0
- data/Rakefile +297 -0
- data/doc.rb +42 -0
- data/ext/curb.c +339 -0
- data/ext/curb.h +50 -0
- data/ext/curb.o +0 -0
- data/ext/curb_core.so +0 -0
- data/ext/curb_easy.c +2932 -0
- data/ext/curb_easy.h +103 -0
- data/ext/curb_easy.o +0 -0
- data/ext/curb_errors.c +630 -0
- data/ext/curb_errors.h +128 -0
- data/ext/curb_errors.o +0 -0
- data/ext/curb_macros.h +114 -0
- data/ext/curb_multi.c +487 -0
- data/ext/curb_multi.h +26 -0
- data/ext/curb_multi.o +0 -0
- data/ext/curb_postfield.c +511 -0
- data/ext/curb_postfield.h +40 -0
- data/ext/curb_postfield.o +0 -0
- data/ext/curb_upload.c +80 -0
- data/ext/curb_upload.h +30 -0
- data/ext/curb_upload.o +0 -0
- data/ext/extconf.rb +162 -0
- data/lib/curb.rb +184 -0
- data/lib/curl.rb +2 -0
- data/tests/alltests.rb +3 -0
- data/tests/bug_curb_easy_blocks_ruby_threads.rb +52 -0
- data/tests/bug_instance_post_differs_from_class_post.rb +53 -0
- data/tests/bug_multi_segfault.rb +10 -0
- data/tests/bug_require_last_or_segfault.rb +40 -0
- data/tests/helper.rb +168 -0
- data/tests/require_last_or_segfault_script.rb +36 -0
- data/tests/tc_curl_download.rb +32 -0
- data/tests/tc_curl_easy.rb +664 -0
- data/tests/tc_curl_multi.rb +421 -0
- data/tests/tc_curl_postfield.rb +141 -0
- data/tests/unittests.rb +2 -0
- metadata +96 -0
data/lib/curl.rb
ADDED
data/tests/alltests.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
|
+
require 'webrick'
|
3
|
+
class ::WEBrick::HTTPServer ; def access_log(config, req, res) ; end ; end
|
4
|
+
class ::WEBrick::BasicLog ; def log(level, data) ; end ; end
|
5
|
+
|
6
|
+
class BugTestInstancePostDiffersFromClassPost < Test::Unit::TestCase
|
7
|
+
def test_bug
|
8
|
+
server = WEBrick::HTTPServer.new( :Port => 9999 )
|
9
|
+
server.mount_proc("/test") do|req,res|
|
10
|
+
sleep 0.5
|
11
|
+
res.body = "hi"
|
12
|
+
res['Content-Type'] = "text/html"
|
13
|
+
end
|
14
|
+
|
15
|
+
thread = Thread.new(server) do|srv|
|
16
|
+
srv.start
|
17
|
+
end
|
18
|
+
|
19
|
+
threads = []
|
20
|
+
timer = Time.now
|
21
|
+
|
22
|
+
5.times do |i|
|
23
|
+
t = Thread.new do
|
24
|
+
c = Curl::Easy.perform('http://localhost:9999/test')
|
25
|
+
c.header_str
|
26
|
+
end
|
27
|
+
threads << t
|
28
|
+
end
|
29
|
+
|
30
|
+
multi_responses = threads.collect do|t|
|
31
|
+
t.value
|
32
|
+
end
|
33
|
+
|
34
|
+
multi_time = (Time.now - timer)
|
35
|
+
puts "requested in #{multi_time}"
|
36
|
+
|
37
|
+
timer = Time.now
|
38
|
+
single_responses = []
|
39
|
+
5.times do |i|
|
40
|
+
c = Curl::Easy.perform('http://localhost:9999/test')
|
41
|
+
single_responses << c.header_str
|
42
|
+
end
|
43
|
+
|
44
|
+
single_time = (Time.now - timer)
|
45
|
+
puts "requested in #{single_time}"
|
46
|
+
|
47
|
+
assert single_time > multi_time
|
48
|
+
|
49
|
+
server.shutdown
|
50
|
+
thread.join
|
51
|
+
end
|
52
|
+
end
|
@@ -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.expand_path(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,10 @@
|
|
1
|
+
# From safis http://github.com/taf2/curb/issues#issue/5
|
2
|
+
# irb: require 'curb'
|
3
|
+
# irb: multi = Curl::Multi.new
|
4
|
+
# irb: exit
|
5
|
+
# <main>:47140: [BUG] Bus Error
|
6
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__),'..','ext'))
|
7
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
|
8
|
+
require 'curb'
|
9
|
+
multi = Curl::Multi.new
|
10
|
+
exit
|
@@ -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,168 @@
|
|
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(':','|'))}"
|
16
|
+
|
17
|
+
require 'thread'
|
18
|
+
require 'webrick'
|
19
|
+
|
20
|
+
# set this to true to avoid testing with multiple threads
|
21
|
+
# or to test with multiple threads set it to false
|
22
|
+
# this is important since, some code paths will change depending
|
23
|
+
# on the presence of multiple threads
|
24
|
+
TEST_SINGLE_THREADED=false
|
25
|
+
|
26
|
+
# keep webrick quiet
|
27
|
+
class ::WEBrick::HTTPServer
|
28
|
+
def access_log(config, req, res)
|
29
|
+
# nop
|
30
|
+
end
|
31
|
+
end
|
32
|
+
class ::WEBrick::BasicLog
|
33
|
+
def log(level, data)
|
34
|
+
# nop
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Simple test server to record number of times a request is sent/recieved of a specific
|
40
|
+
# request type, e.g. GET,POST,PUT,DELETE
|
41
|
+
#
|
42
|
+
class TestServlet < WEBrick::HTTPServlet::AbstractServlet
|
43
|
+
|
44
|
+
def self.port=(p)
|
45
|
+
@port = p
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.port
|
49
|
+
(@port or 9129)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.path
|
53
|
+
'/methods'
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.url
|
57
|
+
"http://127.0.0.1:#{port}#{path}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def respond_with(method,req,res)
|
61
|
+
res.body = method.to_s
|
62
|
+
res['Content-Type'] = "text/plain"
|
63
|
+
end
|
64
|
+
|
65
|
+
def do_GET(req,res)
|
66
|
+
respond_with(:GET,req,res)
|
67
|
+
end
|
68
|
+
|
69
|
+
def do_HEAD(req,res)
|
70
|
+
res['Location'] = "/nonexistent"
|
71
|
+
respond_with(:HEAD, req, res)
|
72
|
+
end
|
73
|
+
|
74
|
+
def do_POST(req,res)
|
75
|
+
if req.body
|
76
|
+
params = {}
|
77
|
+
req.body.split('&').map{|s| k,v=s.split('='); params[k] = v }
|
78
|
+
end
|
79
|
+
if params and params['s'] == '500'
|
80
|
+
res.status = 500
|
81
|
+
else
|
82
|
+
respond_with("POST\n#{req.body}",req,res)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def do_PUT(req,res)
|
87
|
+
res['X-Requested-Content-Type'] = req.content_type
|
88
|
+
respond_with("PUT\n#{req.body}",req,res)
|
89
|
+
end
|
90
|
+
|
91
|
+
def do_DELETE(req,res)
|
92
|
+
respond_with(:DELETE,req,res)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
module TestServerMethods
|
98
|
+
def locked_file
|
99
|
+
File.join(File.dirname(__FILE__),"server_lock-#{@__port}")
|
100
|
+
end
|
101
|
+
|
102
|
+
def server_setup(port=9129,servlet=TestServlet)
|
103
|
+
@__port = port
|
104
|
+
if @server.nil? and !File.exist?(locked_file)
|
105
|
+
|
106
|
+
File.open(locked_file,'w') {|f| f << 'locked' }
|
107
|
+
if TEST_SINGLE_THREADED
|
108
|
+
rd, wr = IO.pipe
|
109
|
+
@__pid = fork do
|
110
|
+
rd.close
|
111
|
+
rd = nil
|
112
|
+
|
113
|
+
# start up a webrick server for testing delete
|
114
|
+
server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => File.expand_path(File.dirname(__FILE__))
|
115
|
+
|
116
|
+
server.mount(servlet.path, servlet)
|
117
|
+
server.mount("/ext", WEBrick::HTTPServlet::FileHandler, File.join(File.dirname(__FILE__),'..','ext'))
|
118
|
+
|
119
|
+
trap("INT") { server.shutdown }
|
120
|
+
GC.start
|
121
|
+
wr.flush
|
122
|
+
wr.close
|
123
|
+
server.start
|
124
|
+
end
|
125
|
+
wr.close
|
126
|
+
rd.read
|
127
|
+
rd.close
|
128
|
+
else
|
129
|
+
# start up a webrick server for testing delete
|
130
|
+
@server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => File.expand_path(File.dirname(__FILE__))
|
131
|
+
|
132
|
+
@server.mount(servlet.path, servlet)
|
133
|
+
@server.mount("/ext", WEBrick::HTTPServlet::FileHandler, File.join(File.dirname(__FILE__),'..','ext'))
|
134
|
+
queue = Queue.new # synchronize the thread startup to the main thread
|
135
|
+
|
136
|
+
@test_thread = Thread.new { queue << 1; @server.start }
|
137
|
+
|
138
|
+
# wait for the queue
|
139
|
+
value = queue.pop
|
140
|
+
if !value
|
141
|
+
STDERR.puts "Failed to startup test server!"
|
142
|
+
exit(1)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
exit_code = lambda do
|
148
|
+
begin
|
149
|
+
if File.exist?(locked_file)
|
150
|
+
File.unlink locked_file
|
151
|
+
if TEST_SINGLE_THREADED
|
152
|
+
Process.kill 'INT', @__pid
|
153
|
+
else
|
154
|
+
@server.shutdown unless @server.nil?
|
155
|
+
end
|
156
|
+
end
|
157
|
+
#@server.shutdown unless @server.nil?
|
158
|
+
rescue Object => e
|
159
|
+
puts "Error #{__FILE__}:#{__LINE__}\n#{e.message}"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
trap("INT"){exit_code.call}
|
164
|
+
at_exit{exit_code.call}
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -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.expand_path(File.join(File.dirname(__FILE__), '..', 'ext')))
|
25
|
+
$:.unshift(File.expand_path(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,32 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
|
+
|
3
|
+
class TestCurbCurlDownload < Test::Unit::TestCase
|
4
|
+
include TestServerMethods
|
5
|
+
|
6
|
+
def setup
|
7
|
+
server_setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_download_url_to_file
|
11
|
+
dl_url = "http://127.0.0.1:9129/ext/curb_easy.c"
|
12
|
+
dl_path = File.join(Dir::tmpdir, "dl_url_test.file")
|
13
|
+
|
14
|
+
curb = Curl::Easy.download(dl_url, dl_path)
|
15
|
+
assert File.exist?(dl_path)
|
16
|
+
assert_equal File.read(File.join(File.dirname(__FILE__), '..','ext','curb_easy.c')), File.read(dl_path)
|
17
|
+
ensure
|
18
|
+
File.unlink(dl_path) if File.exist?(dl_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_download_bad_url_gives_404
|
22
|
+
dl_url = "http://127.0.0.1:9129/this_file_does_not_exist.html"
|
23
|
+
dl_path = File.join(Dir::tmpdir, "dl_url_test.file")
|
24
|
+
|
25
|
+
curb = Curl::Easy.download(dl_url, dl_path)
|
26
|
+
assert_equal Curl::Easy, curb.class
|
27
|
+
assert_equal 404, curb.response_code
|
28
|
+
ensure
|
29
|
+
File.unlink(dl_path) if File.exist?(dl_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,664 @@
|
|
1
|
+
require File.expand_path(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_equal Curl::Easy, c.class
|
26
|
+
assert_nil c.url
|
27
|
+
assert_nil c.body_str
|
28
|
+
assert_nil c.header_str
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_new_02
|
32
|
+
c = Curl::Easy.new($TEST_URL)
|
33
|
+
assert_equal $TEST_URL, c.url
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_new_03
|
37
|
+
blk = lambda { |i| i.length }
|
38
|
+
|
39
|
+
c = Curl::Easy.new do |curl|
|
40
|
+
curl.on_body(&blk)
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_nil c.url
|
44
|
+
assert_equal blk, c.on_body # sets handler nil, returns old handler
|
45
|
+
assert_equal nil, c.on_body
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_new_04
|
49
|
+
blk = lambda { |i| i.length }
|
50
|
+
|
51
|
+
c = Curl::Easy.new($TEST_URL) do |curl|
|
52
|
+
curl.on_body(&blk)
|
53
|
+
end
|
54
|
+
|
55
|
+
assert_equal $TEST_URL, c.url
|
56
|
+
assert_equal blk, c.on_body # sets handler nil, returns old handler
|
57
|
+
assert_equal nil, c.on_body
|
58
|
+
end
|
59
|
+
|
60
|
+
class Foo < Curl::Easy
|
61
|
+
end
|
62
|
+
def test_new_05
|
63
|
+
# can use Curl::Easy as a base class
|
64
|
+
c = Foo.new
|
65
|
+
assert_equal Foo, c.class
|
66
|
+
c.url = $TEST_URL
|
67
|
+
c.perform
|
68
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
|
69
|
+
end
|
70
|
+
|
71
|
+
# test invalid use of new
|
72
|
+
def test_new_06
|
73
|
+
Curl::Easy.new(TestServlet.url) do|curl|
|
74
|
+
curl.http_post
|
75
|
+
assert_equal "POST\n", curl.body_str
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_escape
|
80
|
+
c = Curl::Easy.new
|
81
|
+
|
82
|
+
assert_equal "one%20two", c.escape('one two')
|
83
|
+
assert_equal "one%00two%20three", c.escape("one\000two three")
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_unescape
|
87
|
+
c = Curl::Easy.new
|
88
|
+
|
89
|
+
assert_equal "one two", c.unescape('one%20two')
|
90
|
+
|
91
|
+
# prior to 7.15.4 embedded nulls cannot be unescaped
|
92
|
+
if Curl::VERNUM >= 0x070f04
|
93
|
+
assert_equal "one\000two three", c.unescape("one%00two%20three")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_headers
|
98
|
+
c = Curl::Easy.new($TEST_URL)
|
99
|
+
|
100
|
+
assert_equal({}, c.headers)
|
101
|
+
c.headers = "Expect:"
|
102
|
+
assert_equal "Expect:", c.headers
|
103
|
+
c.headers = ["Expect:", "User-Agent: myapp-0.0.0"]
|
104
|
+
assert_equal ["Expect:", "User-Agent: myapp-0.0.0"], c.headers
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_get_01
|
108
|
+
c = Curl::Easy.new($TEST_URL)
|
109
|
+
assert_equal true, c.http_get
|
110
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
|
111
|
+
assert_equal "", c.header_str
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_get_02
|
115
|
+
data = ""
|
116
|
+
c = Curl::Easy.new($TEST_URL) do |curl|
|
117
|
+
curl.on_body { |d| data << d; d.length }
|
118
|
+
end
|
119
|
+
|
120
|
+
assert_equal true, c.http_get
|
121
|
+
|
122
|
+
assert_nil c.body_str
|
123
|
+
assert_equal "", c.header_str
|
124
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, data)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_get_03
|
128
|
+
c = Curl::Easy.new($TEST_URL + "nonexistent")
|
129
|
+
assert_raise(Curl::Err::CouldntReadError) { c.http_get }
|
130
|
+
assert_equal "", c.body_str
|
131
|
+
assert_equal "", c.header_str
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
def test_last_effective_url_01
|
136
|
+
c = Curl::Easy.new($TEST_URL)
|
137
|
+
|
138
|
+
assert_equal $TEST_URL, c.url
|
139
|
+
assert_nil c.last_effective_url
|
140
|
+
|
141
|
+
assert c.http_get
|
142
|
+
|
143
|
+
assert_equal c.url, c.last_effective_url
|
144
|
+
c.url = "file://some/new.url"
|
145
|
+
|
146
|
+
assert_not_equal c.last_effective_url, c.url
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_http_get_block
|
150
|
+
curl = Curl::Easy.http_get(TestServlet.url) do|c|
|
151
|
+
c.follow_location = true
|
152
|
+
c.max_redirects = 3
|
153
|
+
end
|
154
|
+
assert_equal curl.url, curl.last_effective_url
|
155
|
+
assert_equal 'GET', curl.body_str
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_local_port_01
|
159
|
+
c = Curl::Easy.new($TEST_URL)
|
160
|
+
|
161
|
+
assert_nil c.local_port
|
162
|
+
assert_nil c.local_port_range
|
163
|
+
assert_nil c.proxy_port
|
164
|
+
|
165
|
+
c.local_port = 88
|
166
|
+
|
167
|
+
assert_equal 88, c.local_port
|
168
|
+
assert_nil c.local_port_range
|
169
|
+
assert_nil c.proxy_port
|
170
|
+
|
171
|
+
c.local_port = nil
|
172
|
+
|
173
|
+
assert_nil c.local_port
|
174
|
+
assert_nil c.local_port_range
|
175
|
+
assert_nil c.proxy_port
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_local_port_02
|
179
|
+
c = Curl::Easy.new($TEST_URL)
|
180
|
+
|
181
|
+
assert_nil c.local_port
|
182
|
+
assert_raise(ArgumentError) { c.local_port = 0 }
|
183
|
+
assert_raise(ArgumentError) { c.local_port = 65536 }
|
184
|
+
assert_raise(ArgumentError) { c.local_port = -1 }
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_local_port_range_01
|
188
|
+
c = Curl::Easy.new($TEST_URL)
|
189
|
+
|
190
|
+
assert_nil c.local_port_range
|
191
|
+
assert_nil c.local_port
|
192
|
+
assert_nil c.proxy_port
|
193
|
+
|
194
|
+
c.local_port_range = 88
|
195
|
+
assert_equal 88, c.local_port_range
|
196
|
+
assert_nil c.local_port
|
197
|
+
assert_nil c.proxy_port
|
198
|
+
|
199
|
+
c.local_port_range = nil
|
200
|
+
|
201
|
+
assert_nil c.local_port_range
|
202
|
+
assert_nil c.local_port
|
203
|
+
assert_nil c.proxy_port
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_local_port_range_02
|
207
|
+
c = Curl::Easy.new($TEST_URL)
|
208
|
+
|
209
|
+
assert_nil c.local_port_range
|
210
|
+
assert_raise(ArgumentError) { c.local_port_range = 0 }
|
211
|
+
assert_raise(ArgumentError) { c.local_port_range = 65536 }
|
212
|
+
assert_raise(ArgumentError) { c.local_port_range = -1 }
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_proxy_url_01
|
216
|
+
c = Curl::Easy.new($TEST_URL)
|
217
|
+
|
218
|
+
assert_equal $TEST_URL, c.url
|
219
|
+
assert_nil c.proxy_url
|
220
|
+
|
221
|
+
c.proxy_url = "http://some.proxy"
|
222
|
+
|
223
|
+
assert_equal $TEST_URL, c.url
|
224
|
+
assert_equal "http://some.proxy", c.proxy_url
|
225
|
+
|
226
|
+
c.proxy_url = nil
|
227
|
+
assert_equal $TEST_URL, c.url
|
228
|
+
assert_nil c.proxy_url
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_proxy_port_01
|
232
|
+
c = Curl::Easy.new($TEST_URL)
|
233
|
+
|
234
|
+
assert_nil c.local_port
|
235
|
+
assert_nil c.local_port_range
|
236
|
+
assert_nil c.proxy_port
|
237
|
+
|
238
|
+
c.proxy_port = 88
|
239
|
+
|
240
|
+
assert_equal 88, c.proxy_port
|
241
|
+
assert_nil c.local_port
|
242
|
+
assert_nil c.local_port_range
|
243
|
+
|
244
|
+
c.proxy_port = nil
|
245
|
+
assert_nil c.proxy_port
|
246
|
+
assert_nil c.local_port
|
247
|
+
assert_nil c.local_port_range
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_proxy_port_02
|
251
|
+
c = Curl::Easy.new($TEST_URL)
|
252
|
+
|
253
|
+
assert_nil c.proxy_port
|
254
|
+
assert_raise(ArgumentError) { c.proxy_port = 0 }
|
255
|
+
assert_raise(ArgumentError) { c.proxy_port = 65536 }
|
256
|
+
assert_raise(ArgumentError) { c.proxy_port = -1 }
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_proxy_type_01
|
260
|
+
c = Curl::Easy.new($TEST_URL)
|
261
|
+
|
262
|
+
assert_nil c.proxy_type
|
263
|
+
|
264
|
+
c.proxy_type = 3
|
265
|
+
assert_equal 3, c.proxy_type
|
266
|
+
|
267
|
+
c.proxy_type = nil
|
268
|
+
assert_nil c.proxy_type
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_http_auth_types_01
|
272
|
+
c = Curl::Easy.new($TEST_URL)
|
273
|
+
|
274
|
+
assert_nil c.http_auth_types
|
275
|
+
|
276
|
+
c.http_auth_types = 3
|
277
|
+
assert_equal 3, c.http_auth_types
|
278
|
+
|
279
|
+
c.http_auth_types = nil
|
280
|
+
assert_nil c.http_auth_types
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_proxy_auth_types_01
|
284
|
+
c = Curl::Easy.new($TEST_URL)
|
285
|
+
|
286
|
+
assert_nil c.proxy_auth_types
|
287
|
+
|
288
|
+
c.proxy_auth_types = 3
|
289
|
+
assert_equal 3, c.proxy_auth_types
|
290
|
+
|
291
|
+
c.proxy_auth_types = nil
|
292
|
+
assert_nil c.proxy_auth_types
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_max_redirects_01
|
296
|
+
c = Curl::Easy.new($TEST_URL)
|
297
|
+
|
298
|
+
assert_nil c.max_redirects
|
299
|
+
|
300
|
+
c.max_redirects = 3
|
301
|
+
assert_equal 3, c.max_redirects
|
302
|
+
|
303
|
+
c.max_redirects = nil
|
304
|
+
assert_nil c.max_redirects
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_timeout_01
|
308
|
+
c = Curl::Easy.new($TEST_URL)
|
309
|
+
|
310
|
+
assert_nil c.timeout
|
311
|
+
|
312
|
+
c.timeout = 3
|
313
|
+
assert_equal 3, c.timeout
|
314
|
+
|
315
|
+
c.timeout = nil
|
316
|
+
assert_nil c.timeout
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_connect_timeout_01
|
320
|
+
c = Curl::Easy.new($TEST_URL)
|
321
|
+
|
322
|
+
assert_nil c.connect_timeout
|
323
|
+
|
324
|
+
c.connect_timeout = 3
|
325
|
+
assert_equal 3, c.connect_timeout
|
326
|
+
|
327
|
+
c.connect_timeout = nil
|
328
|
+
assert_nil c.connect_timeout
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_ftp_response_timeout_01
|
332
|
+
c = Curl::Easy.new($TEST_URL)
|
333
|
+
|
334
|
+
assert_nil c.ftp_response_timeout
|
335
|
+
|
336
|
+
c.ftp_response_timeout = 3
|
337
|
+
assert_equal 3, c.ftp_response_timeout
|
338
|
+
|
339
|
+
c.ftp_response_timeout = nil
|
340
|
+
assert_nil c.ftp_response_timeout
|
341
|
+
end
|
342
|
+
|
343
|
+
def test_dns_cache_timeout_01
|
344
|
+
c = Curl::Easy.new($TEST_URL)
|
345
|
+
|
346
|
+
assert_equal 60, c.dns_cache_timeout
|
347
|
+
|
348
|
+
c.dns_cache_timeout = nil
|
349
|
+
assert_nil c.dns_cache_timeout
|
350
|
+
|
351
|
+
c.dns_cache_timeout = 30
|
352
|
+
assert_equal 30, c.dns_cache_timeout
|
353
|
+
end
|
354
|
+
|
355
|
+
def test_on_body
|
356
|
+
blk = lambda { |i| i.length }
|
357
|
+
|
358
|
+
c = Curl::Easy.new
|
359
|
+
c.on_body(&blk)
|
360
|
+
|
361
|
+
assert_equal blk, c.on_body # sets handler nil, returns old handler
|
362
|
+
assert_equal nil, c.on_body
|
363
|
+
end
|
364
|
+
|
365
|
+
def test_on_header
|
366
|
+
blk = lambda { |i| i.length }
|
367
|
+
|
368
|
+
c = Curl::Easy.new
|
369
|
+
c.on_header(&blk)
|
370
|
+
|
371
|
+
assert_equal blk, c.on_header # sets handler nil, returns old handler
|
372
|
+
assert_equal nil, c.on_header
|
373
|
+
end
|
374
|
+
|
375
|
+
def test_on_progress
|
376
|
+
blk = lambda { |*args| true }
|
377
|
+
|
378
|
+
c = Curl::Easy.new
|
379
|
+
c.on_progress(&blk)
|
380
|
+
|
381
|
+
assert_equal blk, c.on_progress # sets handler nil, returns old handler
|
382
|
+
assert_equal nil, c.on_progress
|
383
|
+
end
|
384
|
+
|
385
|
+
def test_on_debug
|
386
|
+
blk = lambda { |*args| true }
|
387
|
+
|
388
|
+
c = Curl::Easy.new
|
389
|
+
c.on_debug(&blk)
|
390
|
+
|
391
|
+
assert_equal blk, c.on_debug # sets handler nil, returns old handler
|
392
|
+
assert_equal nil, c.on_debug
|
393
|
+
end
|
394
|
+
|
395
|
+
def test_proxy_tunnel
|
396
|
+
c = Curl::Easy.new
|
397
|
+
assert !c.proxy_tunnel?
|
398
|
+
assert c.proxy_tunnel = true
|
399
|
+
assert c.proxy_tunnel?
|
400
|
+
end
|
401
|
+
|
402
|
+
def test_fetch_file_time
|
403
|
+
c = Curl::Easy.new
|
404
|
+
assert !c.fetch_file_time?
|
405
|
+
assert c.fetch_file_time = true
|
406
|
+
assert c.fetch_file_time?
|
407
|
+
end
|
408
|
+
|
409
|
+
def test_ssl_verify_peer
|
410
|
+
c = Curl::Easy.new
|
411
|
+
assert c.ssl_verify_peer?
|
412
|
+
assert !c.ssl_verify_peer = false
|
413
|
+
assert !c.ssl_verify_peer?
|
414
|
+
end
|
415
|
+
|
416
|
+
def test_ssl_verify_host
|
417
|
+
c = Curl::Easy.new
|
418
|
+
assert c.ssl_verify_host?
|
419
|
+
assert !c.ssl_verify_host = false
|
420
|
+
assert !c.ssl_verify_host?
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_header_in_body
|
424
|
+
c = Curl::Easy.new
|
425
|
+
assert !c.header_in_body?
|
426
|
+
assert c.header_in_body = true
|
427
|
+
assert c.header_in_body?
|
428
|
+
end
|
429
|
+
|
430
|
+
def test_use_netrc
|
431
|
+
c = Curl::Easy.new
|
432
|
+
assert !c.use_netrc?
|
433
|
+
assert c.use_netrc = true
|
434
|
+
assert c.use_netrc?
|
435
|
+
end
|
436
|
+
|
437
|
+
def test_follow_location
|
438
|
+
c = Curl::Easy.new
|
439
|
+
assert !c.follow_location?
|
440
|
+
assert c.follow_location = true
|
441
|
+
assert c.follow_location?
|
442
|
+
end
|
443
|
+
|
444
|
+
def test_unrestricted_auth
|
445
|
+
c = Curl::Easy.new
|
446
|
+
assert !c.unrestricted_auth?
|
447
|
+
assert c.unrestricted_auth = true
|
448
|
+
assert c.unrestricted_auth?
|
449
|
+
end
|
450
|
+
|
451
|
+
def test_multipart_form_post
|
452
|
+
c = Curl::Easy.new
|
453
|
+
assert !c.multipart_form_post?
|
454
|
+
assert c.multipart_form_post = true
|
455
|
+
assert c.multipart_form_post?
|
456
|
+
end
|
457
|
+
|
458
|
+
def test_enable_cookies
|
459
|
+
c = Curl::Easy.new
|
460
|
+
assert !c.enable_cookies?
|
461
|
+
assert c.enable_cookies = true
|
462
|
+
assert c.enable_cookies?
|
463
|
+
end
|
464
|
+
|
465
|
+
def test_cookies_option
|
466
|
+
c = Curl::Easy.new
|
467
|
+
assert_nil c.cookies
|
468
|
+
assert_equal "name1=content1; name2=content2;", c.cookies = "name1=content1; name2=content2;"
|
469
|
+
assert_equal "name1=content1; name2=content2;", c.cookies
|
470
|
+
end
|
471
|
+
|
472
|
+
def test_cookiefile
|
473
|
+
c = Curl::Easy.new
|
474
|
+
assert_nil c.cookiefile
|
475
|
+
assert_equal "some.file", c.cookiefile = "some.file"
|
476
|
+
assert_equal "some.file", c.cookiefile
|
477
|
+
end
|
478
|
+
|
479
|
+
def test_cookiejar
|
480
|
+
c = Curl::Easy.new
|
481
|
+
assert_nil c.cookiejar
|
482
|
+
assert_equal "some.file", c.cookiejar = "some.file"
|
483
|
+
assert_equal "some.file", c.cookiejar
|
484
|
+
end
|
485
|
+
|
486
|
+
def test_on_success
|
487
|
+
curl = Curl::Easy.new($TEST_URL)
|
488
|
+
on_success_called = false
|
489
|
+
curl.on_success {|c|
|
490
|
+
on_success_called = true
|
491
|
+
assert_not_nil c.body_str
|
492
|
+
assert_equal "", c.header_str
|
493
|
+
assert_match(/^# DO NOT REMOVE THIS COMMENT/, c.body_str)
|
494
|
+
}
|
495
|
+
curl.perform
|
496
|
+
assert on_success_called, "Success handler not called"
|
497
|
+
end
|
498
|
+
|
499
|
+
def test_on_success_with_on_failure
|
500
|
+
curl = Curl::Easy.new("#{$TEST_URL.gsub(/file:\/\//,'')}/not_here")
|
501
|
+
on_failure_called = false
|
502
|
+
curl.on_success {|c| } # make sure we get the failure call even though this handler is defined
|
503
|
+
curl.on_failure {|c,code| on_failure_called = true }
|
504
|
+
curl.perform
|
505
|
+
assert on_failure_called, "Failure handler not called"
|
506
|
+
end
|
507
|
+
|
508
|
+
def test_get_remote
|
509
|
+
curl = Curl::Easy.new(TestServlet.url)
|
510
|
+
curl.http_get
|
511
|
+
assert_equal 'GET', curl.body_str
|
512
|
+
end
|
513
|
+
|
514
|
+
def test_post_remote
|
515
|
+
curl = Curl::Easy.new(TestServlet.url)
|
516
|
+
curl.http_post
|
517
|
+
assert_equal "POST\n", curl.body_str
|
518
|
+
end
|
519
|
+
|
520
|
+
def test_post_remote_is_easy_handle
|
521
|
+
# see: http://pastie.org/560852 and
|
522
|
+
# http://groups.google.com/group/curb---ruby-libcurl-bindings/browse_thread/thread/216bb2d9b037f347?hl=en
|
523
|
+
[:post, :get,:head,:delete].each do |method|
|
524
|
+
count = 0
|
525
|
+
curl = Curl::Easy.send("http_#{method}", TestServlet.url) do|c|
|
526
|
+
count += 1
|
527
|
+
assert_equal Curl::Easy, c.class
|
528
|
+
end
|
529
|
+
assert_equal 1, count, "For request method: #{method.to_s.upcase}"
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
def test_post_with_body_remote
|
534
|
+
curl = Curl::Easy.new(TestServlet.url)
|
535
|
+
curl.post_body = 'foo=bar&encoded%20string=val'
|
536
|
+
|
537
|
+
curl.perform
|
538
|
+
|
539
|
+
assert_equal "POST\nfoo=bar&encoded%20string=val", curl.body_str
|
540
|
+
assert_equal 'foo=bar&encoded%20string=val', curl.post_body
|
541
|
+
end
|
542
|
+
|
543
|
+
def test_form_post_body_remote
|
544
|
+
curl = Curl::Easy.new(TestServlet.url)
|
545
|
+
curl.http_post('foo=bar', 'encoded%20string=val')
|
546
|
+
|
547
|
+
assert_equal "POST\nfoo=bar&encoded%20string=val", curl.body_str
|
548
|
+
assert_equal 'foo=bar&encoded%20string=val', curl.post_body
|
549
|
+
end
|
550
|
+
|
551
|
+
def test_delete_remote
|
552
|
+
curl = Curl::Easy.new(TestServlet.url)
|
553
|
+
curl.http_delete
|
554
|
+
assert_equal 'DELETE', curl.body_str
|
555
|
+
end
|
556
|
+
|
557
|
+
def test_head_remote
|
558
|
+
curl = Curl::Easy.new(TestServlet.url)
|
559
|
+
curl.http_head
|
560
|
+
|
561
|
+
redirect = curl.header_str.match(/Location: (.*)/)
|
562
|
+
|
563
|
+
assert_equal '', curl.body_str
|
564
|
+
assert_match '/nonexistent', redirect[1]
|
565
|
+
end
|
566
|
+
|
567
|
+
def test_head_accessor
|
568
|
+
curl = Curl::Easy.new(TestServlet.url)
|
569
|
+
curl.head = true
|
570
|
+
curl.perform
|
571
|
+
|
572
|
+
redirect = curl.header_str.match(/Location: (.*)/)
|
573
|
+
|
574
|
+
assert_equal '', curl.body_str
|
575
|
+
assert_match '/nonexistent', redirect[1]
|
576
|
+
curl.head = false
|
577
|
+
curl.perform
|
578
|
+
assert_equal 'GET', curl.body_str
|
579
|
+
end
|
580
|
+
|
581
|
+
def test_put_remote
|
582
|
+
curl = Curl::Easy.new(TestServlet.url)
|
583
|
+
curl.headers['Content-Type'] = 'application/json'
|
584
|
+
assert curl.http_put("message")
|
585
|
+
assert_match /^PUT/, curl.body_str
|
586
|
+
assert_match /message$/, curl.body_str
|
587
|
+
assert_match /application\/json/, curl.header_str
|
588
|
+
end
|
589
|
+
|
590
|
+
def test_put_data
|
591
|
+
curl = Curl::Easy.new(TestServlet.url)
|
592
|
+
curl.put_data = 'message'
|
593
|
+
|
594
|
+
curl.perform
|
595
|
+
|
596
|
+
assert_match /^PUT/, curl.body_str
|
597
|
+
assert_match /message$/, curl.body_str
|
598
|
+
end
|
599
|
+
|
600
|
+
def test_put_remote_file
|
601
|
+
curl = Curl::Easy.new(TestServlet.url)
|
602
|
+
File.open(__FILE__,'r') do|f|
|
603
|
+
assert curl.http_put(f)
|
604
|
+
end
|
605
|
+
assert_equal "PUT\n#{File.read(__FILE__)}", curl.body_str
|
606
|
+
end
|
607
|
+
|
608
|
+
def test_put_class_method
|
609
|
+
count = 0
|
610
|
+
curl = Curl::Easy.http_put(TestServlet.url,File.open(__FILE__,'rb')) do|c|
|
611
|
+
count += 1
|
612
|
+
assert_equal Curl::Easy, c.class
|
613
|
+
end
|
614
|
+
assert_equal 1, count
|
615
|
+
assert_equal "PUT\n#{File.read(__FILE__)}", curl.body_str
|
616
|
+
end
|
617
|
+
|
618
|
+
# Generate a self-signed cert with
|
619
|
+
# openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 \
|
620
|
+
# -keyout tests/cert.pem -out tests/cert.pem
|
621
|
+
def test_cert
|
622
|
+
curl = Curl::Easy.new(TestServlet.url)
|
623
|
+
curl.cert= File.join(File.dirname(__FILE__),"cert.pem")
|
624
|
+
assert /cert.pem$/,curl.cert
|
625
|
+
end
|
626
|
+
|
627
|
+
def test_cert_with_password
|
628
|
+
curl = Curl::Easy.new(TestServlet.url)
|
629
|
+
curl.cert= File.join(File.dirname(__FILE__),"cert.pem:password")
|
630
|
+
assert /cert.pem$/,curl.cert
|
631
|
+
end
|
632
|
+
|
633
|
+
def test_cert_type
|
634
|
+
curl = Curl::Easy.new(TestServlet.url)
|
635
|
+
curl.certtype= "DER"
|
636
|
+
assert "DER", curl.certtype
|
637
|
+
end
|
638
|
+
|
639
|
+
def test_default_certtype
|
640
|
+
curl = Curl::Easy.new(TestServlet.url)
|
641
|
+
assert "PEM", curl.certtype
|
642
|
+
end
|
643
|
+
|
644
|
+
# Generate a CA cert with instructions at
|
645
|
+
# http://technocage.com/~caskey/openssl/
|
646
|
+
def test_ca_cert
|
647
|
+
curl = Curl::Easy.new(TestServlet.url)
|
648
|
+
curl.cacert= File.join(File.dirname(__FILE__),"cacert.pem")
|
649
|
+
assert /cacert.pem$/, curl.cacert
|
650
|
+
end
|
651
|
+
|
652
|
+
def test_user_agent
|
653
|
+
curl = Curl::Easy.new(TestServlet.url)
|
654
|
+
curl.useragent= "Curb-Easy/Ruby"
|
655
|
+
assert /ScrubDog$/,curl.useragent
|
656
|
+
end
|
657
|
+
|
658
|
+
include TestServerMethods
|
659
|
+
|
660
|
+
def setup
|
661
|
+
server_setup
|
662
|
+
end
|
663
|
+
|
664
|
+
end
|