Issues with the URL encoding

36 views
Skip to first unread message

galfy

unread,
May 21, 2013, 12:08:44 PM5/21/13
to gev...@googlegroups.com
I am trying to use the information from the pywsgi server in order to implement a digest authentication. And I am meeting some problems that I do not know how to solve elegantly. For example if the URI sent to the server is something like  "/test%20(2).txt" the PyWSGI will unqote it and save it in env['PATH_INFO'] as "/test (2).txt". So far so good. In order to build correct digest authentication I need to know the correct original URI. So I tried to use urllib.quote(env['PATH_INFO']) but this one produces a string(/test%20%282%29.txt) the differs from the original one(/test%20(2).txt). Any idea how I can get the original one without hacking the pywsgi server and set it as a key in the env dict?

Regards,
 Gal

Denis Bilenko

unread,
May 21, 2013, 12:14:57 PM5/21/13
to gev...@googlegroups.com
Basically, this is the flaw in WSGI spec - as is it does not store
unquote path info in environ. I had similar problem and I ended up
using this class: https://gist.github.com/denik/5621051

galfy

unread,
May 24, 2013, 4:19:05 AM5/24/13
to gev...@googlegroups.com
Thank you Denis, the suggestion above worked for me.
Reply all
Reply to author
Forward
0 new messages