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

NettyHttpHelper appends slash to an URI in case of empty CamelHttpPath

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.11.0
    • 3.7.6, 3.11.3, 3.12.0
    • camel-netty-http
    • None
    • Unknown

    Description

      NettyHttpHelper appends slash to an URI in case of empty CamelHttpPath possibly leading to 404/NOT_FOUND errors.

      Test to reproduce

          @Test
          public void testEmptyPathDoesNotEndsWithSlash() throws Exception {
              MockEndpoint input = getMockEndpoint("mock:input");
              input.expectedBodiesReceived("Hello World");
              input.expectedHeaderReceived(Exchange.HTTP_PATH, "");
              input.expectedHeaderReceived(Exchange.HTTP_URI, "/foo");
      
              template.request("netty-http:http://localhost:{{port}}/foo", exchange -> {
                  Message in = exchange.getIn();
                  in.setBody("Hello World");
                  in.setHeader(Exchange.HTTP_PATH, "");
              });
      
              assertMockEndpointsSatisfied();
          }
      

      ... fails with

      java.lang.AssertionError: mock://input Header with name CamelHttpPath for message: 0. Expected: <> but was: </>
      Expected :<>
      Actual   :</>
      <Click to see difference>
      
      	at org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:1782)
      	at org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:1759)
      	at org.apache.camel.component.mock.MockEndpoint$4.assertOnIndex(MockEndpoint.java:608)
      	at org.apache.camel.component.mock.MockEndpoint.onExchange(MockEndpoint.java:1599)
      

      Attachments

        Issue Links

          Activity

            People

              acosentino Andrea Cosentino
              szhemzhitsky Sergey Zhemzhitsky
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: