You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And here is what I see. When I pass unencoded url into REST call UriUtils does nothing so I get more parameters then I need because own url parameters are just appended to API parameters. When I do manual encoding first I get double encoded parameter that is also invalid.
I found the code and it definitely works that way, but I'm not sure why already encoded parameters are forced to be double encoded.
When the RestTemplate is invoked using one of the methods accepting a String URI template, the characters '&', '=', and '+' are not encoded since they are legal URI characters. It wouldn't be possible to know which ones should be encoded and which ones shouldn't.
As for the double encoding, the javadoc of the RestTemplate is very clear that the URI template is expected to not be encoded or else it will be double-encoded.
Activity
spring-projects-issues commentedon Jul 5, 2011
Chris Beams commented
Rossen - this looks at least loosely related to #13050.
spring-projects-issues commentedon Jul 27, 2011
Rossen Stoyanchev commented
There is a good reason for this behavior.
When the RestTemplate is invoked using one of the methods accepting a String URI template, the characters '&', '=', and '+' are not encoded since they are legal URI characters. It wouldn't be possible to know which ones should be encoded and which ones shouldn't.
Consider the following where the value of "url" is "url=http://host/path?a=b&b=c":
As for the double encoding, the javadoc of the RestTemplate is very clear that the URI template is expected to not be encoded or else it will be double-encoded.
You can use the RestTemplate methods that accept a URI instead. See the recommendation here:
https://jira.springsource.org/browse/SPR-5516?focusedCommentId=58444&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-58444
You can also watch or comment under #13050 for a potential improvement.