WebLogic 10gR3 - UnsupportedEncodingException parsing Content-Type header for multipart/form-data

好久不见. 提交于 2019-12-12 11:03:10

问题


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.

来源:https://stackoverflow.com/questions/9332791/weblogic-10gr3-unsupportedencodingexception-parsing-content-type-header-for-mu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!