2020-04-22 14:58:01 +02:00
|
|
|
#!/usr/bin/env python
|
2024-11-06 14:53:25 +01:00
|
|
|
from typing import Any
|
|
|
|
from collections.abc import 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)
|