Ticket #16705: 16705.patch
File 16705.patch, 5.8 KB (added by , 13 years ago) |
---|
-
django/test/client.py
182 182 """ 183 183 The base environment for a request. 184 184 """ 185 # This is a minimal valid WSGI environ dictionary, plus HTTP_COOKIE 186 # for cookie support. Empty strings are omitted. 187 # See http://www.python.org/dev/peps/pep-3333/#environ-variables 185 188 environ = { 186 189 'HTTP_COOKIE': self.cookies.output(header='', sep='; '), 187 'PATH_INFO': '/',188 'QUERY_STRING': '',189 'REMOTE_ADDR': '127.0.0.1',190 190 'REQUEST_METHOD': 'GET', 191 'SCRIPT_NAME': '',192 191 'SERVER_NAME': 'testserver', 193 192 'SERVER_PORT': '80', 194 193 'SERVER_PROTOCOL': 'HTTP/1.1', 195 194 'wsgi.version': (1,0), 196 195 'wsgi.url_scheme': 'http', 196 'wsgi.input': FakePayload(''), 197 197 'wsgi.errors': self.errors, 198 198 'wsgi.multiprocess': True, 199 199 'wsgi.multithread': False, … … 235 235 'PATH_INFO': self._get_path(parsed), 236 236 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 237 237 'REQUEST_METHOD': 'GET', 238 'wsgi.input': FakePayload('')239 238 } 240 239 r.update(extra) 241 240 return self.request(**r) … … 267 266 'PATH_INFO': self._get_path(parsed), 268 267 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 269 268 'REQUEST_METHOD': 'HEAD', 270 'wsgi.input': FakePayload('')271 269 } 272 270 r.update(extra) 273 271 return self.request(**r) … … 280 278 'PATH_INFO': self._get_path(parsed), 281 279 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 282 280 'REQUEST_METHOD': 'OPTIONS', 283 'wsgi.input': FakePayload('')284 281 } 285 282 r.update(extra) 286 283 return self.request(**r) … … 311 308 'PATH_INFO': self._get_path(parsed), 312 309 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 313 310 'REQUEST_METHOD': 'DELETE', 314 'wsgi.input': FakePayload('')315 311 } 316 312 r.update(extra) 317 313 return self.request(**r) -
django/views/generic/simple.py
48 48 from the request is appended to the URL. 49 49 50 50 """ 51 args = request.META ["QUERY_STRING"]51 args = request.META.get('QUERY_STRING', '') 52 52 if args and query_string and url is not None: 53 53 url = "%s?%s" % (url, args) 54 54 -
django/views/generic/base.py
140 140 are provided as kwargs to this method. 141 141 """ 142 142 if self.url: 143 args = self.request.META ["QUERY_STRING"]143 args = self.request.META.get('QUERY_STRING', '') 144 144 if args and self.query_string: 145 145 url = "%s?%s" % (self.url, args) 146 146 else: -
django/middleware/common.py
85 85 new_url[0], urlquote(new_url[1])) 86 86 else: 87 87 newurl = urlquote(new_url[1]) 88 if request. GET:88 if request.META.get('QUERY_STRING', ''): 89 89 newurl += '?' + request.META['QUERY_STRING'] 90 90 return http.HttpResponsePermanentRedirect(newurl) 91 91 -
tests/regressiontests/views/tests/generic/simple.py
47 47 response = self.client.get('/simple/redirect_to_query/?param1=foo¶m2=bar') 48 48 self.assertEqual(response.status_code, 301) 49 49 self.assertEqual('http://testserver/simple/target/?param1=foo¶m2=bar', response['Location']) 50 51 def test_redirect_to_when_meta_contains_no_query_string(self): 52 "regression for #16705" 53 # we can't use self.client.get because it always sets QUERY_STRING 54 response = self.client.request(PATH_INFO='/simple/redirect_to/') 55 self.assertEqual(response.status_code, 301) 56 -
tests/regressiontests/generic_views/base.py
248 248 response = RedirectView.as_view()(self.rf.get('/foo/')) 249 249 self.assertEqual(response.status_code, 410) 250 250 251 def test_perman aent_redirect(self):251 def test_permanent_redirect(self): 252 252 "Default is a permanent redirect" 253 253 response = RedirectView.as_view(url='/bar/')(self.rf.get('/foo/')) 254 254 self.assertEqual(response.status_code, 301) … … 305 305 response = RedirectView.as_view(url='/bar/')(self.rf.delete('/foo/')) 306 306 self.assertEqual(response.status_code, 301) 307 307 self.assertEqual(response['Location'], '/bar/') 308 309 def test_redirect_when_meta_contains_no_query_string(self): 310 "regression for #16705" 311 # we can't use self.rf.get because it always sets QUERY_STRING 312 response = RedirectView.as_view(url='/bar/')(self.rf.request(PATH_INFO='/foo/')) 313 self.assertEqual(response.status_code, 301)