You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Artem St (Jira)" <ji...@apache.org> on 2020/08/17 10:38:00 UTC
[jira] [Created] (CAMEL-15420) camel-http dynamic aware removes
Exchange.HTTP_QUERY header if Exchange.HTTP_PATH header not specified
Artem St created CAMEL-15420:
--------------------------------
Summary: camel-http dynamic aware removes Exchange.HTTP_QUERY header if Exchange.HTTP_PATH header not specified
Key: CAMEL-15420
URL: https://issues.apache.org/jira/browse/CAMEL-15420
Project: Camel
Issue Type: Bug
Components: camel-http-common
Affects Versions: 3.4.3, 2.24.3
Reporter: Artem St
Attachments: HttpSendDynamicAwareHeadersTest.java
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
{code:java}
from("direct:dynamicAware")
.setHeader(Exchange.HTTP_PATH, constant("dynamicAware"))
.setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2"))
.toD("http://localhost:" + localServer.getLocalPort());{code}
will return exchange with getIn().getHeader(Exchange.HTTP_QUERY) equal to "par1=val1&par2=val2".
But, sending message to route
{code:java}
from("direct:dynamicAwareWithoutPathHeader")
.setHeader(Exchange.HTTP_QUERY, constant("par1=val1&par2=val2"))
.toD("http://localhost:" + localServer.getLocalPort() + "/dynamicAware");{code}
removes header Exchange.HTTP_QUERY from result.
Here is full code of test: (also attached as a .java file)
{code:java}
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));
}
}{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)