But path includes the root_path, while the WSGI spec (PEP 3333) says:
SCRIPT_NAME
The initial portion of the request URL’s “path” that corresponds to the application object, so that the application knows its virtual “location”. This may be an empty string, if the application corresponds to the “root” of the server.
PATH_INFO
The remainder of the request URL’s “path”, designating the virtual “location” of the request’s target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash.
See also #424 and especially this comment by @tiangolo for background.
PATH_INFO
seems to be set incorrectly byWsgiToAsgiInstance.build_environ()
. Currently, it's just copied over from thepath
ASGI scope:https://github.com/django/asgiref/blob/8cf847a27da34e7d4490b41b682f657b4f302eaa/asgiref/wsgi.py#L57-L70
But
path
includes theroot_path
, while the WSGI spec (PEP 3333) says:A holdover from the CGI spec (RFC 3875).
When starlette fixed their path handling, they changed their WSGI adapter to account for that:
https://github.com/encode/starlette/blob/7533b61a34f8b0dcb5fc35c717d458439f0baf18/starlette/middleware/wsgi.py#L24-L42
I think asgiref's adapter should do the same.