Ticket #573 (defect)
Opened 2 years ago
Last modified 2 years ago
wsgi server bug in mount-point resolution with multiple mounted applications
Status: closed (fixed)
| Reported by: | pmaupin@gmail.com | Assigned to: | rdelon |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | CherryPy code | Keywords: | |
| Cc: |
Subversion revision 1374
In _cpwsgiserver.py, class HTTPRequest, method parse_request, the loop which sets self.wsgi_app, etc. will not always choose the correct application. Depth-first searching is necessary, but not sufficient, for this task.
Consider two applications, one mounted at "/", and one mounted at "/foo".
The resource "/foobar" is currently mapped as belonging to the "/foo" application. Worse, when the application receives the path, there is no distinction between "/foo/bar" and "/foobar" because the slash is stripped.
On a related note, I am not sure what the first test in this loop is for (path == "*"), but:
a) The test does not need to be inside the loop (could be before the loop); and
b) Choosing the application with the longest path probably violates the principle of least surprise here.
Regards, Pat Maupin
Change History
09/23/06 23:23:40: Modified by pmaupin@gmail.com
10/26/06 00:09:55: Modified by fumanchu
- status changed from new to closed.
- resolution set to fixed.
Fixed in [1413].


I've given this a little thought, and it seems to me that the best way to fix this is to:
a) Suffix each mount_point path with a slash when the server is initialized, e.g.:
and b)
Create a test_path, which is the path with a suffixed '/', for testing in the loop.
This would allow the same depth-first search to be used, with no additional per-request checking.
Regards, Pat