from tornado import web
from .config import config

# pylint: disable=W0223
class BaseHandler(web.RequestHandler):
    '''
    A base request handler.
    '''

    def prepare(self):

        protocol = self.request.headers.get('x-forwarded-proto')

        if config.redirect_to_https and \
           self.request.method == 'GET' and \
           protocol == 'http':
            self.redirect('https://{}{}'.format(
                self.request.host.split(':'), self.request.path
            ), permanent=True)

@@ -455,16 +455,19 @@
 lit(':')
+%5B0%5D
 , self.r

Fix HTTP->HTTPS redirect host