Skip to content

Commit

Permalink
handle proxied devel urls better
Browse files Browse the repository at this point in the history
  • Loading branch information
staffanm committed Jul 11, 2018
1 parent 8b7b3d0 commit 8c92f17
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ferenda/requesthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ def request_uri(self, environ):
rawuri = request_uri(environ)
uri = unquote(rawuri.encode("latin-1").decode("utf-8"))
if getattr(self.repo.config, 'develurl', None):
# in some circumstances, we might want to set develurl to
# https://... while the actual uri provided will be
# http://... (eg. due to TLS-terminating proxies and other
# things), so we change the protocol of the request to
# match the protocol as specified by config.develuri
uriproto = uri.split("://")[0]
develproto = self.repo.config.develurl.split("://")[0]
if uriproto != develproto:
uri = re.sub("^"+uriproto, develproto, uri)
uri = uri.replace(self.repo.config.develurl, self.repo.config.url)
return uri

Expand Down

0 comments on commit 8c92f17

Please sign in to comment.