The implementation follows the specification rules, but there was a problem with messages, containing file parts, which filename headers are non-ASCII.
For example :
The problem was that, the client for our multipart implementation doesnt get the correct file name.
The specification (RFC2046) says that :
The "multipart" boundary delimiters and header fields are always represented as 7bit US-ASCII and RFC 2047 says : Generally, an "encoded-word" is a sequence of printable ASCII characters that begins with "=?", ends with "?=", and has two "?"s in between. It specifies a character set and an encoding method, and also includes the original text encoded as graphic ASCII characters, according to the rules for that encoding method. A mail composer that implements this specification will provide a means of inputting non-ASCII text in header fields, but will translate these fields (or appropriate portions of these fields) into encoded-words before inserting them into the message header. A mail reader that implements this specification will recognize encoded-words when they appear in certain portions of the message header. Instead of displaying the encoded-word "as is", it will reverse the encoding and display the original text in the designated character set.
So the specification here specifies that mail composer is responsible for encoded header names and values. But the SAP NetWeaver Multipart library has an additional API method which can be used to set the proper encoding, and get correctly parsed headers, without any additional efforts from the consumer of the library.
The new method is in com.sap.engine.services.servlets_jsp.lib.multipart.MultipartMessage :
/** * Sets encoding for part's headers parsing. * If the paramether is null - no encoding will be used for string conversion. * @param charset The encoding to be used. * @throws UnsupportedEncodingException If the given encoding is not supported. */ public void setCharset(String charset) throws UnsupportedEncodingException And can be used like in this JSP code: com.sap.engine.services.servlets_jsp.lib.multipart.MultipartMessage mm = (com.sap.engine.services.servlets_jsp.lib.multipart.MultipartMessage)request.getAttribute("com.sap.servlet.multipart.body"); mm.setCharset("UTF-8");
The method should be called first and before any other MultipartMessages methods otherwise has no effect!