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)
* Add database migration code
* Change KickassTorrents provider URLs
* Fix missing Content-Type headers for posters and banners
[develop changelog]
* 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 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):