feign
feign copied to clipboard
About character escape
Characters Are Not Escaped !
a example:
The provider `
@PostMapping("find")
public String find(@RequestParam(name = "name",required = true) String name,
@RequestParam(name = "text",required = true) String text){
return "hello";
}
`
The consumer
`
@Autowired
UserFeign userFeign;
@Test
void contextLoads() {
String name = "12%2601";
String text ="&";
String s = userFeign.find(name, text);
}
`
result:
environment: java version 1.8.0_202; Spring boot 2.3.7.RELEASE; feign-core 10.10.1
This Result Is Different From What I Expected , I Think name should Be “12%2601”. debug, i Noticed feign.RequestTemplate#resolve append uri = “/find?name=12%2601&text=%26” ,% is Not Escaped, resulting In Provider Resolution Failure.
I think they should all be escaped, or Allow Developers To Modify It.
Sorry, my English is very weak!!!
Is there a way to escape them all?
The end result on the URI is PCT-encoded as per the URI Template specification: https://datatracker.ietf.org/doc/html/rfc6570
Values such as %
and &
are reserved and will not be encoded again. I recommend that you read more on percent encoding: https://en.wikipedia.org/wiki/Percent-encoding, to see if your assumptions are correct.