From 121a5374d9ab72d561b5640536bc23bc507123d3 Mon Sep 17 00:00:00 2001 From: Hunt Xu Date: Fri, 13 Jul 2018 19:14:25 +0800 Subject: [PATCH] Fix function download content-type not set correctly Story: 2002979 Task: 22988 Change-Id: I998811a6bcf31f0a4e5125be6b9d50949199c0d8 --- qinling/api/controllers/v1/function.py | 3 +-- qinling_tempest_plugin/tests/api/test_functions.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qinling/api/controllers/v1/function.py b/qinling/api/controllers/v1/function.py index fa148ecb..5aa6549f 100644 --- a/qinling/api/controllers/v1/function.py +++ b/qinling/api/controllers/v1/function.py @@ -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 ) diff --git a/qinling_tempest_plugin/tests/api/test_functions.py b/qinling_tempest_plugin/tests/api/test_functions.py index d25deb93..71d4906e 100644 --- a/qinling_tempest_plugin/tests/api/test_functions.py +++ b/qinling_tempest_plugin/tests/api/test_functions.py @@ -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