Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15420

camel-http dynamic aware removes Exchange.HTTP_QUERY header if Exchange.HTTP_PATH header not specified

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.24.3, 3.4.3
    • Fix Version/s: 3.5.0, 3.4.4, 2.25.3
    • Component/s: camel-http-common
    • Labels:
      None
    • Estimated Complexity:
      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));
      
       }
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ArtemSt Artem St

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment