0

I'm using Apache Camel's HTTP 4 component for performing a HTTP-PUT request. Before sending the request, I set custom and application dependent headers. One of the header key is 'Date'.

But unfortunately, Camel-HTTP4 ignores the Date-Header and does not send it to the remote server:

.setHeader("Date", simple("${date:now:EEE, dd MMM yyyy HH:mm:ss z}"))
.toD("https4:{{myprops.uri}}?bridgeEndpoint=true" +
    "&throwExceptionOnFailure=false" +
    "&mapHttpMessageBody=true" +
    "&httpMethod=" + HttpMethods.PUT +
    "&connectTimeout={{myprops.connectTimeout}}" +
    "&socketTimeout={{myprops.socketTimeout}}").id("https-connect")
 // Date is not sent

Does anybody know why the header is removed and how I can configure that the header is kept?

Thx

ian_eve
  • 97
  • 2
  • 8
  • AFAIK the default `HeaderFilterStrategy` only copies known headers from the headers of the message stored in the current exchange to the HTTP request/response. On using a custom implementation here you should be able to define which headers are passed from request to the Camel message and which headers are passed from the message to the generated HTTP response – Roman Vottner Jul 27 '21 at 08:38

1 Answers1

0

Add &date=${header.Date}to the .toD() parameters, because it is a custom parameter.

There are some http headers that you don't have to add to the parameters if you define them before the http call. In this case for example you could use .setHeader(Exchange.HTTP_METHOD, constant(HttpMethod.PUT))

lbma
  • 132
  • 8