diff --git a/django/contrib/flatpages/views.py b/django/contrib/flatpages/views.py
index 497979e497..20e930f343 100644
--- a/django/contrib/flatpages/views.py
+++ b/django/contrib/flatpages/views.py
@@ -1,7 +1,6 @@
from django.conf import settings
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import get_current_site
-from django.core.xheaders import populate_xheaders
from django.http import Http404, HttpResponse, HttpResponsePermanentRedirect
from django.shortcuts import get_object_or_404
from django.template import loader, RequestContext
@@ -70,5 +69,4 @@ def render_flatpage(request, f):
'flatpage': f,
})
response = HttpResponse(t.render(c))
- populate_xheaders(request, response, FlatPage, f.id)
return response
diff --git a/django/core/xheaders.py b/django/core/xheaders.py
deleted file mode 100644
index 3766628c98..0000000000
--- a/django/core/xheaders.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""
-Pages in Django can are served up with custom HTTP headers containing useful
-information about those pages -- namely, the content type and object ID.
-
-This module contains utility functions for retrieving and doing interesting
-things with these special "X-Headers" (so called because the HTTP spec demands
-that custom headers are prefixed with "X-").
-
-Next time you're at slashdot.org, watch out for X-Fry and X-Bender. :)
-"""
-
-def populate_xheaders(request, response, model, object_id):
- """
- Adds the "X-Object-Type" and "X-Object-Id" headers to the given
- HttpResponse according to the given model and object_id -- but only if the
- given HttpRequest object has an IP address within the INTERNAL_IPS setting
- or if the request is from a logged in staff member.
- """
- from django.conf import settings
- if (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS
- or (hasattr(request, 'user') and request.user.is_active
- and request.user.is_staff)):
- response['X-Object-Type'] = "%s.%s" % (model._meta.app_label, model._meta.model_name)
- response['X-Object-Id'] = str(object_id)
diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt
index 60b3381dd6..452baf7f76 100644
--- a/docs/releases/1.6.txt
+++ b/docs/releases/1.6.txt
@@ -491,6 +491,11 @@ Miscellaneous
memcache backend no longer uses the default timeout, and now will
set-and-expire-immediately the value.
+* The ``django.contrib.flatpages`` app used to set custom HTTP headers for
+ debugging purposes. This functionality was not documented and made caching
+ ineffective so it has been removed, along with its generic implementation,
+ previously available in ``django.core.xheaders``.
+
Features deprecated in 1.6
==========================
diff --git a/tests/special_headers/__init__.py b/tests/special_headers/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/tests/special_headers/fixtures/data.xml b/tests/special_headers/fixtures/data.xml
deleted file mode 100644
index 7e60d45199..0000000000
--- a/tests/special_headers/fixtures/data.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
diff --git a/tests/special_headers/models.py b/tests/special_headers/models.py
deleted file mode 100644
index e05c5a6920..0000000000
--- a/tests/special_headers/models.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from django.db import models
-
-
-class Article(models.Model):
- text = models.TextField()
diff --git a/tests/special_headers/templates/special_headers/article_detail.html b/tests/special_headers/templates/special_headers/article_detail.html
deleted file mode 100644
index 3cbd38cb7e..0000000000
--- a/tests/special_headers/templates/special_headers/article_detail.html
+++ /dev/null
@@ -1 +0,0 @@
-{{ object }}
diff --git a/tests/special_headers/tests.py b/tests/special_headers/tests.py
deleted file mode 100644
index b4b704ae21..0000000000
--- a/tests/special_headers/tests.py
+++ /dev/null
@@ -1,62 +0,0 @@
-from django.contrib.auth.models import User
-from django.test import TestCase
-from django.test.utils import override_settings
-
-
-@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
-class SpecialHeadersTest(TestCase):
- fixtures = ['data.xml']
- urls = 'special_headers.urls'
-
- def test_xheaders(self):
- user = User.objects.get(username='super')
- response = self.client.get('/special_headers/article/1/')
- self.assertFalse('X-Object-Type' in response)
- self.client.login(username='super', password='secret')
- response = self.client.get('/special_headers/article/1/')
- self.assertTrue('X-Object-Type' in response)
- user.is_staff = False
- user.save()
- response = self.client.get('/special_headers/article/1/')
- self.assertFalse('X-Object-Type' in response)
- user.is_staff = True
- user.is_active = False
- user.save()
- response = self.client.get('/special_headers/article/1/')
- self.assertFalse('X-Object-Type' in response)
-
- def test_xview_func(self):
- user = User.objects.get(username='super')
- response = self.client.head('/special_headers/xview/func/')
- self.assertFalse('X-View' in response)
- self.client.login(username='super', password='secret')
- response = self.client.head('/special_headers/xview/func/')
- self.assertTrue('X-View' in response)
- self.assertEqual(response['X-View'], 'special_headers.views.xview')
- user.is_staff = False
- user.save()
- response = self.client.head('/special_headers/xview/func/')
- self.assertFalse('X-View' in response)
- user.is_staff = True
- user.is_active = False
- user.save()
- response = self.client.head('/special_headers/xview/func/')
- self.assertFalse('X-View' in response)
-
- def test_xview_class(self):
- user = User.objects.get(username='super')
- response = self.client.head('/special_headers/xview/class/')
- self.assertFalse('X-View' in response)
- self.client.login(username='super', password='secret')
- response = self.client.head('/special_headers/xview/class/')
- self.assertTrue('X-View' in response)
- self.assertEqual(response['X-View'], 'special_headers.views.XViewClass')
- user.is_staff = False
- user.save()
- response = self.client.head('/special_headers/xview/class/')
- self.assertFalse('X-View' in response)
- user.is_staff = True
- user.is_active = False
- user.save()
- response = self.client.head('/special_headers/xview/class/')
- self.assertFalse('X-View' in response)
diff --git a/tests/special_headers/urls.py b/tests/special_headers/urls.py
deleted file mode 100644
index f7ba141207..0000000000
--- a/tests/special_headers/urls.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# coding: utf-8
-from __future__ import absolute_import
-
-from django.conf.urls import patterns
-
-from . import views
-from .models import Article
-
-urlpatterns = patterns('',
- (r'^special_headers/article/(?P\d+)/$', views.xview_xheaders),
- (r'^special_headers/xview/func/$', views.xview_dec(views.xview)),
- (r'^special_headers/xview/class/$', views.xview_dec(views.XViewClass.as_view())),
-)
diff --git a/tests/special_headers/views.py b/tests/special_headers/views.py
deleted file mode 100644
index a8bbd6542e..0000000000
--- a/tests/special_headers/views.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from django.core.xheaders import populate_xheaders
-from django.http import HttpResponse
-from django.utils.decorators import decorator_from_middleware
-from django.views.generic import View
-from django.middleware.doc import XViewMiddleware
-
-from .models import Article
-
-xview_dec = decorator_from_middleware(XViewMiddleware)
-
-def xview(request):
- return HttpResponse()
-
-def xview_xheaders(request, object_id):
- response = HttpResponse()
- populate_xheaders(request, response, Article, 1)
- return response
-
-class XViewClass(View):
- def get(self, request):
- return HttpResponse()