1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Fix public_url property to generate a url when cdn is not enabled. Also, create a new url method that returns the full url.

This commit is contained in:
Rupak Ganguly 2011-07-13 18:11:08 -04:00
parent e9553e6fc7
commit d9925930bf
2 changed files with 19 additions and 8 deletions

View file

@ -35,6 +35,9 @@ module Fog
nil
end
def url
"#{@scheme}://#{@host}:#{@port}#{@path}"
end
end
class Mock

View file

@ -40,16 +40,24 @@ module Fog
def public_url
requires :key
@public_url ||= begin
begin response = connection.cdn.head_container(key)
if response.headers['X-CDN-Enabled'] == 'True'
if connection.hp_cdn_ssl == true
response.headers['X-CDN-SSL-URI']
else
response.headers['X-CDN-URI']
if !connection.cdn.nil?
begin response = connection.cdn.head_container(key)
if response.headers['X-CDN-Enabled'] == 'True'
if connection.hp_cdn_ssl == true
response.headers['X-CDN-SSL-URI']
else
response.headers['X-CDN-URI']
end
end
rescue Fog::Service::NotFound
nil
end
else
begin response = connection.head_container(key)
url = "#{connection.url}/#{key}"
rescue Fog::Service::NotFound
nil
end
rescue Fog::Service::NotFound
nil
end
end
end