Skip to content
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

QueryTemplate Bug in 10.x #1064

Closed
zhangruican opened this issue Sep 7, 2019 · 4 comments · Fixed by #1138
Closed

QueryTemplate Bug in 10.x #1064

zhangruican opened this issue Sep 7, 2019 · 4 comments · Fixed by #1138
Assignees
Labels
bug Unexpected or incorrect behavior feedback provided Feedback has been provided to the author

Comments

@zhangruican
Copy link

RequestTemplate template = new RequestTemplate().query("url", "{url}").query("b", "{b}");
Map<String, String> vars = Maps.newHashMap();
vars.put("url", "http://www.baidu.com/?a=1&b=2");
vars.put("b", "3");
template = template.resolve(vars);
System.out.println(template.url());  // output /?url=http:%2F%2Fwww.baidu.com%2F%3Fa=1&b=2&b=3

should /?url=http:%2F%2Fwww.baidu.com%2F%3Fa=1%26b=2&b=3
QueryTemplate use Template.parseTemplate

@kdavisk6
Copy link
Member

kdavisk6 commented Nov 3, 2019

@zhangruican

What exactly is the issue in the result?

@kdavisk6 kdavisk6 added the feedback provided Feedback has been provided to the author label Nov 3, 2019
@zhangruican
Copy link
Author

an issue with URI template encoding , '&' encoding

@kdavisk6
Copy link
Member

That is intentional. Feign will consider the value for a template variable in its entirety when resolving the template. It will also encode the entire value before substitution. I suspect the output you are looking for is:

/?url=http:%2F%2Fwww.baidu.com%2F%3Fa=1%26b=2%26b=3

If that is the case, you will need to provide the complete value as {ur}l.

@kdavisk6
Copy link
Member

Please see #1138 for background on this issue and a potential fix.

@kdavisk6 kdavisk6 added the bug Unexpected or incorrect behavior label Dec 26, 2019
@kdavisk6 kdavisk6 self-assigned this Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior feedback provided Feedback has been provided to the author
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants