* add SSL support to the client (pass another arg to enable)

git-svn-id: file:///home/svn/incoming/trunk@3411 4d416f70-5f16-0410-b530-b9f4589650da
unstable
bmc 2006-01-20 18:59:24 +00:00
parent d07e5fd330
commit 9913f6d953
2 changed files with 21 additions and 3 deletions

View File

@ -42,13 +42,13 @@ class Client
return init_request(Request::Post.new(uri, proto))
end
def initialize(host, port = 80, context = {})
def initialize(host, port = 80, context = {}, ssl = nil)
self.hostname = host
self.port = port.to_i
self.context = context
self.ssl = ssl
self.request_config = {}
self.client_config = {}
end
#
@ -138,7 +138,8 @@ class Client
'PeerPort' => self.port.to_i,
'LocalHost' => self.local_host,
'LocalPort' => self.local_port,
'Context' => self.context
'Context' => self.context,
'SSL' => self.ssl
)
end
@ -257,6 +258,9 @@ class Client
protected
# https
attr_accessor :ssl
attr_accessor :hostname, :port # :nodoc:
attr_accessor :request_config, :client_config # :nodoc:

View File

@ -74,4 +74,18 @@ class Rex::Proto::Http::Client::UnitTest < Test::Unit::TestCase
assert_equal('1.1', resp.proto)
end
def test_ssl
c = Klass.new('www.geotrust.com', '443', {}, 'true')
c.request_option('vhost', 'www.geotrust.com')
r = c.request(
'method' => 'GET',
'uri' => '/'
)
resp = c.send_request(r)
assert_equal(200, resp.code)
assert_equal('OK', resp.message)
assert_equal('1.1', resp.proto)
c.close
end
end