Commits

Anonymous committed 76d1f30

switch to permanent redirects; fixes #6

Comments (0)

Files changed (2)

localeurl/middleware.py

 from django.conf import settings
 import django.core.exceptions
-from django.http import HttpResponseRedirect
+from django.http import HttpResponsePermanentRedirect
 from django.utils import translation
 import localeurl
 from localeurl import utils
             if request.META.get("QUERY_STRING", ""):
                 locale_path = "%s?%s" % (locale_path,
                         request.META['QUERY_STRING'])
-            return HttpResponseRedirect(locale_path)
+            return HttpResponsePermanentRedirect(locale_path)
         request.path_info = path
         if not locale:
             try:

localeurl/tests.py

     def test_process_request(self):
         r1 = self.request_factory.get('/test/')
         r2 = self.middleware.process_request(r1)
-        self.assertEqual(302, r2.status_code)
+        self.assertEqual(301, r2.status_code)
         self.assertEqual('/en/test/', r2['Location'])
 
         r1 = self.request_factory.get('/test/?somevar=someval')
         r2 = self.middleware.process_request(r1)
-        self.assertEqual(302, r2.status_code)
+        self.assertEqual(301, r2.status_code)
         self.assertEqual('/en/test/?somevar=someval', r2['Location'])
 
         r1 = self.request_factory.get('/fr/test/')
 
         r1 = self.request_factory.get('/nl-be/test/independent/?foo=bar')
         r2 = self.middleware.process_request(r1)
-        self.assertEqual(302, r2.status_code)
+        self.assertEqual(301, r2.status_code)
         self.assertEqual('/test/independent/?foo=bar', r2['Location'])
 
     def test_process_request_no_default_prefix(self):
 
         r1 = self.request_factory.get('/en/test/foo/')
         r2 = self.middleware.process_request(r1)
-        self.assertEqual(302, r2.status_code)
+        self.assertEqual(301, r2.status_code)
         self.assertEqual('/test/foo/', r2['Location'])
 
         r1 = self.request_factory.get('/fr/test/foo/')