public static class HttpRequestParser.MultipartParser extends Object
| Constructor and Description |
|---|
MultipartParser(byte[] arr, String delim)Constructor |
| Modifier and Type | Method and Description |
|---|---|
Hashtable<String,String> | getFormData()Get form data hastable, using correct charset. |
int | parseAllTokens()Parse all tokens into Vector of MultipartToken objects. |
void | setDefaultCharset(String charset)Decodes parts in a named character set when the request does not name one itself. |
public MultipartParser(byte[] arr,
String delim)public void setDefaultCharset(String charset)
Opt-in, and it changes nothing for any caller that does not call it. Multipart is in live use by customer applications doing file upload, so the default stays what it has always been: the definition_charset part if the request carries one, and ISO-8859-1 otherwise. Altering that globally would change behaviour for deployed customers who did not ask for it.
An in-band definition_charset still wins. This is a fallback for the request that says nothing, not an override of the request that does - including the Internet Explorer workaround, which distrusts the BROWSER's claim of UTF-8 and must not be undone by an application's own declaration.
Both HTML-style and Java-style names are accepted ("UTF-8" and "UTF8", "iso-8859-2" and "8859_2"). The name is validated HERE rather than at decode time, and the reason is sharper than tidiness: MultipartToken.getDataString catches the decode failure and returns null, and getFormData then calls Hashtable.put with that null - which throws NullPointerException. So an unvalidated charset does not degrade the result, it fails the whole request from inside the parser, with a stack trace pointing at Hashtable.put rather than at whoever named the charset.
charset - The character set name, or null to keep the default.IllegalArgumentException - If the name is not a supported character set.public int parseAllTokens()
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© 2026 Mindus SARL. All rights reserved.