From e06b44a28f6d580e358424d6622502f8806333d9 Mon Sep 17 00:00:00 2001 From: benoitc Date: Wed, 26 May 2010 16:27:12 +0200 Subject: [PATCH] fix issue #51. Support https schema. Pas an Http header to gunicorn : X-Forwarded-Protocol=https , X-Forwarded-Ssl=on --- gunicorn/http/request.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gunicorn/http/request.py b/gunicorn/http/request.py index b8144a29..cdef120c 100644 --- a/gunicorn/http/request.py +++ b/gunicorn/http/request.py @@ -102,6 +102,12 @@ class Request(object): client_address = self.client_address or "127.0.0.1" forward_adress = self.parser.headers_dict.get('X-Forwarded-For', client_address) + + if self.parser.headers_dict.get("X-Forwarded-Protocol") == "https" or \ + self.parser.headers_dict.get("X-Forwarded-Ssl") == "on": + url_scheme = "https" + else: + url_scheme = "http" if isinstance(forward_adress, basestring): # we only took the last one @@ -129,7 +135,7 @@ class Request(object): path_info = path_info.split(script_name, 1)[-1] environ = { - "wsgi.url_scheme": 'http', + "wsgi.url_scheme": url_scheme, "wsgi.input": wsgi_input, "wsgi.errors": sys.stderr, "wsgi.version": (1, 0),