Index: django/http/__init__.py
===================================================================
--- django/http/__init__.py	(revision 5766)
+++ django/http/__init__.py	(working copy)
@@ -356,9 +356,14 @@
 
 def get_host(request):
     "Gets the HTTP host from the environment or request headers."
-    host = request.META.get('HTTP_X_FORWARDED_HOST', '')
+    host = (request.META.get('HTTP_X_FORWARDED_HOST')
+            or request.META.get('HTTP_HOST'))
     if not host:
-        host = request.META.get('HTTP_HOST', '')
+        # Reconstruct host based on PEP333
+        host = request.META['SERVER_NAME']
+        server_port = request.META['SERVER_PORT']
+        if server_port != (request.is_secure() and 443 or 80):
+            host = '%s:%s' % (host, server_port)
     return host
 
 # It's neither necessary nor appropriate to use
