Uploaded image for project: 'Synapse'
  1. Synapse
  2. SYNAPSE-662

ClientWorker overriding character encoding

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.2
    • 2.0
    • None
    • None

    Description

      The following code exists in the org.apache.synapse.transport.nhttp.ClientWorker class' run() method:

      responseMsgCtx.setProperty(
      Constants.Configuration.CHARACTER_SET_ENCODING,
      contentType.indexOf(HTTP.CHARSET_PARAM) > 0 ?
      charSetEnc : MessageContext.DEFAULT_CHAR_SET_ENCODING);

      This fails however for the following Content-Type HTTP header:
      application/soap+xml; action="urn:echoResponse";charset=UTF-16

      BuilderUtil.getCharSetEncoding(contentType) is called a few lines up and correctly extracts the UTF-16 character set value, but then overrides this and sets it to UTF-8. It does this because the value of org.apache.http.protocol.HTTP.CHARSET_PARAM is "; charset=". That is, it's failing because the response does not have a space between the charset parameter and the previous parameter.

      Reading through the HTTP specs, I haven't come across anything that says either that whitespace is permissible or not permissible here. In my view the code should therfore be flexible enough to handle either case.

      I would suggest simpifying the code to:

      responseMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);

      as the BuilderUtil.getCharSetEncoding() code above the offending code seems to be sufficient at first glance.

      Attachments

        1. SYNAPSE-662-patch.txt
          0.9 kB
          Heshan Theekshana Suriyaarachchi

        Activity

          People

            hiranya Hiranya Kasub Jayathilaka
            miielz Myles Bunbury
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: