Mercurial > kallithea
comparison pylons_app/lib/middleware/https_fixup.py @ 204:a8ea3ce3cdc4
Created middleware package. Crated special middleware to handle https requests redirections.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 23 May 2010 00:54:22 +0200 |
parents | |
children | 3782a6d698af |
comparison
equal
deleted
inserted
replaced
203:be6d8aaddbd1 | 204:a8ea3ce3cdc4 |
---|---|
1 class HttpsFixup(object): | |
2 def __init__(self, app): | |
3 self.application = app | |
4 | |
5 def __call__(self, environ, start_response): | |
6 self.__fixup(environ) | |
7 return self.application(environ, start_response) | |
8 | |
9 | |
10 def __fixup(self, environ): | |
11 """Function to fixup the environ as needed. In order to use this | |
12 middleware you should set this header inside your | |
13 proxy ie. nginx, apache etc. | |
14 """ | |
15 proto = environ.get('HTTP_X_URL_SCHEME') | |
16 | |
17 if proto == 'https': | |
18 environ['wsgi.url_scheme'] = proto | |
19 else: | |
20 environ['wsgi.url_scheme'] = 'http' | |
21 return None |