From 6f78646ea2200fa2c5dd424589a6cae537f00deb Mon Sep 17 00:00:00 2001 From: Sivasathurappan Radhakrishnan Date: Thu, 17 Mar 2016 09:40:23 +0000 Subject: [PATCH] Add content-disposition header to tempurl request Added content-disposition header to HEAD tempurl request. As per HTTP docs[1] HEAD response must be identical to GET except return message-body response. [1]https://tools.ietf.org/html/rfc2616#section-9.4 Change-Id: Ie60a6fb632613055da5279db5b128ce5ee5172ae Closes-Bug:#1539805 --- test/unit/common/middleware/test_tempurl.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/unit/common/middleware/test_tempurl.py b/test/unit/common/middleware/test_tempurl.py index 0d5ed07111..40368f38a5 100644 --- a/test/unit/common/middleware/test_tempurl.py +++ b/test/unit/common/middleware/test_tempurl.py @@ -202,7 +202,7 @@ class TestTempURL(unittest.TestCase): self.assertEqual(req.environ['swift.authorize_override'], True) self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl') - def test_head_valid(self): + def test_head_valid_with_filename(self): method = 'HEAD' expires = int(time() + 86400) path = '/v1/a/c/o' @@ -211,11 +211,14 @@ class TestTempURL(unittest.TestCase): 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)}) + 'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s&' + 'filename=bob_killer.txt' % (sig, expires)}) self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')])) resp = req.get_response(self.tempurl) self.assertEqual(resp.status_int, 200) + self.assertEqual(resp.headers['content-disposition'], + 'attachment; filename="bob_killer.txt"; ' + + "filename*=UTF-8''bob_killer.txt") def test_head_and_get_headers_match(self): method = 'HEAD'