我正想通过这个链接: https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/Web_Services_and_Routing_with_Camel_CXF/files/Proxying-Headers.html为什么Apache的骆驼过滤掉HTTP头
它指出,使用HTTP或基于HTTP的组件建桥的应用程序时,经常需要删除或过滤掉某些标题或您的路线中的标题类,以确保您的应用程序按照预期行事。另外在org.apache.camel.component.netty4.http.NettyHttpHeaderFilterStrategy可以看出,被过滤掉大量的头如下:
protected void initialize() {
getOutFilter().add("content-length");
getOutFilter().add("content-type");
getOutFilter().add("host");
// Add the filter for the Generic Message header
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
getOutFilter().add("cache-control");
getOutFilter().add("connection");
getOutFilter().add("date");
getOutFilter().add("pragma");
getOutFilter().add("trailer");
getOutFilter().add("transfer-encoding");
getOutFilter().add("upgrade");
getOutFilter().add("via");
getOutFilter().add("warning");
}
我知道我们可以实现我们自己的过滤器覆盖此行为战略。但是阻止标题的原因是什么?例如,如果我不阻止缓存控制或编译指示标题,会导致什么副作用?
在上面提供的链接中,它还指出当HTTP生产者端点接收到交换并将其转换为目标消息格式时,它将如下处理In消息标头:**所有其他标头将转换为HTTP标头目标消息,用下面的标头,其被阻塞(基于不区分大小写匹配)除外:** _content长度 内容类型 缓存控制 连接 日期 编译 拖车 转印-encoding upgrade via warning_ – user3244615
t他不是真的,HttpHeaderFilterStrategy会过滤掉所有的一般的http头文件。我面临同样的问题,因为它会过滤缓存控制头。 – bLaXjack