8000 Proper extracting (from host) of bucket names containing dots by Allactaga · Pull Request #88 · jubos/fake-s3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Proper extracting (from host) of bucket names containing dots #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/fakes3/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def initialize(server,store,hostname)
@hostname = hostname
@port = server.config[:Port]
@root_hostnames = [hostname,'localhost','s3.amazonaws.com','s3.localhost']
escaped_hostnames = @root_hostnames.map { |host| Regexp.escape(host) }
@bucket_host_regex = Regexp.new('^(.*?)\.(?:%s)$' % escaped_hostnames.join('|'))
end

def do_GET(request, response)
Expand Down Expand Up @@ -355,7 +357,7 @@ def normalize_request(webrick_req)
s_req.is_path_style = true

if !@root_hostnames.include?(host)
s_req.bucket = host.split(".")[0]
s_req.bucket = @bucket_host_regex.match(host)[1]
s_req.is_path_style = false
end

Expand Down
0