当前位置:网站首页>Feign report 400 processing
Feign report 400 processing
2022-04-23 16:49:00 【InfoQ】
getXxByIds(String Ids)feign.FeignException$BadRequest: [400] during [POST] to [http...
Problem recurrence
@Slf4j
@RestController
public class SkyController {
@GetMapping("/sky")
public String sky (@RequestParam(required = false) String name) {
log.info(name);
return name;
}
@PostMapping("/deliver")
public String deliver (String packageBox) {
log.info(packageBox);
return packageBox;
}
@PostMapping("/feignPost")
public String feignPost(@RequestParam(name = "name") String name){
log.info(name);
return name;
}
@PostMapping("/feignBody")
public String feignBody(@RequestBody String name){
log.info(name);
return name;
}
}
// gateway The service name
@FeignClient(value = "paw-dogs-sky-service")
public interface SkyFeignClient {
@PostMapping("/deliver")
String deliver (@RequestParam(name = "packageBox") String packageBox);
@PostMapping("/feignPost")
String feignPost(@RequestParam(name = "name") String name);
@PostMapping("/feignBody")
String feignBody(@RequestBody String name);
}
@Slf4j
@SpringBootTest
class SkyFeignClientTest {
@Autowired
SkyFeignClient skyFeignClient;
@Test
void deliver () {
String param = RandomUtil.randomString(10*1024);
log.info(param);
String result = skyFeignClient.deliver(param);
log.info(result);
}
@Test
void feignPost () {
String param = RandomUtil.randomString(10*1024);
log.info(param);
String result = skyFeignClient.feignPost(param);
log.info(result);
}
@Test
void feignBody () {
String param = RandomUtil.randomString(1*1024);
log.info(param);
String result = skyFeignClient.feignBody(param);
log.info(result);
}
}

use postman Direct access to service testing


url Length limit
- browser url Length limit
- Server length limit Such as tomcat Limit , nginx url Limit
- SpringBoot Project length limit
max-http-header-sizeDefault 8k, Change the service provided sky Configuration of 100*1024 (100k) , Retry the normal service call .
DataSize maxHttpHeaderSize = DataSize.ofKilobytes(8)
server:
port: 8080
max-http-header-size: 102400
Source code analysis
RequestTemplateMap<String, QueryTemplate> queries = new LinkedHashMap<>()packageBox--> packageBox={packageBox}SpringMvcContractprocessAnnotationOnClassprocessAnnotationOnMethodprocessAnnotationsOnParameterAnnotatedParameterProcessorRequestParamParameterProcessorpublic boolean processArgument(AnnotatedParameterContext context,
Annotation annotation, Method method) {
int parameterIndex = context.getParameterIndex();
Class<?> parameterType = method.getParameterTypes()[parameterIndex];
MethodMetadata data = context.getMethodMetadata();
if (Map.class.isAssignableFrom(parameterType)) {
checkState(data.queryMapIndex() == null,
"Query map can only be present once.");
data.queryMapIndex(parameterIndex);
return true;
}
RequestParam requestParam = ANNOTATION.cast(annotation);
String name = requestParam.value();
checkState(emptyToNull(name) != null,
"RequestParam.value() was empty on parameter %s", parameterIndex);
context.setParameterName(name);
// Encapsulate parameters
Collection<String> query = context.setTemplateParameter(name,
data.template().queries().get(name));
data.template().query(name, query);
return true;
}
SynchronousMethodHandlerexecuteAndDecode(template, options)Object executeAndDecode(RequestTemplate template, Options options) throws Throwable {
// Build request
Request request = targetRequest(template);
if (logLevel != Logger.Level.NONE) {
logger.logRequest(metadata.configKey(), logLevel, request);
}
Response response;
long start = System.nanoTime();
try {
// perform http request
response = client.execute(request, options);
...
}
DefaultLoadBalancerFeignClientFeignBlockingLoadBalancerClientsolve
1. Increase the of service providers header Parameters ( More micro services Not very suitable )
2. Change it to requestBody Call the service
summary
RequestTemplateRequest版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231645272078.html
边栏推荐
- Modify the test case name generated by DDT
- MySQL master-slave synchronization pit avoidance version tutorial
- Disk management and file system
- 安装及管理程序
- Kunteng full duplex digital wireless transceiver chip kt1605 / kt1606 / kt1607 / kt1608 is suitable for interphone scheme
- Installation and management procedures
- 计算饼状图百分比
- Pseudo Distributed installation spark
- Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
- 05 Lua 控制结构
猜你喜欢

1959年高考数学真题

各大框架都在使用的Unsafe类,到底有多神奇?

How vscode compares the similarities and differences between two files

Real time operation of vim editor

Summary according to classification in sail software

RAID磁盘阵列与RAID5的创建

Derivation of Σ GL perspective projection matrix

博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生

PyTorch:train模式与eval模式的那些坑

Gartner 发布新兴技术研究:深入洞悉元宇宙
随机推荐
Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
Calculate pie chart percentage
Detailed explanation of UWA pipeline function | visual configuration automatic test
Derivation of Σ GL perspective projection matrix
The first line and the last two lines are frozen when paging
RAID磁盘阵列与RAID5的创建
5-minute NLP: text to text transfer transformer (T5) unified text to text task model
◰GL-着色器处理程序封装
File upload and download of robot framework
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
正则过滤内网地址和网段
How to build tiktok user trust and drive fan growth
Solution of garbled code on idea console
无线鹅颈麦主播麦手持麦无线麦克风方案应当如何选择
Public variables of robotframework
拷贝构造函数 浅拷贝与深拷贝
聊一聊浏览器缓存控制
Loading order of logback configuration file
English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
05 Lua 控制结构