Commit a0c2eb46 authored by Claude Paroz's avatar Claude Paroz
Browse files

Fixed #23960 -- Removed http.fix_location_header

Thanks Carl Meyer for the report and Tim Graham for the review.
parent 0339844b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ logger = logging.getLogger('django.request')
class BaseHandler(object):
    # Changes that are always applied to a response (in this order).
    response_fixes = [
        http.fix_location_header,
        http.conditional_content_removal,
    ]

+3 −3
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ from django.http.response import (
    HttpResponseNotFound, HttpResponseNotAllowed, HttpResponseGone,
    HttpResponseServerError, Http404, BadHeaderError, JsonResponse,
)
from django.http.utils import fix_location_header, conditional_content_removal
from django.http.utils import conditional_content_removal

__all__ = [
    'SimpleCookie', 'parse_cookie', 'HttpRequest', 'QueryDict',
@@ -17,6 +17,6 @@ __all__ = [
    'HttpResponsePermanentRedirect', 'HttpResponseNotModified',
    'HttpResponseBadRequest', 'HttpResponseForbidden', 'HttpResponseNotFound',
    'HttpResponseNotAllowed', 'HttpResponseGone', 'HttpResponseServerError',
    'Http404', 'BadHeaderError', 'fix_location_header', 'JsonResponse',
    'FileResponse', 'conditional_content_removal',
    'Http404', 'BadHeaderError', 'JsonResponse', 'FileResponse',
    'conditional_content_removal',
]
+0 −13
Original line number Diff line number Diff line
@@ -9,19 +9,6 @@ Functions that modify an HTTP request or response in some way.
# universally applicable.


def fix_location_header(request, response):
    """
    Ensures that we always use an absolute URI in any location header in the
    response. This is required by RFC 2616, section 14.30.

    Code constructing response objects is free to insert relative paths, as
    this function converts them to absolute paths.
    """
    if 'Location' in response:
        response['Location'] = request.build_absolute_uri(response['Location'])
    return response


def conditional_content_removal(request, response):
    """
    Removes the content of responses for HEAD requests, 1xx, 204 and 304
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ class CommonMiddleware(object):
        if new_url == old_url:
            # No redirects required.
            return
        if new_url[0]:
        if new_url[0] != old_url[0]:
            newurl = "%s://%s%s" % (
                request.scheme,
                new_url[0], urlquote(new_url[1]))
+6 −10
Original line number Diff line number Diff line
@@ -40,17 +40,13 @@ class LocaleMiddleware(object):

            if path_valid:
                script_prefix = get_script_prefix()
                language_url = "%s://%s%s" % (
                    request.scheme,
                    request.get_host(),
                    # insert language after the script prefix and before the
                # Insert language after the script prefix and before the
                # rest of the URL
                    request.get_full_path().replace(
                language_url = request.get_full_path().replace(
                    script_prefix,
                    '%s%s/' % (script_prefix, language),
                    1
                )
                )
                return self.response_redirect_class(language_url)

        if not (self.is_language_prefix_patterns_used
Loading