cleanup and typo fixes
This commit is contained in:
parent
a9b56db2e4
commit
87161229d9
|
@ -30,15 +30,17 @@ module Fog
|
||||||
|
|
||||||
def request
|
def request
|
||||||
uri = URI.parse(@url)
|
uri = URI.parse(@url)
|
||||||
path = "#{uri.path}#{uri.query.nil? ? "" : "?#{uri.query}"}"
|
path = "#{uri.path}"
|
||||||
host = "#{uri.host}#{uri.port == 80 ? "" : ":#{uri.port}"}"
|
path << "?#{uri.query}" if uri.query
|
||||||
|
host = "#{uri.host}"
|
||||||
|
host << ":#{uri.port}" unless uri.port == 80
|
||||||
@headers.merge!({'Host' => host})
|
@headers.merge!({'Host' => host})
|
||||||
request = "#{method} #{path} HTTP/1.1\r\n"
|
request = "#{method} #{path} HTTP/1.1\r\n"
|
||||||
for key, value in headers
|
for key, value in headers
|
||||||
request << "#{key}: #{value}\r\n"
|
request << "#{key}: #{value}\r\n"
|
||||||
end
|
end
|
||||||
|
request << "\r\n#{@body}" if @body
|
||||||
request << "\r\n"
|
request << "\r\n"
|
||||||
request << "#{@body}\r\n" if @body
|
|
||||||
send_data(request)
|
send_data(request)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -201,22 +201,25 @@ module Fog
|
||||||
def url(bucket_name = nil, path = nil)
|
def url(bucket_name = nil, path = nil)
|
||||||
url = "#{@scheme}://"
|
url = "#{@scheme}://"
|
||||||
url << "#{bucket_name}." if bucket_name
|
url << "#{bucket_name}." if bucket_name
|
||||||
url << "#{@host}:#{@port}/"
|
url << "#{@host}:#{@port}/#{path}"
|
||||||
url << path if path
|
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
|
||||||
def canonicalize_amz_headers(headers)
|
def canonicalize_amz_headers(headers)
|
||||||
headers = headers.select {|key,value| key.match(/^x-amz-/iu)}.sort {|x,y| x[0] <=> y[0]}.collect {|header| header.join(':')}.join("\n").downcase
|
if headers.empty?
|
||||||
headers.empty? ? nil : headers
|
nil
|
||||||
|
else
|
||||||
|
headers.select {|key,value| key.match(/^x-amz-/iu)}.sort {|x,y| x[0] <=> y[0]}.collect {|header| header.join(':')}.join("\n").downcase
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def canonicalize_resource(uri)
|
def canonicalize_resource(uri)
|
||||||
resource = "/#{'s3.amazonaws.com' == uri.host ? "" : "#{uri.host.split('.s3.amazonaws.com')[0]}/"}"
|
resource = "/"
|
||||||
|
resource << "#{match[1]}/" if match = uri.host.match(/(.*).s3.amazonaws.com/)
|
||||||
resource << "#{uri.path[1..-1]}" if uri.path
|
resource << "#{uri.path[1..-1]}" if uri.path
|
||||||
resource << "?location" if uri.to_s.include?('?acl')
|
resource << "?acl" if uri.to_s.include?('?acl')
|
||||||
resource << "?location" if uri.to_s.include?('?location')
|
resource << "?location" if uri.to_s.include?('?location')
|
||||||
resource << "?location" if uri.to_s.include?('?torrent')
|
resource << "?torrent" if uri.to_s.include?('?torrent')
|
||||||
resource
|
resource
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue