Ticket #3414: wsgi_path_from_many_params_2.diff.txt

File wsgi_path_from_many_params_2.diff.txt, 1.0 KB (added by Richard Davies <richard.davies@…>, 7 years ago)

Update to wsgi_path_from_many_params.diff which better handles QUERY_STRING

Line 
1Index: django/core/handlers/wsgi.py
2===================================================================
3--- django/core/handlers/wsgi.py        (revision 7995)
4+++ django/core/handlers/wsgi.py        (working copy)
5@@ -74,9 +74,15 @@
6
7 class WSGIRequest(http.HttpRequest):
8     def __init__(self, environ):
9-        self.environ = environ
10-        self.path = force_unicode(environ['PATH_INFO'])
11-        self.META = environ
12+        if environ['PATH_INFO']:
13+            self.path = force_unicode(environ['PATH_INFO'])
14+        elif environ.has_key('REDIRECT_URL') and environ['REDIRECT_URL']:
15+            self.path = force_unicode(environ['REDIRECT_URL'])
16+        else:
17+            self.path = force_unicode(environ.get('REQUEST_URI', '/').partition('?')[0])
18+        if environ.get('QUERY_STRING', '') == '':
19+            environ['QUERY_STRING'] = environ.get('REQUEST_URI', '').partition('?')[2]
20+        self.environ = self.META = environ
21         self.method = environ['REQUEST_METHOD'].upper()
22
23     def __repr__(self):
Back to Top