For some reason, Safari is sending two requests per page. When doing
so, the second request's environment variables are the same as the
previous sets (not previous requests) environment variables.
Take a look:
I've added the following to the beginning of process_request of the
WebpyApplication (line 180 of application.py):
print "SCRIPT_NAME: ", self._environ.get('SCRIPT_NAME','')
print "PATH_INFO: ", self._environ.get('PATH_INFO','')
url = quote(self._environ.get('SCRIPT_NAME',''))
url += quote(self._environ.get('PATH_INFO',''))
print "URL: ", url
The following is the output whenever I request a page in Safari:
1st request (/add/category):
SCRIPT_NAME
PATH_INFO /add/category
URL: /add/category
SCRIPT_NAME
PATH_INFO /add/category/
URL: /add/category/
SCRIPT_NAME
PATH_INFO /favicon.ico
URL: /favicon.ico
SCRIPT_NAME
PATH_INFO /add/category/
URL: /add/category/
2nd request (/add/note):
SCRIPT_NAME
PATH_INFO /add/note
URL: /add/note
SCRIPT_NAME
PATH_INFO /add/category/
URL: /add/category/
SCRIPT_NAME
PATH_INFO /favicon.ico
URL: /favicon.ico
SCRIPT_NAME
PATH_INFO /add/category/
URL: /add/category/
Even though I'm going to /add/note, the second request still thinks I'm
going to /add/category. When tested in Firefox, it will sometimes do
the double request, but the second request matches the first, so this
never happens.
And this only becomes a problem with the slash_append turned on as the
environment variables are passed and the function uses the second set
(which in turn, takes me back to /add/category when I want to go to
/add/note)
Why is this happening?
The second request was coming from a poorly coded constructor override.
I find it weird that it was not happening in Firefox, though...
I've corrected my code and everything works fine, but I did find one
real (not my mistake, promise) bug with the fix_slash method:
In application.py, fix_slash should be:
fix_slash(self.request.environ, True)
and not
fix_slash(self._eviron, True)