summaryrefslogtreecommitdiff
path: root/test/net/http/utils.rb
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-20 16:21:22 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-20 16:21:22 +0000
commitc6920177f3e561f779f54534e511f0c9f0de6edd (patch)
tree3e7fe138ecb67bb2e2a9e520b373d420b315e147 /test/net/http/utils.rb
parentd86caf318820ebcebf981b822a65d5a4cfab6364 (diff)
* lib/net/http.rb (Net::HTTP#connect): use
OpenSSL::SSL::SSLContext.build instead of SSLContext.new (default verify mode is now OpenSSL::SSL::VERIFY_PEER). * lib/net/https.rb: SSL parameters are defined by attr_accessor. * test/net/http/test_https.rb: add test for HTTPS features. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/http/utils.rb')
-rw-r--r--test/net/http/utils.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb
index aec1967a74..766bf71c46 100644
--- a/test/net/http/utils.rb
+++ b/test/net/http/utils.rb
@@ -1,4 +1,9 @@
require 'webrick'
+begin
+ require "webrick/https"
+rescue LoadError
+ # SSL features cannot be tested
+end
require 'webrick/httpservlet/abstract'
module TestNetHTTPUtils
@@ -35,14 +40,22 @@ module TestNetHTTPUtils
end
def spawn_server
- @server = WEBrick::HTTPServer.new(
+ server_config = {
:BindAddress => config('host'),
:Port => config('port'),
:Logger => WEBrick::Log.new(NullWriter.new),
:AccessLog => [],
:ShutdownSocketWithoutClose => true,
- :ServerType => Thread
- )
+ :ServerType => Thread,
+ }
+ if defined?(OpenSSL) and config('ssl_enable')
+ server_config.update({
+ :SSLEnable => true,
+ :SSLCertificate => config('ssl_certificate'),
+ :SSLPrivateKey => config('ssl_private_key'),
+ })
+ end
+ @server = WEBrick::HTTPServer.new(server_config)
@server.mount('/', Servlet)
@server.start
n_try_max = 5