Sha256: 59a4be1c99dd5016d2a6ff914c44119978a587e884c148255970bba54d707454
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
require "webrick" require "webrick/ssl" require "support/black_hole" require "support/dummy_server/servlet" require "support/servers/config" require "support/servers/runner" class DummyServer < WEBrick::HTTPServer include ServerConfig CONFIG = { :BindAddress => "127.0.0.1", :Port => 0, :AccessLog => BlackHole, :Logger => BlackHole }.freeze def initialize(options = {}) if options[:ssl] override_config = { :SSLEnable => true, :SSLStartImmediately => true } else override_config = {} end super CONFIG.merge(override_config) mount("/", Servlet) end def endpoint "#{ssl? ? 'https' : 'http'}://#{addr}:#{port}" end def ssl_context @ssl_context ||= begin context = OpenSSL::SSL::SSLContext.new context.verify_mode = OpenSSL::SSL::VERIFY_PEER context.key = OpenSSL::PKey::RSA.new( File.read(File.join(certs_dir, "server.key")) ) context.cert = OpenSSL::X509::Certificate.new( File.read(File.join(certs_dir, "server.crt")) ) context.ca_file = File.join(certs_dir, "ca.crt") context end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
http-0.8.0.pre4 | spec/support/dummy_server.rb |
http-0.8.0.pre3 | spec/support/dummy_server.rb |
http-0.8.0.pre2 | spec/support/dummy_server.rb |
http-0.8.0.pre | spec/support/dummy_server.rb |