1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fix for tornado write issues on GET and POST methods.

This commit is contained in:
echel0n 2014-06-29 19:52:04 -07:00
parent 1145f90208
commit eece317c75

View File

@ -146,8 +146,7 @@ def redirect(url, permanent=False, status=None):
class MainHandler(RequestHandler): class MainHandler(RequestHandler):
def __init__(self, application, request, **kwargs): def __init__(self, application, request, **kwargs):
super(MainHandler, self).__init__(application, request, **kwargs) super(MainHandler, self).__init__(application, request, **kwargs)
sickbeard.REMOTE_IP = self.request.headers.get('X-Forwarded-For', sickbeard.REMOTE_IP = self.request.headers.get('X-Forwarded-For', self.request.headers.get('X-Real-Ip', self.request.remote_ip))
self.request.headers.get('X-Real-Ip', self.request.remote_ip))
def http_error_401_handler(self): def http_error_401_handler(self):
""" Custom handler for 401 error """ """ Custom handler for 401 error """
@ -165,7 +164,7 @@ class MainHandler(RequestHandler):
def write_error(self, status_code, **kwargs): def write_error(self, status_code, **kwargs):
if status_code == 401: if status_code == 401:
self.write(self.http_error_401_handler()) self.finish(self.http_error_401_handler())
elif status_code == 404: elif status_code == 404:
self.redirect('/home/') self.redirect('/home/')
else: else:
@ -217,13 +216,13 @@ class MainHandler(RequestHandler):
def get(self, *args, **kwargs): def get(self, *args, **kwargs):
try: try:
self.write(self._dispatch()) self.finish(self._dispatch())
except HTTPRedirect,inst: except HTTPRedirect,inst:
self.redirect(inst.url, inst.permanent, inst.status) self.redirect(inst.url, inst.permanent, inst.status)
def post(self, *args, **kwargs): def post(self, *args, **kwargs):
try: try:
self.write(self._dispatch()) self.finish(self._dispatch())
except HTTPRedirect, inst: except HTTPRedirect, inst:
self.redirect(inst.url, inst.permanent, inst.status) self.redirect(inst.url, inst.permanent, inst.status)