From 3f2254aee049a4ed610125618201a35a8c52b224 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 7 Dec 2014 22:45:00 +0800 Subject: [PATCH] Fix missing Content-Type headers for posters and banners --- CHANGES.md | 1 + sickbeard/webserve.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f155ee05..2a230585 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ * Fix startup code order and general re-factoring (adapted from midgetspy/Sick-Beard) * Add database migration code * Change KickassTorrents provider URLs +* Fix missing Content-Type headers for posters and banners [develop changelog] * Add TVRage network name standardization diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index a067b472..62e1db58 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -61,6 +61,7 @@ from sickbeard.scene_numbering import get_scene_numbering, set_scene_numbering, from sickbeard.blackandwhitelist import BlackAndWhiteList from browser import WebFileBrowser +from mimetypes import MimeTypes from lib.dateutil import tz from lib.unrar2 import RarFile @@ -234,7 +235,9 @@ class MainHandler(RequestHandler): func = getattr(klass, 'index', None) if callable(func): - return func(**args) + out = func(**args) + self._headers = klass._headers + return out raise HTTPError(404) @@ -264,7 +267,7 @@ class MainHandler(RequestHandler): else: default_image_name = 'banner.png' - default_image_path = ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', 'slick', 'images', default_image_name) + image_path = ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', 'slick', 'images', default_image_name) if show and sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)): cache_obj = image_cache.ImageCache() @@ -279,10 +282,11 @@ class MainHandler(RequestHandler): image_file_name = cache_obj.banner_thumb_path(show) if ek.ek(os.path.isfile, image_file_name): - with file(image_file_name, 'rb') as img: - return img.read() + image_path = image_file_name - with file(default_image_path, 'rb') as img: + mime_type, encoding = MimeTypes().guess_type(image_path) + self.set_header('Content-Type', mime_type) + with file(image_path, 'rb') as img: return img.read() def setHomeLayout(self, layout):