My application is receiving multi-part content through an HTTP POST, on WebLogic 10gR3. Whenever clients specify the charset
attribute before other attributes on the Content-Type header (e.g. Content-Type: multipart/form-data; charset=utf-8; boundary=a_random_boundary
), WebLogic is throwing the following exception (caught in my managed server's log):
Unsupported encoding: "utf-8; boundary=a_random_boundary" specified.
java.io.UnsupportedEncodingException: Unsupported Encoding utf-8; boundary=a_random_boundary
at weblogic.servlet.internal.ServletRequestImpl.setCharacterEncoding(ServletRequestImpl.java:428)
at weblogic.servlet.internal.ServletRequestImpl.initRequestEncoding(ServletRequestImpl.java:1115)
at weblogic.servlet.internal.ServletRequestImpl.getCharacterEncoding(ServletRequestImpl.java:451)
at javax.servlet.ServletRequestWrapper.getCharacterEncoding(ServletRequestWrapper.java:115)
at com.MyClass.myMethod(MyClass.java:100)
Just for information, I am doing a getCharacterEncoding()
call to an HttpServletRequest
instance at line 100.
However, if clients specify the charset at the end of the header (e.g. Content-Type: multipart/form-data; boundary=a_random_boundary; charset=utf-8), the application and WebLogic perform gracefully.
According to RFC2045, the order of the parameters is not significant:
The Content-Type header field specifies the nature of the data in the body of an entity by giving media type and subtype identifiers, and by providing auxiliary information that may be required for certain media types. After the media type and subtype names, the remainder of the header field is simply a set of parameters, specified in an attribute=value notation. The ordering of parameters is not significant.
I have searched around, and the closer I got to a similar problem was the following thread at OTN.
I am assuming this is a bug in WebLogic, but I thought I would look for some insight before contacting support and/or making a workaround.
Thanks for any insight into this issue.