mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-03 09:32:21 +08:00
fix(FeignConfig): 复制请求头忽略content-length
This commit is contained in:
parent
4e56b18bc7
commit
d477c0bbbb
@ -47,18 +47,22 @@ public class FeignConfig {
|
||||
if (requestAttributes != null) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) requestAttributes;
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
//获取请求头
|
||||
// 获取请求头
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
if (headerNames != null) {
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String name = headerNames.nextElement();
|
||||
// 忽略content-length。因为在复制请求头到新请求时,原始的content-length可能不再准确。
|
||||
if (!"content-length".equalsIgnoreCase(name)) {
|
||||
String values = request.getHeader(name);
|
||||
//将请求头保存到模板中
|
||||
// 将请求头保存到模板中,除了 Content-Length
|
||||
template.header(name, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user