当前位置:网站首页>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
边栏推荐
- Loading order of logback configuration file
- 织梦DEDECMS安全设置指南
- 信息摘要、数字签名、数字证书、对称加密与非对称加密详解
- Set the color change of interlaced lines in cells in the sail software and the font becomes larger and red when the number is greater than 100
- 04 Lua 运算符
- MySql主从复制
- Bytevcharts visual chart library, I have everything you want
- Phpstudy V8, a commonly used software for station construction 1 graphic installation tutorial (Windows version) super detailed
- Knowledge points and examples of [seven input / output systems]
- Talk about browser cache control
猜你喜欢

Quick install mongodb

NVIDIA graphics card driver error
![[pyGame games] how did angry birds, a mobile game that became popular all over the world 10 years ago, dominate the list? Classic return](/img/f5/15b3731e75eb4d861bd9d29ae244da.png)
[pyGame games] how did angry birds, a mobile game that became popular all over the world 10 years ago, dominate the list? Classic return

Dlib of face recognition framework

How to build tiktok user trust and drive fan growth

STM32__03—初识定时器

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

Disk management and file system

英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)

True math problems in 1959 college entrance examination
随机推荐
Database dbvisualizer Pro reported file error, resulting in data connection failure
Selenium IDE and XPath installation of chrome plug-in
安装及管理程序
SQL database
ByteVCharts可视化图表库,你想要的我都有
Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
Xinwangda: HEV and Bev super fast charging fist products are shipped on a large scale
DanceNN:字节自研千亿级规模文件元数据存储系统概述
The solution of not displaying a whole line when the total value needs to be set to 0 in sail software
如何建立 TikTok用户信任并拉动粉丝增长
Loading order of logback configuration file
Mock test using postman
Detailed explanation of Niuke - Gloves
Solution of garbled code on idea console
Loggie source code analysis source file module backbone analysis
NVIDIA显卡驱动报错
RTKLIB 2.4.3源码笔记
◰ GL shadow map core steps
How vscode compares the similarities and differences between two files
Differences between MySQL BTREE index and hash index