-
Notifications
You must be signed in to change notification settings - Fork 72
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
Query parameters get reencoded for GET requests #40
Comments
There is a test that checks URL query encoding: https://github.com/apex/gateway/blob/master/request_test.go#L38 Are you sure the request itself isn't double encoded? Gateway should be properly decoding things AFAICT. |
This test is testing the request with a prefilled APIGatewayProxyRequest object. The double encoding is happening because querystring is being encoded again before filling the APIGatewayProxyRequest: Line 33 in 46d1104
|
I'm not sure I follow. RawQuery is supposed to have % stuff in it. If you want the version without % encoding, do It sounds like the issue is that the parameters are already percent encoded in APIGatewayProxyRequest, which AFAICT is wrong. |
So let me explain it this way: I have a url something.com The NewRequest function reencodes this url making this: Now running |
From my understanding, the frontend does encode all query parameters before making the request which is the standard. That is why the inbuilt URL.Query() function in go's request library decodes them automatically. |
Yes, the raw URL should have percentages in it. APIGatewayProxyRequest is not a raw URL. The percentages should already have been turned into decoded values when being added to event.QueryStringParameters by AWS itself. That's why they need to be reencoded for the Request.URL. |
Just checked. They aren't being decoded by AWS. |
I've been looking but can't find any documentation. Did you find AWS documentation? Or just do an experimental setup? If an experiment, what does you gateway look like? |
I did an experimental setup. I don't use api gateway instead I have a load balancer that directly calls the lambda application via target groups |
I think your LB needs to do the decoding then before it builds the JSON. |
I don't think that can be done with AWS's ALBs. Does the api gateway decode the query string before making the request to lambda? |
When someone makes a GET request with encoded query parameters like
?phone=%2B919999999999
It is reencoded by the NewRequest function in the package to
?phone=%252B919999999999
which cannot be decoded back to the original +919999999999 resulting in issues with go's inbuilt r.URL.Query() and other functions.
The text was updated successfully, but these errors were encountered: