Fix function download content-type not set correctly

Story: 2002979
Task: 22988

Change-Id: I998811a6bcf31f0a4e5125be6b9d50949199c0d8
This commit is contained in:
Hunt Xu 2018-07-13 19:14:25 +08:00
parent 83bf1657a1
commit 121a5374d9
2 changed files with 2 additions and 2 deletions

View File

@ -98,7 +98,7 @@ class FunctionsController(rest.RestController):
raise exc.InputException('Failed to validate object in Swift.')
@rest_utils.wrap_pecan_controller_exception
@pecan.expose()
@pecan.expose(content_type='application/zip')
@pecan.expose('json')
def get(self, id):
"""Get function information or download function package.
@ -139,7 +139,6 @@ class FunctionsController(rest.RestController):
pecan.response.app_iter = (f if isinstance(f, collections.Iterable)
else FileIter(f))
pecan.response.headers['Content-Type'] = 'application/zip'
pecan.response.headers['Content-Disposition'] = (
'attachment; filename="%s"' % id
)

View File

@ -48,6 +48,7 @@ class FunctionsTest(base.BaseQinlingTest):
# Download function package
resp, data = self.client.download_function(function_id)
self.assertEqual(200, resp.status)
self.assertEqual('application/zip', resp['content-type'])
self.assertEqual(os.path.getsize(self.python_zip_file), len(data))
# Delete function