@Log4j2
@Configuration
public class FeignConfig implements RequestInterceptor {
@Override
public void apply(RequestTemplate template) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
Enumeration<String> headerNames = request.getHeaderNames();
if (headerNames != null) {
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
String values = request.getHeader(name);
// 跳过 content-length
if (name.equals("content-length")){
continue;
}
template.header(name, values);
}
} else {
log.info("feign interceptor error header:{}", template);
}
}
}
feign 携带请求头报错 feign.RetryableException: too many bytes written executing
最新推荐文章于 2024-09-09 15:39:33 发布