CenturyLinkCloud / mdw

https://centurylinkcloud.github.io/mdw/
MIT License
46 stars 10 forks source link

Support for UTF-8 POST/PUT/PATCH REST requests #733

Open donaldoakes opened 5 years ago

donaldoakes commented 5 years ago

The default character set per Java servlet spec is ISO-8859-1. MalformedInputExceptions can occur when non ISO-8859-1 characters are encountered in the request body (see below).

We should provide a way to configure the servlet to expect UTF-8 (and maybe this should be the default).

java.nio.charset.MalformedInputException: Input length = 1
                at java.nio.charset.CoderResult.throwException(CoderResult.java:281) ~[na:1.8.0_212]
                at org.apache.tomcat.util.buf.B2CConverter.convert(B2CConverter.java:275) ~[tomcat-embed-core-8.5.32.jar!/:8.5.32]
                at org.apache.catalina.connector.InputBuffer.realReadChars(InputBuffer.java:426) ~[tomcat-embed-core-8.5.32.jar!/:8.5.32]
                at org.apache.catalina.connector.InputBuffer.checkCharBufferEof(InputBuffer.java:652) ~[tomcat-embed-core-8.5.32.jar!/:8.5.32]
                at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:468) ~[tomcat-embed-core-8.5.32.jar!/:8.5.32]
                at org.apache.catalina.connector.CoyoteReader.read(CoyoteReader.java:108) ~[tomcat-embed-core-8.5.32.jar!/:8.5.32]
                at org.apache.catalina.connector.CoyoteReader.readLine(CoyoteReader.java:163) ~[tomcat-embed-core-8.5.32.jar!/:8.5.32]
                at com.centurylink.mdw.hub.servlet.RestServlet.handleRequest(RestServlet.java:242) ~[mdw-spring-boot-6.1.22.jar!/:na]
                at com.centurylink.mdw.hub.servlet.RestServlet.doPost(RestServlet.java:144) ~[mdw-spring-boot-6.1.22.jar!/:na]
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) ~[tomcat-embed-core-8.5.32.jar!/:8.5.32]
                at com.centurylink.mdw.hub.servlet.RestServlet.service(RestServlet.java:224) ~[mdw-spring-boot-6.1.22.jar!/:na]
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.32.jar!/:8.5.32]