From 1c81fb368ea8cc336ad6f611f6facfd353983959 Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Wed, 14 Oct 2015 21:28:42 +0000 Subject: [PATCH] server.rb: support multiple hostnames for fake-s3 server --- lib/fakes3/server.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/fakes3/server.rb b/lib/fakes3/server.rb index 00affde9..f7de2322 100644 --- a/lib/fakes3/server.rb +++ b/lib/fakes3/server.rb @@ -44,12 +44,14 @@ def inspect end class Servlet < WEBrick::HTTPServlet::AbstractServlet - def initialize(server,store,hostname) + def initialize(server,store,hostnames) super(server) @store = store @hostname = hostname @port = server.config[:Port] - @root_hostnames = [hostname,'localhost','s3.amazonaws.com','s3.localhost'] + @root_hostnames = ['localhost','s3.amazonaws.com','s3.localhost'] + extra_hostnames = Array(hostnames) + @root_hostnames << extra_hostnames end def validate_request(request) @@ -505,11 +507,11 @@ def dump_request(request) class Server - def initialize(address,port,store,hostname,ssl_cert_path,ssl_key_path) + def initialize(address,port,store,hostnames,ssl_cert_path,ssl_key_path) @address = address @port = port @store = store - @hostname = hostname + @hostnames = hostnames @ssl_cert_path = ssl_cert_path @ssl_key_path = ssl_key_path webrick_config = { @@ -529,7 +531,7 @@ def initialize(address,port,store,hostname,ssl_cert_path,ssl_key_path) end def serve - @server.mount "/", Servlet, @store,@hostname + @server.mount "/", Servlet, @store, @hostnames trap "INT" do @server.shutdown end @server.start end