mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
cleanup and typo fixes
This commit is contained in:
parent
a9b56db2e4
commit
87161229d9
2 changed files with 15 additions and 10 deletions
|
@ -30,15 +30,17 @@ module Fog
|
|||
|
||||
def request
|
||||
uri = URI.parse(@url)
|
||||
path = "#{uri.path}#{uri.query.nil? ? "" : "?#{uri.query}"}"
|
||||
host = "#{uri.host}#{uri.port == 80 ? "" : ":#{uri.port}"}"
|
||||
path = "#{uri.path}"
|
||||
path << "?#{uri.query}" if uri.query
|
||||
host = "#{uri.host}"
|
||||
host << ":#{uri.port}" unless uri.port == 80
|
||||
@headers.merge!({'Host' => host})
|
||||
request = "#{method} #{path} HTTP/1.1\r\n"
|
||||
for key, value in headers
|
||||
request << "#{key}: #{value}\r\n"
|
||||
end
|
||||
request << "\r\n#{@body}" if @body
|
||||
request << "\r\n"
|
||||
request << "#{@body}\r\n" if @body
|
||||
send_data(request)
|
||||
end
|
||||
|
||||
|
|
|
@ -201,22 +201,25 @@ module Fog
|
|||
def url(bucket_name = nil, path = nil)
|
||||
url = "#{@scheme}://"
|
||||
url << "#{bucket_name}." if bucket_name
|
||||
url << "#{@host}:#{@port}/"
|
||||
url << path if path
|
||||
url << "#{@host}:#{@port}/#{path}"
|
||||
url
|
||||
end
|
||||
|
||||
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
|
||||
headers.empty? ? nil : headers
|
||||
if headers.empty?
|
||||
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
|
||||
|
||||
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 << "?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?('?torrent')
|
||||
resource << "?torrent" if uri.to_s.include?('?torrent')
|
||||
resource
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue