mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-05 10:32:41 +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) {
|
if (requestAttributes != null) {
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) requestAttributes;
|
ServletRequestAttributes attributes = (ServletRequestAttributes) requestAttributes;
|
||||||
HttpServletRequest request = attributes.getRequest();
|
HttpServletRequest request = attributes.getRequest();
|
||||||
//获取请求头
|
// 获取请求头
|
||||||
Enumeration<String> headerNames = request.getHeaderNames();
|
Enumeration<String> headerNames = request.getHeaderNames();
|
||||||
if (headerNames != null) {
|
if (headerNames != null) {
|
||||||
while (headerNames.hasMoreElements()) {
|
while (headerNames.hasMoreElements()) {
|
||||||
String name = headerNames.nextElement();
|
String name = headerNames.nextElement();
|
||||||
String values = request.getHeader(name);
|
// 忽略content-length。因为在复制请求头到新请求时,原始的content-length可能不再准确。
|
||||||
//将请求头保存到模板中
|
if (!"content-length".equalsIgnoreCase(name)) {
|
||||||
template.header(name, values);
|
String values = request.getHeader(name);
|
||||||
|
// 将请求头保存到模板中,除了 Content-Length
|
||||||
|
template.header(name, values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user