aboutsummaryrefslogtreecommitdiffstats
path: root/test/net/http/utils.rb
diff options
context:
space:
mode:
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