From 38d04e0bb9544a1516fc49c08a7c28b1f68a304a Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Sun, 26 Feb 2012 22:35:36 -0800 Subject: [PATCH] Show proper scheme in urls --- httpbin/helpers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/httpbin/helpers.py b/httpbin/helpers.py index 3b73c8f..86a3676 100644 --- a/httpbin/helpers.py +++ b/httpbin/helpers.py @@ -6,7 +6,6 @@ httpbin.helpers This module provides helper functions for httpbin. """ - import json from hashlib import md5 from werkzeug.http import parse_authorization_header @@ -73,6 +72,11 @@ def get_headers(hide_env=True): return CaseInsensitiveDict(headers.items()) +def get_url(): + scheme = request.headers.get("X-Forwarded-Proto", "http") + return request.url.replace("http", scheme) + + def get_dict(*keys, **extras): """Returns request dict of given keys.""" @@ -102,7 +106,7 @@ def get_dict(*keys, **extras): d = dict( - url=request.url, + url=get_url(), args=request.args, form=form, data=data,