Issue #573 resolved

wsgi server bug in mount-point resolution with multiple mounted applications

Anonymous created an issue

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

Reported by pmaupin@gmail.com

Comments (3)

  1. Anonymous

    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.:

    self.mount_points.sort() self.mount_points.reverse() self.mount_points = [(x+'/', y) for (x,y) in self.mount_points]

    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

  2. Log in to comment