Merge "Handle tempurl Content-Disposition header missing from HEAD"
This commit is contained in:
commit
cfb0b6a029
@ -400,7 +400,7 @@ class TempURL(object):
|
||||
|
||||
def _start_response(status, headers, exc_info=None):
|
||||
headers = self._clean_outgoing_headers(headers)
|
||||
if env['REQUEST_METHOD'] == 'GET' and status[0] == '2':
|
||||
if env['REQUEST_METHOD'] in ('GET', 'HEAD') and status[0] == '2':
|
||||
# figure out the right value for content-disposition
|
||||
# 1) use the value from the query string
|
||||
# 2) use the value from the object metadata
|
||||
|
@ -215,6 +215,31 @@ class TestTempURL(unittest.TestCase):
|
||||
resp = req.get_response(self.tempurl)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
def test_head_and_get_headers_match(self):
|
||||
method = 'HEAD'
|
||||
expires = int(time() + 86400)
|
||||
path = '/v1/a/c/o'
|
||||
key = 'abc'
|
||||
hmac_body = '%s\n%s\n%s' % (method, expires, path)
|
||||
sig = hmac.new(key, hmac_body, sha1).hexdigest()
|
||||
req = self._make_request(path, keys=[key], environ={
|
||||
'REQUEST_METHOD': 'HEAD',
|
||||
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s'
|
||||
% (sig, expires)})
|
||||
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
|
||||
resp = req.get_response(self.tempurl)
|
||||
|
||||
get_method = 'GET'
|
||||
get_hmac_body = '%s\n%s\n%s' % (get_method, expires, path)
|
||||
get_sig = hmac.new(key, get_hmac_body, sha1).hexdigest()
|
||||
get_req = self._make_request(path, keys=[key], environ={
|
||||
'REQUEST_METHOD': 'GET',
|
||||
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s'
|
||||
% (get_sig, expires)})
|
||||
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
|
||||
get_resp = get_req.get_response(self.tempurl)
|
||||
self.assertEqual(resp.headers, get_resp.headers)
|
||||
|
||||
def test_get_valid_with_filename_and_inline(self):
|
||||
method = 'GET'
|
||||
expires = int(time() + 86400)
|
||||
|
Loading…
Reference in New Issue
Block a user