Skip to Content
The SAP NetWeaver Application Server provides API for multipart requests parsing (See linked URL).
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 doesn’t 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 :

/** * 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: mm = (""); mm.setCharset("UTF-8");

The method should be called first and before any other MultipartMessage’s methods otherwise has no effect!

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply