如何让 headerFilterStrategy 与 http4 一起使用? [英] How do I get headerFilterStrategy to work with http4?
问题描述
我想使用 http4 中的 ="nofollow">headerFilterStrategy 功能,可从 HTTP 中过滤掉大部分标头-要求.我想稍后在 HTTP 请求之后使用标头,因此不能选择使用 removeHeaders.
I want to use the headerFilterStrategy functionality in http4 to filter out most headers from a HTTP-request. I want to use the headers later on, after the HTTP-request, so using removeHeaders is not an option.
我想我会尝试使用 DefaultHeaderFilterStrategy:
I figured I'd try with DefaultHeaderFilterStrategy:
<bean id="beanHeaderFilter" class="org.apache.camel.impl.DefaultHeaderFilterStrategy"/>
...
<to uri="http4://localhost:8080/my/path?headerFilterStrategy=#beanHeaderFilter"/>
我从中得到的只是 org.apache.http.client.ClientProtocolException.所以我尝试制作自己的 headerFilterStrategy:
All I get from that is org.apache.http.client.ClientProtocolException. So I tried making my own headerFilterStrategy:
public class HeaderFilter implements HeaderFilterStrategy {
@Override
public boolean applyFilterToCamelHeaders(String s, Object o, Exchange exchange) {
return false;
}
@Override
public boolean applyFilterToExternalHeaders(String s, Object o, Exchange exchange) {
return false;
}
}
当如上所述引用 HeaderFilter 时,我仍然遇到相同的错误.我做错了什么?
When referencing the HeaderFilter as above I still get the same error. What am I doing wrong?
使用骆驼 2.14.
推荐答案
啊,我非常关注通过哪些标题,我没有注意到标题中的内容.我试图提出的请求在应该使用 GET 时使用了 POST.它现在有效.希望这个帖子将来对某人有用:)
Aargh, I was paying so much attention to what headers were coming through that I didn't notice what was in the headers. The request I was trying to make was using POST when it should be using GET. It works now. Hopefully this thread will be of some use to somebody in the future :)
这篇关于如何让 headerFilterStrategy 与 http4 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!