summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2013-05-24 18:02:30 +0200
committerRoland Hedberg <roland.hedberg@adm.umu.se>2013-05-24 18:02:30 +0200
commite401cf25e2ace829f3438d06efb3e6749e84014b (patch)
tree183531718d373c5c8b0f50ee3614ccece39abed5 /src
parent77e5a407a52a380cff191ffcf5d74c8cf095b27d (diff)
downloadpysaml2-develop.tar.gz
In some case you want the url to be based on server_name/server_port and not http_host, now you can get what you want.develop
Diffstat (limited to 'src')
-rw-r--r--src/saml2/httputil.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/saml2/httputil.py b/src/saml2/httputil.py
index ae672e44..e2a0d492 100644
--- a/src/saml2/httputil.py
+++ b/src/saml2/httputil.py
@@ -154,16 +154,19 @@ def extract(environ, empty=False, err=False):
return formdata
-def geturl(environ, query=True, path=True):
+def geturl(environ, query=True, path=True, use_server_name=False):
"""Rebuilds a request URL (from PEP 333).
+ You may want to chose to use the environment variables
+ server_name and server_port instead of http_host in some case.
+ The parameter use_server_name allows you to chose.
:param query: Is QUERY_STRING included in URI (default: True)
:param path: Is path included in URI (default: True)
+ :param use_server_name: If SERVER_NAME/_HOST should be used instead of
+ HTTP_HOST
"""
url = [environ['wsgi.url_scheme'] + '://']
- if environ.get('SERVER_NAME'):
- url.append(environ['HTTP_HOST'])
- else:
+ if use_server_name:
url.append(environ['SERVER_NAME'])
if environ['wsgi.url_scheme'] == 'https':
if environ['SERVER_PORT'] != '443':
@@ -171,6 +174,8 @@ def geturl(environ, query=True, path=True):
else:
if environ['SERVER_PORT'] != '80':
url.append(':' + environ['SERVER_PORT'])
+ else:
+ url.append(environ['HTTP_HOST'])
if path:
url.append(getpath(environ))
if query and environ.get('QUERY_STRING'):