java - Apache Camel: URI Escaping in HTTP (and other Producers) -
in apache camel route, want take several headers , compose them http query string in safe way. examples i've found either use constant(), isn't useful building dynamic query strings, or use simple() doesn't offer url escaping.
for example, take following snippet right http component's documentation:
from("direct:start") .setheader(exchange.http_query, constant("order=123&detail=short")) .to("http://oldhost");
this 90% of way there, if don't want order id 123? we'd able substitute header value here. so, next logical version of switch simple:
from("direct:start") .setheader(exchange.http_query, simple("order=${header.orderid}&detail=short")) .to("http://oldhost");
but has major issue of not being url encoded. means space (or reserved character) in header.orderid results in exception thrown http component invalid query string.
so way that's left use javascript, verbose this, or write custom processor. seems should that's built-in, i'm asking here see if i'm missing obvious/normal way i'm looking here?
Comments
Post a Comment