}
if (mediaType.equals("multipart/form-data")) {
form = HttpValuesMap.ofObjects();
MultipartStreamParser multipartParser = new MultipartStreamParser();
try {
byte[] bodyBytes = bodyString.getBytes(StringPool.ISO_8859_1);
ByteArrayInputStream bin = new ByteArrayInputStream(bodyBytes);
multipartParser.parseRequestStream(bin, charset);
} catch (IOException ioex) {
throw new HttpException(ioex);
}
// string parameters
for (String paramName : multipartParser.getParameterNames()) {
String[] values = multipartParser.getParameterValues(paramName);
if (values.length == 1) {
form.add(paramName, values[0]);
} else {
form.put(paramName, values);
}
}
// file parameters
for (String paramName : multipartParser.getFileParameterNames()) {
FileUpload[] values = multipartParser.getFiles(paramName);
if (values.length == 1) {
form.add(paramName, values[0]);
} else {
form.put(paramName, values);
}