MCPcopy Create free account
hub / github.com/internetarchive/openlibrary / https_middleware

Function https_middleware

scripts/affiliate_server.py:723–739  ·  view source on GitHub ↗

Hack to support https even when the app server http only. The nginx configuration has changed to add the following setting: proxy_set_header X-Scheme $scheme; Using that value to overwrite wsgi.url_scheme in the WSGI environ, which is used by all redirects and other utilities.

(app)

Source from the content-addressed store, hash-verified

721
722
723def https_middleware(app):
724 """Hack to support https even when the app server http only.
725
726 The nginx configuration has changed to add the following setting:
727
728 proxy_set_header X-Scheme $scheme;
729
730 Using that value to overwrite wsgi.url_scheme in the WSGI environ,
731 which is used by all redirects and other utilities.
732 """
733
734 def wrapper(environ, start_response):
735 if environ.get("HTTP_X_SCHEME") == "https":
736 environ["wsgi.url_scheme"] = "https"
737 return app(environ, start_response)
738
739 return wrapper
740
741
742def runfcgi(func, addr=("localhost", 8000)):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected