-
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
Fix path parsing to use URL.EscapedPath() instead of Path and unescape individual components #660
Conversation
…vidual components
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
CLAs look good, thanks! |
This looks like a really interesting patch. Can you add some tests that demonstrate the new behavior? |
Possibly more importantly, can you demonstrate old broken behavior and how the new code fixes it? |
I will most definitely add a test. I just wanted to solicit feedback on this to see if this would be something acceptable upstream before investing more time in this. |
@achew22, @ivucica -- I added a unit test which can reproduce broken behavior (before my fix) and verifies the desired behavior (after my fix). However, I am having trouble understanding the remaining node integration test failures:
It looks like this ABitOfEverything service has a
It seems that the test case itself would need to change. Can someone explain the meaning behind |
@yugui, now that I look at that, do you know why that is like that? My guess is that it strips the "strprefix/" from the beginning of the string value, but I don't understand why you wouldn't just put that outside the capture. Do you have any hints? |
I first thought this might be a case of https://tools.ietf.org/html/rfc6570 page 8 and page 21. My (untested) understanding was that passing However, I remembered seeing this syntax before in the wild. Here it is in pubsub v1's pubsub.proto. I think this might mean that the value |
I think that interpretation is correct. Cloud Endpoints's ESP: |
Reading through, I think I agree with your interpretation of the spec @ivucica. @jessesuen, I think that should be sufficient information to update the tests to reflect the new behavior. Does that work for you? |
Sorry, I was OOO the past week. If you mean moving |
Alternatively, do you believe that
into this:
|
On Fri, Jun 15, 2018 at 3:43 PM Jesse Suen ***@***.***> wrote:
Sorry, I was OOO the past week. If you mean moving strprefix/ outside the
capture, I will be happy to make this change. I'll update the PR.
I don't think moving it out is meant to be equivalent. Leaving it in says
"match this pattern if the template field's value starts with strprefix/".
When the template field's value is placed into a variable, strprefix/
remains inside.
That is: /abc/def/{ghi} is not equivalent to /abc/{ghi=def/*}. Given
/abc/def/blah, the former will produce ghi=blah, and the latter will
produce ghi=def/blah.
I don't know how widely this is used in general, but as you can see, proto
for Cloud Pubsub does use it and presumably depends on it. Without looking
at the code (no time!), I will assume gRPC-Gateway interprets this pattern
equivalent to Google Cloud Endpoints's REST frontend.
|
Bump, what's left to do before we can merge this? |
I believe error from #660 (comment) needs to be fixed? |
Please rebase on master for new CI functionality. |
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. |
This MR is still relevant and it is actually fixing a bug. @jessesuen any update on this? |
I'd be happy to review any new PRs to fix this. |
…th and unescape individual components Basically we want to route for instance http://example.com/resources/some%2Fpath/something from this http annotation : get: /resources/{key}/something We want the key field in gRPC to be able to contain 0 or many slashes grpc-ecosystem#660
@johanbrandhorst Would it be possible to get a new version cut that contains this fix? |
@v3n I've just released v2.7.0 |
This addresses issue #308.
When parsing the request URL, ServeHTTP() currently uses URL.Path instead of URL.EscapedPath(). This makes it impossible for grpc-gateway to support having slashes
/
in a path even if they are encoded (e.g. http://example.com/some%2Fpath/resource). This change will switch parsing to use URL.EscapedPath(), then unescape the individual components after they have been split by/
.