Merge pull request #1291 from umap-project/guess-mime-type-return

Avoid using a tuple as a content type when guessed
This commit is contained in:
Yohan Boniface 2023-09-01 17:24:03 +02:00 committed by GitHub
commit 6ce541e899
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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