Closed jwiater closed 5 years ago
Can you give me an example url
imagine passing parameters in url path, not query string:
htttp://someservice/someGetRequest/resourceType/nice%20things
Something like that would fail
Example of API Gateway service using path parameters
I made a new version with this change.
Hi
I found another thing If there is a space in the url itself, not just the query string we have the same problem.
If the url contains space, normally it is encoded to + or %20 But then it is encoded again with the % to %25 so the %20 becomes %2520
AWS complains about that – the message that “the canonical string should be …”
The solution is to Escape also the URL, but one must be careful since it wants to encode also the / characters:
So:
In the place where you have:
canonical_request.Append( request.RequestUri.AbsolutePath + "\n" );
use this:
string sanitizedUrl = SanitizeUrl( request.RequestUri.AbsolutePath ); canonical_request.Append( sanitizedUrl + "\n" );
and add SanitizeUrl method:
private string SanitizeUrl( string absolutePath ) { StringBuilder sb = new StringBuilder(); string[] segments = absolutePath.Split( new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries );
}
Thank you