mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-14 20:10:59 +00:00
Fixed content type header of frontend serve view
This commit is contained in:
parent
269cb95ed6
commit
f81385da31
2 changed files with 4 additions and 2 deletions
|
|
@ -171,7 +171,7 @@ class TestFrontendServeView(TestCase):
|
|||
|
||||
# Check response
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response['Content-Type'], 'image/jpeg')
|
||||
self.assertEqual(response['Content-Type'], 'image/png')
|
||||
|
||||
def test_get_invalid_signature(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from wsgiref.util import FileWrapper
|
||||
import imghdr
|
||||
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.http import HttpResponse
|
||||
|
|
@ -18,6 +19,7 @@ def serve(request, signature, image_id, filter_spec):
|
|||
try:
|
||||
rendition = image.get_rendition(filter_spec)
|
||||
rendition.file.open('rb')
|
||||
return HttpResponse(FileWrapper(rendition.file), content_type='image/jpeg')
|
||||
image_format = imghdr.what(rendition.file)
|
||||
return HttpResponse(FileWrapper(rendition.file), content_type='image/' + image_format)
|
||||
except InvalidFilterSpecError:
|
||||
return HttpResponse("Invalid filter spec: " + filter_spec, content_type='text/plain', status=400)
|
||||
|
|
|
|||
Loading…
Reference in a new issue