BGP-Ranking/website/web/proxied.py

18 lines
509 B
Python
Raw Normal View History

2021-12-06 14:30:08 +01:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from typing import Any, MutableMapping
class ReverseProxied():
def __init__(self, app: Any) -> None:
self.app = app
def __call__(self, environ: MutableMapping[str, Any], start_response: Any) -> Any:
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)