lookyloo/website/web/proxied.py

18 lines
509 B
Python
Raw Normal View History

2020-04-22 14:58:01 +02:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
2021-09-07 12:59:31 +02:00
from typing import Any, MutableMapping
2020-04-22 14:58:01 +02:00
class ReverseProxied():
2020-05-18 18:32:59 +02:00
def __init__(self, app: Any) -> None:
2020-04-22 14:58:01 +02:00
self.app = app
2020-05-18 18:32:59 +02:00
def __call__(self, environ: MutableMapping[str, Any], start_response: Any) -> Any:
2020-04-22 14:58:01 +02:00
scheme = environ.get('HTTP_X_FORWARDED_PROTO')
if not scheme:
scheme = environ.get('HTTP_X_SCHEME')
if scheme:
environ['wsgi.url_scheme'] = scheme
return self.app(environ, start_response)