Ticket #4986: get_host.patch
File get_host.patch, 854 bytes (added by , 17 years ago) |
---|
-
django/http/__init__.py
356 356 357 357 def get_host(request): 358 358 "Gets the HTTP host from the environment or request headers." 359 host = request.META.get('HTTP_X_FORWARDED_HOST', '') 359 host = (request.META.get('HTTP_X_FORWARDED_HOST') 360 or request.META.get('HTTP_HOST')) 360 361 if not host: 361 host = request.META.get('HTTP_HOST', '') 362 # Reconstruct host based on PEP333 363 host = request.META['SERVER_NAME'] 364 server_port = request.META['SERVER_PORT'] 365 if server_port != (request.is_secure() and 443 or 80): 366 host = '%s:%s' % (host, server_port) 362 367 return host 363 368 364 369 # It's neither necessary nor appropriate to use