Child pages
  • How to remove the http protocol headers in the camel message?
Skip to end of metadata
Go to start of metadata

In camel there are a number of components that use the http protocol headers to do their business.
The components include camel-http, camel-jetty, camel-restlet, camel-cxf, etc.
If you are using these component, you may pay attention to the Http protocol headers:

  Exchange.CONTENT_ENCODING
  Exchange.CONTENT_TYPE
  Exchange.HTTP_BASE_URI
  Exchange.HTTP_CHARACTER_ENCODING
  Exchange.HTTP_METHOD
  Exchange.HTTP_PATH
  Exchange.HTTP_QUERY
  Exchange.HTTP_RESPONSE_CODE

If you don't want these headers to bother your other endpoints, you can remove these headers as follows:

  from("jetty://http://myhost:9000/myservice/")
    // Remove the header which name is start with CamelHttp, this DSL is new to Camel 2.3.0
    // You can use removeHeader if your camel version is lower than 2.3.0
    .removeHeaders("CamelHttp*")
    .to("otherEndpoint");
  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <route>
      <from uri="jetty://http://myhost:9000/myservice/"/>
      <removeHeaders pattern="CamelHttp*" />
      <to uri="otherEndpoint"/>
    </route>
  </camelContext> 
  • No labels

1 Comment

  1. To make the spring version the same as the java DSL version shouldn't it be like this :

    <removeHeaders pattern="CamelHttp*" />