Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.24.3, 3.4.3
-
None
-
Unknown
Description
If http path specified in endpoint uri instead of Exchange.HTTP_PATH header than dynamic aware ignores Exchange.HTTP_QUERY and set it as null.
Sending message to route
from("direct:dynamicAware") .setHeader(Exchange.HTTP_PATH, constant("dynamicAware")) .setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2")) .toD("http://localhost:" + localServer.getLocalPort());
will return exchange with getIn().getHeader(Exchange.HTTP_QUERY) equal to "par1=val1&par2=val2".
But, sending message to route
from("direct:dynamicAwareWithoutPathHeader") .setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2")) .toD("http://localhost:" + localServer.getLocalPort() + "/dynamicAware");
removes header Exchange.HTTP_QUERY from result.
Here is full code of test: (also attached as a .java file)
public class HttpSendDynamicAwareHeadersTest extends BaseHttpTest { private HttpServer localServer; @BeforeEach @Override public void setUp() throws Exception { localServer = ServerBootstrap.bootstrap(). setHttpProcessor(getBasicHttpProcessor()). setConnectionReuseStrategy(getConnectionReuseStrategy()). setResponseFactory(getHttpResponseFactory()). setExpectationVerifier(getHttpExpectationVerifier()). setSslContext(getSSLContext()). registerHandler("/dynamicAware", new BasicValidationHandler(GET.name(), null, null, null)). create(); localServer.start(); super.setUp(); } @AfterEach @Override public void tearDown() throws Exception { super.tearDown(); if (localServer != null) { localServer.stop(); } } @Override protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { from("direct:dynamicAware") .setHeader(Exchange.HTTP_PATH, constant("dynamicAware")) .setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2")) .toD("http://localhost:" + localServer.getLocalPort()); from("direct:dynamicAwareWithoutPathHeader") .setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2")) .toD("http://localhost:" + localServer.getLocalPort() + "/dynamicAware"); } }; } @Test public void testDynamicAwareHeaders() throws Exception { Exchange e = fluentTemplate.to("direct:dynamicAware").send(); assertNotNull(e.getIn().getHeader(Exchange.HTTP_QUERY)); e = fluentTemplate.to("direct:dynamicAwareWithoutPathHeader").send(); assertNotNull(e.getIn().getHeader(Exchange.HTTP_QUERY)); } }