def get_url(request):
protocol = request.headers.get('<STR_LIT>') or request.headers.get('<STR_LIT>')<EOL>if protocol is None and request.headers.get('<STR_LIT>') == '<STR_LIT>':<EOL><INDENT>protocol = '<STR_LIT>'<EOL><DEDENT>if protocol is None:<EOL><INDENT>return request.url<EOL><DEDENT>url = list(urlparse(request.url))<EOL>url[<NUM_LIT:0>] = protocol<EOL>return urlunparse(url)<EOL>
Since we might be hosted behind a proxy, we need to check the
X-Forwarded-Proto, X-Forwarded-Protocol, or X-Forwarded-SSL headers
to find out what protocol was used to access us.