diff --git a/lib/fog/storage/requests/aws/copy_object.rb b/lib/fog/storage/requests/aws/copy_object.rb index fc2916d19..5986eb5ba 100644 --- a/lib/fog/storage/requests/aws/copy_object.rb +++ b/lib/fog/storage/requests/aws/copy_object.rb @@ -60,7 +60,7 @@ module Fog target_bucket[:objects][target_object_name] = target_object response.body = { 'ETag' => target_object['ETag'], - 'LastModified' => Time.parse(target_object['LastModified']) + 'LastModified' => Time.parse(target_object['Last-Modified']) } else response.status = 404 diff --git a/lib/fog/storage/requests/aws/get_bucket.rb b/lib/fog/storage/requests/aws/get_bucket.rb index a32498751..f8e792a80 100644 --- a/lib/fog/storage/requests/aws/get_bucket.rb +++ b/lib/fog/storage/requests/aws/get_bucket.rb @@ -72,11 +72,11 @@ module Fog (options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) || (options['marker'] && object['Key'] <= options['marker']) end.map do |object| - data = object.reject {|key, value| !['ETag', 'Key', 'LastModified', 'Size', 'StorageClass'].include?(key)} + data = object.reject {|key, value| !['ETag', 'Key', 'StorageClass'].include?(key)} data.merge!({ - 'LastModified' => Time.parse(data['LastModified']), + 'LastModified' => Time.parse(object['Last-Modified']), 'Owner' => bucket['Owner'], - 'Size' => data['Size'].to_i + 'Size' => object['Content-Length'].to_i }) data end diff --git a/lib/fog/storage/requests/aws/get_object.rb b/lib/fog/storage/requests/aws/get_object.rb index cfd06a804..083148f94 100644 --- a/lib/fog/storage/requests/aws/get_object.rb +++ b/lib/fog/storage/requests/aws/get_object.rb @@ -68,15 +68,20 @@ module Fog if (bucket = @data[:buckets][bucket_name]) && (object = bucket[:objects][object_name]) if options['If-Match'] && options['If-Match'] != object['ETag'] response.status = 412 - elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['LastModified']) + elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['Last-Modified']) response.status = 304 elsif options['If-None-Match'] && options['If-None-Match'] == object['ETag'] response.status = 304 - elsif options['If-Unmodified-Since'] && options['If-Unmodified-Since'] < Time.parse(object['LastModified']) + elsif options['If-Unmodified-Since'] && options['If-Unmodified-Since'] < Time.parse(object['Last-Modified']) response.status = 412 else response.status = 200 - response.headers = object.reject {|key, value| key == :body} + for key, value in object + case key + when 'Cache-Control', 'Content-Disposition', 'Content-Encoding', 'Content-Length', 'Content-MD5', 'Content-Type', 'ETag', 'Expires', 'Last-Modified', /^x-amz-meta-/ + response.headers[key] = value + end + end unless block_given? response.body = object[:body] else diff --git a/lib/fog/storage/requests/aws/put_object.rb b/lib/fog/storage/requests/aws/put_object.rb index 1421d07a2..a7e06e4ea 100644 --- a/lib/fog/storage/requests/aws/put_object.rb +++ b/lib/fog/storage/requests/aws/put_object.rb @@ -64,13 +64,13 @@ module Fog if (bucket = @data[:buckets][bucket_name]) response.status = 200 object = { - :body => data[:body], - 'Content-Type' => options['Content-Type'] || data[:headers]['Content-Type'], - 'ETag' => Fog::AWS::Mock.etag, - 'Key' => object_name, - 'LastModified' => Fog::Time.now.to_date_header, - 'Size' => options['Content-Length'] || data[:headers]['Content-Length'], - 'StorageClass' => options['x-amz-storage-class'] || 'STANDARD' + :body => data[:body], + 'Content-Type' => options['Content-Type'] || data[:headers]['Content-Type'], + 'ETag' => Fog::AWS::Mock.etag, + 'Key' => object_name, + 'Last-Modified' => Fog::Time.now.to_date_header, + 'Content-Length' => options['Content-Length'] || data[:headers]['Content-Length'], + 'StorageClass' => options['x-amz-storage-class'] || 'STANDARD' } for key, value in options @@ -82,10 +82,10 @@ module Fog bucket[:objects][object_name] = object response.headers = { - 'Content-Length' => object['Size'], + 'Content-Length' => object['Content-Length'], 'Content-Type' => object['Content-Type'], 'ETag' => object['ETag'], - 'Last-Modified' => object['LastModified'] + 'Last-Modified' => object['Last-Modified'] } else response.status = 404 diff --git a/lib/fog/storage/requests/google/copy_object.rb b/lib/fog/storage/requests/google/copy_object.rb index 9fd582657..b6d78312c 100644 --- a/lib/fog/storage/requests/google/copy_object.rb +++ b/lib/fog/storage/requests/google/copy_object.rb @@ -56,7 +56,7 @@ module Fog target_bucket[:objects][target_object_name] = target_object response.body = { 'ETag' => target_object['ETag'], - 'LastModified' => Time.parse(target_object['LastModified']) + 'LastModified' => Time.parse(target_object['Last-Modified']) } else response.status = 404 diff --git a/lib/fog/storage/requests/google/get_bucket.rb b/lib/fog/storage/requests/google/get_bucket.rb index 3dc4955a1..f9fd67772 100644 --- a/lib/fog/storage/requests/google/get_bucket.rb +++ b/lib/fog/storage/requests/google/get_bucket.rb @@ -69,11 +69,11 @@ module Fog (options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) || (options['marker'] && object['Key'] <= options['marker']) end.map do |object| - data = object.reject {|key, value| !['ETag', 'Key', 'LastModified', 'Size', 'StorageClass'].include?(key)} + data = object.reject {|key, value| !['ETag', 'Key', 'StorageClass'].include?(key)} data.merge!({ - 'LastModified' => Time.parse(data['LastModified']), + 'LastModified' => Time.parse(object['Last-Modified']), 'Owner' => bucket['Owner'], - 'Size' => data['Size'].to_i + 'Size' => object['Content-Length'].to_i }) data end diff --git a/lib/fog/storage/requests/google/get_object.rb b/lib/fog/storage/requests/google/get_object.rb index d81f02e69..a9aef7cc4 100644 --- a/lib/fog/storage/requests/google/get_object.rb +++ b/lib/fog/storage/requests/google/get_object.rb @@ -65,15 +65,20 @@ module Fog if (bucket = @data[:buckets][bucket_name]) && (object = bucket[:objects][object_name]) if options['If-Match'] && options['If-Match'] != object['ETag'] response.status = 412 - elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['LastModified']) + elsif options['If-Modified-Since'] && options['If-Modified-Since'] > Time.parse(object['Last-Modified']) response.status = 304 elsif options['If-None-Match'] && options['If-None-Match'] == object['ETag'] response.status = 304 - elsif options['If-Unmodified-Since'] && options['If-Unmodified-Since'] < Time.parse(object['LastModified']) + elsif options['If-Unmodified-Since'] && options['If-Unmodified-Since'] < Time.parse(object['Last-Modified']) response.status = 412 else response.status = 200 - response.headers = object.reject {|key, value| key == :body} + for key, value in object + case key + when 'Cache-Control', 'Content-Disposition', 'Content-Encoding', 'Content-Length', 'Content-MD5', 'Content-Type', 'ETag', 'Expires', 'Last-Modified', /^x-goog-meta-/ + response.headers[key] = value + end + end unless block_given? response.body = object[:body] else diff --git a/lib/fog/storage/requests/google/put_object.rb b/lib/fog/storage/requests/google/put_object.rb index 40e9508bc..d71aeb75f 100644 --- a/lib/fog/storage/requests/google/put_object.rb +++ b/lib/fog/storage/requests/google/put_object.rb @@ -58,13 +58,13 @@ module Fog if (bucket = @data[:buckets][bucket_name]) response.status = 200 object = { - :body => data[:body], - 'Content-Type' => options['Content-Type'] || data[:headers]['Content-Type'], - 'ETag' => Fog::Google::Mock.etag, - 'Key' => object_name, - 'LastModified' => Fog::Time.now.to_date_header, - 'Size' => options['Content-Length'] || data[:headers]['Content-Length'], - 'StorageClass' => 'STANDARD' + :body => data[:body], + 'Content-Type' => options['Content-Type'] || data[:headers]['Content-Type'], + 'ETag' => Fog::Google::Mock.etag, + 'Key' => object_name, + 'Last-Modified' => Fog::Time.now.to_date_header, + 'Content-Length' => options['Content-Length'] || data[:headers]['Content-Length'], + 'StorageClass' => 'STANDARD' } for key, value in options @@ -76,10 +76,10 @@ module Fog bucket[:objects][object_name] = object response.headers = { - 'Content-Length' => object['Size'], + 'Content-Length' => object['Content-Length'], 'Content-Type' => object['Content-Type'], 'ETag' => object['ETag'], - 'Last-Modified' => object['LastModified'] + 'Last-Modified' => object['Last-Modified'] } else response.status = 404