class FakeAWS::S3::Request
Extract information from an incoming S3
request.
See docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html
Public Instance Methods
bucket()
click to toggle source
# File lib/fake_aws/s3/request.rb, line 15 def bucket @bucket ||= case request_style when :path path_components.first when :virtual_hosted host_name_components[0..-4].join(".") when :cname host else raise FakeAWS::InternalError end end
has_key?()
click to toggle source
# File lib/fake_aws/s3/request.rb, line 39 def has_key? key != "/" end
http_headers()
click to toggle source
# File lib/fake_aws/s3/request.rb, line 10 def http_headers http_headers = env_headers.map {|key, value| [header_key_for_env_key(key), value] } Hash[http_headers] end
key()
click to toggle source
# File lib/fake_aws/s3/request.rb, line 28 def key @key ||= "/" + case request_style when :path path_components.drop(1).join("/") when :virtual_hosted, :cname path_components.join("/") else raise FakeAWS::InternalError end end
Private Instance Methods
env_headers()
click to toggle source
# File lib/fake_aws/s3/request.rb, line 65 def env_headers @env.select {|key, _| key.start_with?("HTTP_") } end
header_key_for_env_key(env_key)
click to toggle source
# File lib/fake_aws/s3/request.rb, line 69 def header_key_for_env_key(env_key) env_key.sub(/^HTTP_/, "").gsub("_", "-").downcase end
host_name_components()
click to toggle source
# File lib/fake_aws/s3/request.rb, line 45 def host_name_components @host_name_components ||= host.split(".") end
path_components()
click to toggle source
# File lib/fake_aws/s3/request.rb, line 49 def path_components @path_components ||= path.split("/").drop(1) end
request_style()
click to toggle source
# File lib/fake_aws/s3/request.rb, line 53 def request_style @request_style ||= if host =~ %r{s3[-\w\d]*} if host_name_components.length > 3 :virtual_hosted else :path end else :cname end end