camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Adding HTTP Headers to All Jetty Routes
Date Thu, 24 Jul 2014 09:44:39 GMT

You can use a custom http binding. See about this at

eg just extend the default, and add those headers in the writeResponse
method, and call its super to do the actual writing.

On Tue, Jul 22, 2014 at 9:20 PM, Gavagai <> wrote:
> Hi all -
> I am trying to add some headers to the exchange's "out" on all routes.
> Specifically, I would like to add the following to support CORS:
>     exch.out.headers['Access-Control-Allow-Origin'] = '*'
>     exch.out.headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE,
>     exch.out.headers['Access-Control-Request-Method'] = '*'
>     exch.out.headers['Access-Control-Allow-Headers'] = 'Origin,
> X-Requested-With, Content-Type, Accept, Authorization, Cookie'
> I do not understand how to do this for all routes. It works great when it is
> done in a processor, but I obviously don't want to have to add these to each
> processor. I tried intercepting the message using interceptFrom(), but the
> headers so defined are not retained when the message is forwarded on to the
> next destination. I also tried setting properties on the exchange, but this
> presents problems when forming the response.
> What is the best way to add HTTP headers to the messages returned from all
> routes? Basically say "for every message, always add these headers as the
> final step."
> Tim
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Red Hat, Inc.
Twitter: davsclaus
Author of Camel in Action:

View raw message