Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-523

java.io.UnsupportedEncodingException: UTF-8;

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.2.11.Final, 1.3.0.Beta9
    • 1.1.0.Final
    • None
    • None
    • Hide

      Send a request with Content-Type header

      multipart/form-data; charset=UTF-8; boundary=AaBbCc=_X30

      Show
      Send a request with Content-Type header multipart/form-data; charset=UTF-8; boundary=AaBbCc=_X30

      I'm trying to setup my web application with a component for scanning documents on the browser, and this particular component has a javascript code that submits the scanned document using multipart, and has a servlet that handles the submitted form. Part of the the javascript code that submits the scanned document is the following:

      a.xhr.setRequestHeader("Content-Type","multipart/form-data; boundary="+a.boundaryString)

      The Content-Type header of the associated POST is:

      Content-Type:"multipart/form-data; charset=UTF-8; boundary=AaBbCc=_X30"

      Once the Servlet that handles the submit goes through the doPost method, I get the following stacktrace:

      14:31:46,448 ERROR [io.undertow.request] (default task-60) UT005023: Exception handling request to /scan/AtalasoftCaptureHandler: java.lang.RuntimeException: java.io.UnsupportedEncodingException: UTF-8;
      at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:755)
      at io.undertow.servlet.spec.HttpServletRequestImpl.getParameter(HttpServletRequestImpl.java:627)
      at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:194)
      at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:194)
      at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:194)
      at com.atalasoft.imaging.webcontrols.capture.WebCaptureRequestHandler.processRequest(Unknown Source)
      at com.atalasoft.imaging.webcontrols.capture.WebCaptureRequestHandler.doPost(Unknown Source)
      at ScanHandler.doPost(ScanHandler.java:44)
      Caused by: java.io.UnsupportedEncodingException: UTF-8;
      at java.lang.StringCoding.decode(StringCoding.java:190)
      at java.lang.String.<init>(String.java:414)
      at java.lang.String.<init>(String.java:479)
      at io.undertow.util.MultipartParser$ParseState.headerName(MultipartParser.java:174)
      at io.undertow.util.MultipartParser$ParseState.parse(MultipartParser.java:107)
      at io.undertow.server.handlers.form.MultiPartParserDefinition$MultiPartUploadHandler.parseBlocking(MultiPartParserDefinition.java:206)
      at io.undertow.servlet.spec.HttpServletRequestImpl.parseFormData(HttpServletRequestImpl.java:753)
      ... 85 more

      Looks like the HttpServerExchange.extractCharset method is considering the semicolon as part of the charset, and then it considers the encoding invalid.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              pvcastro Pedro Castro (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: