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

Incorrect Content-Length returned for converted result objects with Unicode characters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.8.0, 2.9.0
    • 2.8.6, 2.9.3, 2.10.0
    • camel-servlet
    • Patch Available
    • Unknown

    Description

      The camel-servlet component responds with an incorrect http Content-Length header, causing the HTTP client to retreive a incomplete response, when the body of the out message is of a POJO type and is converted into a string that contains unicode characters.

      For example, the following route returns "Büe Wör", but should return "Büe Wörld".

      from("servlet:///testUnicodeWithObjectResponse?matchOnUriPrefix=true")
      .process(new Processor() {
      public void process(Exchange exchange) throws Exception {
      String contentType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class);
      exchange.getOut().setHeader(Exchange.CONTENT_TYPE, contentType + "; charset=UTF-8");
      }})
      .transform(constant(
      new Object(){
      @Override
      public String toString()

      Unknown macro: { return "Büe Wörld"; }

      }
      ));

      The attached patch contains a fix for the problem and a test to reproduce the problem.

      Attachments

        1. patch.diff
          4 kB
          Manuel Holzleitner

        Activity

          People

            davsclaus Claus Ibsen
            manuelh9r Manuel Holzleitner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: