0

I want to enrich a Camel exchange with content fetched from some external web service. However, when calling that service, I do not want all the headers on my incoming exchange to be mapped onto HTTP headers, just some selected ones should be mapped. Hence, I try to use a HeaderFilteringStrategy as follows:

    override fun configure() {
        from(direct("webservice-query"))
            .setHeader("Accept").constant("application/json")
            .setHeader(Exchange.HTTP_PATH)
            .simple("/partner:\${header.$PARTNER_ID_HEADER}")
            .setHeader(Exchange.HTTP_QUERY).constant("attachments=true")
            .enrich(http(partnerDbUrl)
                     .headerFilterStrategy(myHeaderFilterStrategy)
                     .httpMethod(HttpMethods.GET), PartnerAggregationStrategy
                    )
    }

where myHeaderFilterStrategy is an instance of a custom HeaderFilteringStrategy. However, the HTTP component does not use this strategy. Instead, a default HttpHeaderFilteringStrategy is used. Why? What is wrong with the above route configuration? How can I set a custom header filtering strategy, or otherwise prevent unwanted headers polluting the HTTP request?

Ulrich Schuster
  • 1,670
  • 15
  • 24
  • are you sure it's using a default strategy? Looks like [it should use](https://github.com/apache/camel/blob/b8460586fa75b6ed4b5812aa25e17f636ebf7ed9/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java#L173-L194) the filter strategy provided. What Camel version are you using? – Jeremy Ross Dec 15 '22 at 16:57
  • I'm using Camel 3.19, Spring Boot 2.7.6, Kotlin 1.7.2. And yes, I am sure that it is using the default HttpHeaderFilteringStrategy - I used the debugger to go through most of the steps and inspect the internal fields – Ulrich Schuster Dec 16 '22 at 08:36
  • I'd try setting a breakpoint in the area I linked and find out why the wrong filter strategy is being used. – Jeremy Ross Dec 16 '22 at 20:08

0 Answers0