Changeset 6296
- Timestamp:
- 09/15/07 12:46:03 (1 year ago)
- Files:
-
- django/trunk/django/contrib/admin/views/doc.py (modified) (2 diffs)
- django/trunk/django/contrib/sites/models.py (modified) (2 diffs)
- django/trunk/django/core/handlers/base.py (modified) (1 diff)
- django/trunk/django/http/__init__.py (modified) (3 diffs)
- django/trunk/django/middleware/common.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/admin/views/doc.py
r5803 r6296 6 6 from django.shortcuts import render_to_response 7 7 from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist 8 from django.http import Http404 , get_host8 from django.http import Http404 9 9 from django.core import urlresolvers 10 10 from django.contrib.admin import utils … … 30 30 admin_root = request.path[:-len('doc/bookmarklets/')] 31 31 return render_to_response('admin_doc/bookmarklets.html', { 32 'admin_url': "%s://%s%s" % (request.is_secure() and 'https' or 'http', get_host(request), admin_root),32 'admin_url': "%s://%s%s" % (request.is_secure() and 'https' or 'http', request.get_host(), admin_root), 33 33 }, context_instance=RequestContext(request)) 34 34 bookmarklets = staff_member_required(bookmarklets) django/trunk/django/contrib/sites/models.py
r6180 r6296 1 1 from django.db import models 2 2 from django.utils.translation import ugettext_lazy as _ 3 from django.http import get_host4 3 5 4 SITE_CACHE = {} … … 55 54 """ 56 55 def __init__(self, request): 57 self.domain = self.name = get_host(request)56 self.domain = self.name = request.get_host() 58 57 59 58 def __unicode__(self): django/trunk/django/core/handlers/base.py
r6292 r6296 143 143 this function converts them to absolute paths. 144 144 """ 145 if 'Location' in response and http.get_host(request):145 if 'Location' in response and request.get_host(): 146 146 response['Location'] = request.build_absolute_uri(response['Location']) 147 147 return response django/trunk/django/http/__init__.py
r6235 r6296 44 44 45 45 __contains__ = has_key 46 47 def get_host(self): 48 "Returns the HTTP host using the environment or request headers." 49 # We try three options, in order of decreasing preference. 50 host = self.META.get('HTTP_X_FORWARDED_HOST', '') 51 if 'HTTP_HOST' in self.META: 52 host = self.META['HTTP_HOST'] 53 else: 54 # Reconstruct the host using the algorithm from PEP 333. 55 host = self.META['SERVER_NAME'] 56 server_port = self.META['SERVER_PORT'] 57 if server_port != (self.is_secure() and 443 or 80): 58 host = '%s:%s' % (host, server_port) 59 return host 46 60 47 61 def get_full_path(self): … … 58 72 if not ':' in location: 59 73 current_uri = '%s://%s%s' % (self.is_secure() and 'https' or 'http', 60 get_host(self), self.path)74 self.get_host(), self.path) 61 75 location = urljoin(current_uri, location) 62 76 return location … … 382 396 HttpResponse.__init__(self, *args, **kwargs) 383 397 398 # A backwards compatible alias for HttpRequest.get_host. 384 399 def get_host(request): 385 "Gets the HTTP host from the environment or request headers." 386 # We try three options, in order of decreasing preference. 387 host = request.META.get('HTTP_X_FORWARDED_HOST', '') 388 if 'HTTP_HOST' in request.META: 389 host = request.META['HTTP_HOST'] 390 else: 391 # Reconstruct the host using the algorithm from PEP 333. 392 host = request.META['SERVER_NAME'] 393 server_port = request.META['SERVER_PORT'] 394 if server_port != (request.is_secure() and 443 or 80): 395 host = '%s:%s' % (host, server_port) 396 return host 400 return request.get_host() 397 401 398 402 # It's neither necessary nor appropriate to use django/trunk/django/middleware/common.py
r5878 r6296 33 33 34 34 # Check for a redirect based on settings.APPEND_SLASH and settings.PREPEND_WWW 35 host = http.get_host(request)35 host = request.get_host() 36 36 old_url = [host, request.path] 37 37 new_url = old_url[:] … … 62 62 # If the referrer was from an internal link or a non-search-engine site, 63 63 # send a note to the managers. 64 domain = http.get_host(request)64 domain = request.get_host() 65 65 referer = request.META.get('HTTP_REFERER', None) 66 66 is_internal = _is_internal_request(domain, referer)
