From 6cacc7122bdda8d9f2c293b3f24e03177034d46f Mon Sep 17 00:00:00 2001 From: David Larlet Date: Tue, 29 Aug 2023 15:24:58 -0400 Subject: [PATCH] Avoid using a tuple as a content type when guessed Only use the content type with mimetypes.guess_type --- umap/views.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/umap/views.py b/umap/views.py index d8935957..f33296d9 100644 --- a/umap/views.py +++ b/umap/views.py @@ -378,15 +378,15 @@ class AjaxProxy(View): return HttpResponseBadRequest("Timeout") else: status_code = proxied_request.code - mimetype = proxied_request.headers.get( - "Content-Type" - ) or mimetypes.guess_type( - url - ) # noqa + content_type = proxied_request.headers.get("Content-Type") + if not content_type: + content_type, encoding = mimetypes.guess_type(url) content = proxied_request.read() # Quick hack to prevent Django from adding a Vary: Cookie header self.request.session.accessed = False - response = HttpResponse(content, status=status_code, content_type=mimetype) + response = HttpResponse( + content, status=status_code, content_type=content_type + ) if ttl: response["X-Accel-Expires"] = ttl return response