From 7d3fe51100302f2c1af00a343c17940e530b4dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Fri, 26 Apr 2019 10:55:32 +0000 Subject: [FIX] http,web,website_*: return the correct Content-Type for images * = website_profile, website_slides Before this commit, the returned Content-Type was not always correct, for example if the image tool was changing the format, which happens when given a BMP (converted to PNG), or other types being converted to JPEG. The previous method `force_contenttype` was too specific and it wasn't available in every controller. It didn't even need to be a controller method because it didn't use self. Now we create a generic helper to ease updating headers. The Content-Type is only updated when it is safe to do. It is especially unsafe for example for SVG files. task-1958000 PR: #31811 --- addons/website_profile/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/website_profile/controllers/main.py') diff --git a/addons/website_profile/controllers/main.py b/addons/website_profile/controllers/main.py index 3b5bc7843bc..5d379643e5d 100644 --- a/addons/website_profile/controllers/main.py +++ b/addons/website_profile/controllers/main.py @@ -98,7 +98,7 @@ class WebsiteProfile(http.Controller): image_base64 = tools.image_process(image_base64, (width, height), crop=crop) content = base64.b64decode(image_base64) - headers.append(('Content-Length', len(content))) + headers = http.set_safe_image_headers(headers, content) response = request.make_response(content, headers) response.status_code = status return response -- cgit v1.2.3