-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path pattern matching is case sensitive #2091
Comments
I also notice that https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/pattern_test.go |
my workaround is to have nginx do a case-insensitive location matching, and rewrite the url using regex captures to match the expected case of the gateway :(. like this : https://serverfault.com/questions/804533/nginx-case-insensitive-location-with-case-sensitive-proxy-pass I'm happy to contribute if it's something that makes sense, but maybe I'm the odd one here? |
Hi @serbrech, thanks for the report.
Do you have any link to an RFC or similar to support this? I dig a bit around and domains are case insensitive (RFC 4343), although, I haven't found any strict requirements for the rest of the URL. On stackoverflow there was a similar discussion with some examples where various sites implement it differently. I think this can be translated into a feature request. We should be backward compatible so we shouldn't change the current behaviour as others may depend on it but I don't see any problem with introducing a flag which would enable case insensitivity as you described it. |
I looked at the Pattern matcher and hoped for a simple fix. I naively tried to change the OpLit Of course it needs to be backward compatible to release it as a patch, but I do think that the right default should be case insensitive in a future version. So, as a feature, can we simply add this as an option argument to the muxer, like the if so, here is my minimal proposal : option 1: mux option
The Pattern struct is created in the template as a var. the template generation doesn't know about the mux options, so we need to use the option when calling We can either modify the Match signature, or we could do and finally, we change the pattern matching accordingly. Downside is, it's ON or OFF for the entire gateway. option 2: generator optionAnother possibility is to make it a generation parameter.
That also allows to define the option per route, and it can even become an annotation. The option still need to be exposed on Line 182 in 7db4bb7
I think that option 2 is much cleaner and more powerful, so that's what I'd suggest doing. full support for annotations and per route handling doesn't need to be there for a minimal implementation either. WDYT? |
@serbrech Thank you for the analysis! I agree that the option 2 is more powerful but I am afraid that it will break the backward compatibility. If we change The option 1 seems less powerful but, following the logic from the issue description, maybe it makes more sense to turn it on or off globally so that all paths are uniform. I don't quite see any use case why someone would like to decide that by path, excluding some legacy cases which I still think would be better to solve in nginx or similar. It is also safer in terms of backward compatibility. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
🐛 Bug Report
URLs are not supposed to be case sensitive, but when defining the gateways with :
get: "/some/{param}/CaseSensitive/{other_param}"
the GET request needs to match the casing of the pattern provided.
Of we don't match the casing, the gateway returns 404 Not Found
To Reproduce
see above
Expected behavior
(Write what you thought would happen.)
Actual Behavior
(Write what happened. Add screenshots, if applicable.)
Your Environment
(Environment name, version and operating system.)
The text was updated successfully, but these errors were encountered: