Fix missing Content-Type headers for posters and banners

This commit is contained in:
Adam 2014-12-07 22:45:00 +08:00 committed by Adam
parent 705c17a043
commit 3f2254aee0
2 changed files with 10 additions and 5 deletions

View file

@ -16,6 +16,7 @@
* Fix startup code order and general re-factoring (adapted from midgetspy/Sick-Beard) * Fix startup code order and general re-factoring (adapted from midgetspy/Sick-Beard)
* Add database migration code * Add database migration code
* Change KickassTorrents provider URLs * Change KickassTorrents provider URLs
* Fix missing Content-Type headers for posters and banners
[develop changelog] [develop changelog]
* Add TVRage network name standardization * Add TVRage network name standardization

View file

@ -61,6 +61,7 @@ from sickbeard.scene_numbering import get_scene_numbering, set_scene_numbering,
from sickbeard.blackandwhitelist import BlackAndWhiteList from sickbeard.blackandwhitelist import BlackAndWhiteList
from browser import WebFileBrowser from browser import WebFileBrowser
from mimetypes import MimeTypes
from lib.dateutil import tz from lib.dateutil import tz
from lib.unrar2 import RarFile from lib.unrar2 import RarFile
@ -234,7 +235,9 @@ class MainHandler(RequestHandler):
func = getattr(klass, 'index', None) func = getattr(klass, 'index', None)
if callable(func): if callable(func):
return func(**args) out = func(**args)
self._headers = klass._headers
return out
raise HTTPError(404) raise HTTPError(404)
@ -264,7 +267,7 @@ class MainHandler(RequestHandler):
else: else:
default_image_name = 'banner.png' 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)): if show and sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)):
cache_obj = image_cache.ImageCache() cache_obj = image_cache.ImageCache()
@ -279,10 +282,11 @@ class MainHandler(RequestHandler):
image_file_name = cache_obj.banner_thumb_path(show) image_file_name = cache_obj.banner_thumb_path(show)
if ek.ek(os.path.isfile, image_file_name): if ek.ek(os.path.isfile, image_file_name):
with file(image_file_name, 'rb') as img: image_path = image_file_name
return img.read()
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() return img.read()
def setHomeLayout(self, layout): def setHomeLayout(self, layout):