Skip to content

Commit

Permalink
Merge pull request #1307 from manics/binder_launch_host
Browse files Browse the repository at this point in the history
Set X-Binder-Launch-Host header or binder_launch_host parameter
  • Loading branch information
choldgraf authored Dec 17, 2019
2 parents f92e921 + ab0f7b2 commit f55f700
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions images/federation-redirect/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from tornado.log import enable_pretty_logging, app_log

from tornado.httpclient import AsyncHTTPClient, HTTPError, HTTPRequest
from tornado.httputil import HTTPHeaders
from tornado.httputil import HTTPHeaders, url_concat
from tornado.web import RequestHandler


Expand Down Expand Up @@ -125,6 +125,7 @@ async def get(self):

headers = self.request.headers.copy()
headers["Host"] = self.host[8:]
headers["X-Binder-Launch-Host"] = "https://mybinder.org/"

body = self.request.body
if not body:
Expand Down Expand Up @@ -191,7 +192,9 @@ async def get(self):

self.set_cookie("host", host_name, path=uri)

self.redirect(host_name + uri)
redirect = url_concat(host_name + uri, {'binder_launch_host': 'https://mybinder.org/'})
app_log.debug('Redirecting to {}'.format(redirect))
self.redirect(redirect, status=307)


class ActiveHostsHandler(RequestHandler):
Expand Down

0 comments on commit f55f700

Please sign in to comment.