You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After some testing and trying one of your suggestions, the only way we could make it work (which I assume its not the right way at all), was to change (to test it) the variable being read and received, in this case by Starlette
defbuild_environ(scope: Scope, body: Body) ->Environ:
""" Builds a scope and request body into a WSGI environ object. """script_name=scope.get("root_path", "").encode("utf8").decode("latin1")
path_info=scope["path"].encode("utf8").decode("latin1")
ifpath_info.startswith(script_name):
path_info=path_info[len(script_name):]
script_name_environ_var=os.environ.get("SCRIPT_NAME", "")
ifscript_name_environ_var:
script_name=unicode_to_wsgi(script_name_environ_var)
environ= {
"asgi.scope": scope,
"REQUEST_METHOD": scope["method"],
"SCRIPT_NAME": script_name,
"PATH_INFO": path_info,
"QUERY_STRING": scope["query_string"].decode("ascii"),
"SERVER_PROTOCOL": f"HTTP/{scope['http_version']}",
"wsgi.version": (1, 0),
"wsgi.url_scheme": scope.get("scheme", "http"),
"wsgi.input": body,
"wsgi.errors": sys.stdout,
"wsgi.multithread": True,
"wsgi.multiprocess": True,
"wsgi.run_once": False,
}
What made it work, was changing the path_info = scope["path"].encode("utf8").decode("latin1") to path_info = scope["route_path"].encode("utf8").decode("latin1") which it doesn't seem right to me since the path should have been the one being read, correct?
This is what I was trying to explain before. Somehow, I do not think the path is being updated properly or there is something else we might be missing.
So, on your middleware, that is what I found, or if you say it is correct (which I do believe it is), then to make it work, only changing the Starlette side to come back to
You can use starlette 0.32 and a2wsgi 1.8 first. Issues related to this are being discussed at django/asgiref#424. I want to wait for the results of the discussion before modifying starlette's PR.
Hey @abersheeran ,
I think here is more adequate since its related with this middleware. This is a continuation of the conversation we were having.
After the update to 1.9.0, this example is still not working. The 404 received is from flask which is great meaning its trying to understand it.
After some testing and trying one of your suggestions, the only way we could make it work (which I assume its not the right way at all), was to change (to test it) the variable being read and received, in this case by Starlette
What made it work, was changing the
path_info = scope["path"].encode("utf8").decode("latin1")
topath_info = scope["route_path"].encode("utf8").decode("latin1")
which it doesn't seem right to me since thepath
should have been the one being read, correct?This is what I was trying to explain before. Somehow, I do not think the
path
is being updated properly or there is something else we might be missing.So, on your middleware, that is what I found, or if you say it is correct (which I do believe it is), then to make it work, only changing the Starlette side to come back to
Which for my understanding, that won't be the case.
Do you have any thought on this? Because a lot of applications rely on this amazing work you have done.
The text was updated successfully, but these errors were encountered: