Use the ASGI raw_path
in the router
#1827
Replies: 6 comments 1 reply
-
To add to this, I would say that this is a bug, not an idea. Starlette behaviour of interpreting Screenshot: Also RFC 3986 section 2.2 states:
|
Beta Was this translation helpful? Give feedback.
-
How does Django and Flask behave? MREs are appreciated. |
Beta Was this translation helpful? Give feedback.
-
They are also in conflict with RFC 3986 and W3C recommendations, as far as I know. That doesn't makes things more correct. Apparently an implicit consequence of the wording of pep-3333 suggests this behaviour, but that is in conflict with the mentioned sources above, which are explicit on this behaviour, and should take precedence anyway. I have created an issue for this on pep-3333 itself, but there doesn't seem to be much interest in this issue. |
Beta Was this translation helpful? Give feedback.
-
For what it’s worth, I have encountered this in the past, and had to redesign my URL structure. I don’t have a strong opinion on what the right thing to do is but I know the current behavior can be a pain. |
Beta Was this translation helpful? Give feedback.
-
That's correct. This is because the While excluding In this case |
Beta Was this translation helpful? Give feedback.
-
I'm having to rewrite my API implementation to ingest all user-created strings using POST requests now because of this issue. Maybe that's the conventionally proper way to do it, but it definitely led me on a wild goose chase because I never expected a string encoded as a URI component would get treated as if it weren't by the API library I'm using. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be nice if the router could be configured to use the ASGI
raw_path
instead of thepath
when matching routes, right now, for example, the router cannot distinguish between requests made to/my/great/route
and/my%2Fgreat/route
because it seems like the scope'spath
property is pre-unquoted by the time the router gets a hold of it.I'd like to be able to define a set of routes which look like this for example:
•
/{param:path}/some/path
•
/{param:path}
And if I make a request for
/example%2Fsome%2Fpath
, I'd expect to match that latter route, but currently it matches to the former. Either converting the router so that it uses theraw_path
, or adding some flag to enable this would offer a lot of flexibility here!If anyone's curious about a concrete use case for this, I'm specifically interested in the IIIF Image API, where this ability to distinguish between these routes would be required. Currently this is something that WSGI/werkzeug seems to handle intuitively but it would be great to be able to use ASGI/starlette for this as well!
Beta Was this translation helpful? Give feedback.
All reactions