Child pages
  • How to remove the http protocol headers in the camel message?

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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:

Code Block
  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:

Code Block
  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");
Code Block
  <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>