当前位置:网站首页>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-size
Default 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
RequestTemplate
Map<String, QueryTemplate> queries = new LinkedHashMap<>()
packageBox--> packageBox={packageBox}
SpringMvcContract
processAnnotationOnClass
processAnnotationOnMethod
processAnnotationsOnParameter
AnnotatedParameterProcessor
RequestParamParameterProcessor
public 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;
}
SynchronousMethodHandler
executeAndDecode(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);
...
}
Default
LoadBalancerFeignClient
FeignBlockingLoadBalancerClient
solve
1. Increase the of service providers header Parameters ( More micro services Not very suitable )
2. Change it to requestBody Call the service
summary
RequestTemplate
Request
版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231645272078.html
边栏推荐
- How magical is the unsafe class used by all major frameworks?
- STM32__ 03 - beginner timer
- 【Pygame小游戏】10年前风靡全球的手游《愤怒的小鸟》,是如何霸榜的?经典回归......
- Zhimeng dedecms security setup Guide
- 计算饼状图百分比
- Set cell filling and ranking method according to the size of the value in the soft report
- Introduction to new functions of camtasia2022 software
- About background image gradient()!
- Public variables of robotframework
- LVM and disk quota
猜你喜欢
OMNeT学习之新建工程
TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
DanceNN:字节自研千亿级规模文件元数据存储系统概述
Use case execution of robot framework
计组 | 【七 输入/输出系统】知识点与例题
Nacos detailed explanation, something
建站常用软件PhpStudy V8.1图文安装教程(Windows版)超详细
Solution of garbled code on idea console
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
Gartner 發布新興技術研究:深入洞悉元宇宙
随机推荐
Loggie source code analysis source file module backbone analysis
Real time operation of vim editor
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
Sail soft calls the method of dynamic parameter transfer and sets parameters in the title
Public variables of robotframework
信息摘要、数字签名、数字证书、对称加密与非对称加密详解
关于 background-image 渐变gradient()那些事!
Loading order of logback configuration file
Introduction notes to PHP zero Foundation (13): array related functions
ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
OMNeT学习之新建工程
面试百分百问到的进程,你究竟了解多少
LVM and disk quota
Pseudo Distributed installation spark
MySQL master-slave synchronization pit avoidance version tutorial
蓝桥杯省一之路06——第十二届省赛真题第二场
Cartoon: what are IAAs, PAAS, SaaS?
◰ GL shader handler encapsulation
如何用Redis实现分布式锁?
Do you really understand the principle of code scanning login?