Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
server.rb: support multiple hostnames for fake-s3 server
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hall committed Oct 14, 2015
1 parent e4ce5bd commit 1c81fb3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/fakes3/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {
Expand All @@ -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
Expand Down

0 comments on commit 1c81fb3

Please sign in to comment.