[elbe-devel] [PATCH 4/5] elbepack: daemon: properly maintain subapplications PATH_INFO

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon Jul 15 12:04:31 CEST 2024


The subapplications mounted via the WsgiDispatcher need their PATH_INFO
and SCRIPT_NAME maintained properly.
Use the utility function shift_path_info() from the stdlib to do so.
This also enables some more cleanups.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/commands/daemon.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/elbepack/commands/daemon.py b/elbepack/commands/daemon.py
index ca8a9cc1f982..3491092cd151 100644
--- a/elbepack/commands/daemon.py
+++ b/elbepack/commands/daemon.py
@@ -9,6 +9,7 @@ import importlib
 import os
 import socket
 import wsgiref.simple_server
+import wsgiref.util
 from pkgutil import iter_modules
 
 import elbepack.daemons
@@ -24,11 +25,9 @@ class _WsgiDispatcher:
         self.mapping = mapping
 
     def __call__(self, environ, start_response):
-        path_info = environ['PATH_INFO']
-        parts = path_info.split('/', maxsplit=2)
-        if len(parts) != 3:
+        app_name = wsgiref.util.shift_path_info(environ)
+        if app_name is None:
             return _not_found(start_response)
-        _, app_name, _ = parts
 
         app = self.mapping.get(app_name)
         if app is None:

-- 
2.45.2



More information about the elbe-devel mailing list