mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws&google|storage] properly handle custom headers in mocks
This commit is contained in:
parent
d4d240de31
commit
67d3bade8c
4 changed files with 23 additions and 17 deletions
|
@ -76,12 +76,7 @@ module Fog
|
||||||
response.status = 412
|
response.status = 412
|
||||||
else
|
else
|
||||||
response.status = 200
|
response.status = 200
|
||||||
response.headers = {
|
response.headers = object.reject {|key, value| key == :body}
|
||||||
'Content-Length' => object['Size'],
|
|
||||||
'Content-Type' => object['Content-Type'],
|
|
||||||
'ETag' => object['ETag'],
|
|
||||||
'Last-Modified' => object['LastModified']
|
|
||||||
}
|
|
||||||
unless block_given?
|
unless block_given?
|
||||||
response.body = object[:body]
|
response.body = object[:body]
|
||||||
else
|
else
|
||||||
|
|
|
@ -65,13 +65,21 @@ module Fog
|
||||||
response.status = 200
|
response.status = 200
|
||||||
object = {
|
object = {
|
||||||
:body => data[:body],
|
:body => data[:body],
|
||||||
'Content-Type' => data[:headers]['Content-Type'],
|
'Content-Type' => options['Content-Type'] || data[:headers]['Content-Type'],
|
||||||
'ETag' => Fog::AWS::Mock.etag,
|
'ETag' => Fog::AWS::Mock.etag,
|
||||||
'Key' => object_name,
|
'Key' => object_name,
|
||||||
'LastModified' => Fog::Time.now.to_date_header,
|
'LastModified' => Fog::Time.now.to_date_header,
|
||||||
'Size' => data[:headers]['Content-Length'],
|
'Size' => options['Content-Length'] || data[:headers]['Content-Length'],
|
||||||
'StorageClass' => 'STANDARD'
|
'StorageClass' => options['x-amz-storage-class'] || 'STANDARD'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for key, value in options
|
||||||
|
case key
|
||||||
|
when 'Cache-Control', 'Content-Disposition', 'Content-Encoding', 'Content-MD5', 'Expires', /^x-amz-meta-/
|
||||||
|
object[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
bucket[:objects][object_name] = object
|
bucket[:objects][object_name] = object
|
||||||
response.headers = {
|
response.headers = {
|
||||||
'Content-Length' => object['Size'],
|
'Content-Length' => object['Size'],
|
||||||
|
|
|
@ -73,12 +73,7 @@ module Fog
|
||||||
response.status = 412
|
response.status = 412
|
||||||
else
|
else
|
||||||
response.status = 200
|
response.status = 200
|
||||||
response.headers = {
|
response.headers = object.reject {|key, value| key == :body}
|
||||||
'Content-Length' => object['Size'],
|
|
||||||
'Content-Type' => object['Content-Type'],
|
|
||||||
'ETag' => object['ETag'],
|
|
||||||
'Last-Modified' => object['LastModified']
|
|
||||||
}
|
|
||||||
unless block_given?
|
unless block_given?
|
||||||
response.body = object[:body]
|
response.body = object[:body]
|
||||||
else
|
else
|
||||||
|
|
|
@ -59,13 +59,21 @@ module Fog
|
||||||
response.status = 200
|
response.status = 200
|
||||||
object = {
|
object = {
|
||||||
:body => data[:body],
|
:body => data[:body],
|
||||||
'Content-Type' => data[:headers]['Content-Type'],
|
'Content-Type' => options['Content-Type'] || data[:headers]['Content-Type'],
|
||||||
'ETag' => Fog::Google::Mock.etag,
|
'ETag' => Fog::Google::Mock.etag,
|
||||||
'Key' => object_name,
|
'Key' => object_name,
|
||||||
'LastModified' => Fog::Time.now.to_date_header,
|
'LastModified' => Fog::Time.now.to_date_header,
|
||||||
'Size' => data[:headers]['Content-Length'],
|
'Size' => options['Content-Length'] || data[:headers]['Content-Length'],
|
||||||
'StorageClass' => 'STANDARD'
|
'StorageClass' => 'STANDARD'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for key, value in options
|
||||||
|
case key
|
||||||
|
when 'Cache-Control', 'Content-Disposition', 'Content-Encoding', 'Content-MD5', 'Expires', /^x-goog-meta-/
|
||||||
|
object[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
bucket[:objects][object_name] = object
|
bucket[:objects][object_name] = object
|
||||||
response.headers = {
|
response.headers = {
|
||||||
'Content-Length' => object['Size'],
|
'Content-Length' => object['Size'],
|
||||||
|
|
Loading…
Add table
Reference in a new issue