从 Camel DefaultHeaderFilterStrategy 中删除了传输日期 header

Transfer Date header removed from Camel DefaultHeaderFilterStrategy

我试图通过两个 header 文件的授权访问 REST API:授权和日期,但日期字段已从 DefaultHeaderFilterStrategy 中删除。我试图用我的过滤器替换它并将其设置到 Jetty 客户端中,但是日期 header 仍然缺少到 RequestProcessor 和 RestProcessor 中。我需要可以在全球范围内传输此 header 以满足我们的所有请求。这是我的部分代码。

@Component
public class RestAPIClientRoute extends RouteBuilder {

    @Autowired
    private CamelContext camelContext;

    @Override
    public void configure() throws Exception {
    
        JettyHttpComponent jettyComponent = camelContext.getComponent("jetty", JettyHttpComponent.class);
        jettyComponent.setHeaderFilterStrategy(new HeaderFilter());
        
        restConfiguration().component("jetty").scheme("http").port(80).host("localhost");    


        interceptSendToEndpoint("rest:post:*").process(new Processor() {
            public void process(Exchange exchange) {

                Properties authProperties = CryptoUtil.duoAuthRequestEncode( duoConfig,"POST", exchange);

                Message msg = exchange.getMessage();
                msg.setHeader("Authorization", "Basic " + authProperties.getProperty("auth"));
                msg.setHeader("Date", authProperties.getProperty("timestamp"));

            }
        });
        
        rest("/rest")
                .post("/accounts/v1/account/list")
                .to("direct:hello");

        from("direct:hello")
            .process(new RequestProcessor());

        from("timer:rest-client?period=60s")
            .to("direct:accountList");
        
        from("direct:accountList")
            .to("rest:post:/rest/accounts/v1/account/list")
            .process(new RestProcessor());
        
    }

}


@Component
public class HeaderFilter implements HeaderFilterStrategy {

    @Override
    public boolean applyFilterToCamelHeaders(String headerName, Object headerValue, Exchange exchange) {

        return false;
    }
    @Override
    public boolean applyFilterToExternalHeaders(String headerName, Object headerValue, Exchange exchange) {

        return false;
    }
}

实际上问题出在 REST 组件上。他设置了 HeaderFilter,它覆盖了 HTTP 组件中的其他设置过滤器。 REST 组件无法设置 HeaderFilterStrategy 并始终使用默认值。我开始只使用带有设置我的自定义过滤器的 http 组件而不是 rest,现在可以从 DefaultHeaderFilterStrategy 中删除 headers。

我换了

   .to("rest:post:/rest/accounts/v1/account/list")

   .setHeader(Exchange.HTTP_METHOD, constant("POST"))
   .setHeader(Exchange.HTTP_QUERY, constant(urlQuery))
   .to("https://host.domain.com/rest/accounts/v1/account/list")