Commit 37addba3 authored by Adrian Holovaty's avatar Adrian Holovaty
Browse files

Converted request.META['REQUEST_METHOD'] calls to request.method, throughout the Django codebase

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent b93de6a2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ class WSGIRequest(http.HttpRequest):

    def _load_post_and_files(self):
        # Populates self._post and self._files
        if self.environ['REQUEST_METHOD'] == 'POST':
        if self.method == 'POST':
            if self.environ.get('CONTENT_TYPE', '').startswith('multipart'):
                header_dict = dict([(k, v) for k, v in self.environ.items() if k.startswith('HTTP_')])
                header_dict['Content-Type'] = self.environ.get('CONTENT_TYPE', '')
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class CacheMiddleware(object):

    def process_request(self, request):
        "Checks whether the page is already cached and returns the cached version if available."
        if not request.META['REQUEST_METHOD'] in ('GET', 'HEAD') or request.GET:
        if not request.method in ('GET', 'HEAD') or request.GET:
            request._cache_update_cache = False
            return None # Don't bother checking the cache.

@@ -55,7 +55,7 @@ class CacheMiddleware(object):
        if not hasattr(request, '_cache_update_cache') or not request._cache_update_cache:
            # We don't need to update the cache, just return.
            return response
        if not request.META['REQUEST_METHOD'] == 'GET':
        if request.method != 'GET':
            # This is a stronger requirement than above. It is needed
            # because of interactions between this middleware and the
            # HTTPMiddleware, which throws the body of a HEAD-request
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ class CommonMiddleware(object):
        # trailing slash or a file extension.
        if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]):
            new_url[1] = new_url[1] + '/'
            if settings.DEBUG and request.META['REQUEST_METHOD'].lower() == 'post':
            if settings.DEBUG and request.method == 'POST':
                raise RuntimeError, "You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to %s%s (note the trailing slash), or set APPEND_SLASH=False in your Django settings." % (new_url[0], new_url[1])
        if new_url != old_url:
            # Redirect
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ class XViewMiddleware(object):
        with an x-header indicating the view function.  This is used by the
        documentation module to lookup the view function for an arbitrary page.
        """
        if request.META['REQUEST_METHOD'] == 'HEAD' and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
        if request.method == 'HEAD' and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
            response = http.HttpResponse()
            response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
            return response
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ class ConditionalGetMiddleware(object):
                response.content = ''
                response['Content-Length'] = '0'

        if request.META['REQUEST_METHOD'] == 'HEAD':
        if request.method == 'HEAD':
            response.content = ''

        return response
Loading