Calle at e-man
Calle at e-man

Reputation: 145

How do I get headerFilterStrategy to work with http4?

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.

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"/>

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;
    }
}

When referencing the HeaderFilter as above I still get the same error. What am I doing wrong?

Using camel 2.14.

Upvotes: 2

Views: 1314

Answers (1)

Calle at e-man
Calle at e-man

Reputation: 145

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 :)

Upvotes: 1

Related Questions