Ticket #12464: 12464.patch
File 12464.patch, 2.2 KB (added by , 14 years ago) |
---|
-
django/core/handlers/base.py
215 215 if not script_url: 216 216 script_url = environ.get('REDIRECT_URL', u'') 217 217 if script_url: 218 return force_unicode(script_url[:-len(environ.get('PATH_INFO', ''))]) 218 path_info = environ.get('PATH_INFO', u'') 219 if path_info: 220 script_url = script_url[:-len(path_info)] 221 return force_unicode(script_url) 219 222 return force_unicode(environ.get('SCRIPT_NAME', u'')) 220 223 -
tests/regressiontests/requests/tests.py
3 3 import unittest 4 4 5 5 from django.http import HttpRequest, HttpResponse, parse_cookie 6 from django.core.handlers.base import get_script_name 6 7 from django.core.handlers.wsgi import WSGIRequest 7 8 from django.core.handlers.modpython import ModPythonRequest 8 9 from django.utils.http import cookie_date 10 from django.conf import settings 9 11 10 12 class RequestsTests(unittest.TestCase): 11 13 … … 45 47 self.assertEqual(request.COOKIES.keys(), []) 46 48 self.assertEqual(request.META.keys(), []) 47 49 50 def test_get_script_name(self): 51 'get_script_name is computing the script name correctly' 52 old = getattr(settings,'FORCE_SCRIPT_NAME',None) 53 if old: 54 settings.FORCE_SCRIPT_NAME = None 55 self.assertEqual(get_script_name({'PATH_INFO': u'', 'SCRIPT_URL': u'test'}), u'test') 56 self.assertEqual(get_script_name({'PATH_INFO': u'/path', 'SCRIPT_URL': u'test/path'}), u'test') 57 self.assertEqual(get_script_name({'PATH_INFO': u'/path', 'REDIRECT_URL': u'test/path'}), u'test') 58 self.assertEqual(get_script_name({'SCRIPT_NAME': u'test'}), u'test') 59 settings.FORCE_SCRIPT_NAME = u'forced' 60 self.assertEqual(get_script_name({'SCRIPT_NAME': u'test'}), u'forced') 61 settings.FORCE_SCRIPT_NAME = old 62 48 63 def test_parse_cookie(self): 49 64 self.assertEqual(parse_cookie('invalid:key=true'), {}) 50 65