|
|
|
@ -873,7 +873,8 @@ public final class httpd implements serverHandler, Cloneable {
|
|
|
|
|
*
|
|
|
|
|
* @author danielr
|
|
|
|
|
* @since 07.08.2008
|
|
|
|
|
* @param header hier muss ARGC gesetzt werden!
|
|
|
|
|
* @param header
|
|
|
|
|
* hier muss ARGC gesetzt werden!
|
|
|
|
|
* @param args
|
|
|
|
|
* @param in
|
|
|
|
|
* @param length
|
|
|
|
@ -881,28 +882,34 @@ public final class httpd implements serverHandler, Cloneable {
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public static HashMap<String, byte[]> parseMultipart(final httpHeader header, final serverObjects args, final InputStream in, final int length) throws IOException {
|
|
|
|
|
RequestContext request = new yacyContextRequest(header, in);
|
|
|
|
|
|
|
|
|
|
if(!FileUploadBase.isMultipartContent(request)) {
|
|
|
|
|
public static HashMap<String, byte[]> parseMultipart(final httpHeader header, final serverObjects args, final InputStream in, final int length)
|
|
|
|
|
throws IOException {
|
|
|
|
|
// read all data from network in memory
|
|
|
|
|
byte[] buffer = serverFileUtils.read(in);
|
|
|
|
|
// parse data in memory
|
|
|
|
|
RequestContext request = new yacyContextRequest(header, new ByteArrayInputStream(buffer));
|
|
|
|
|
|
|
|
|
|
// check information
|
|
|
|
|
if (!FileUploadBase.isMultipartContent(request)) {
|
|
|
|
|
throw new IOException("the request is not a multipart-message!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// format information for further usage
|
|
|
|
|
FileItemFactory factory = new DiskFileItemFactory();
|
|
|
|
|
FileUpload upload = new FileUpload(factory);
|
|
|
|
|
List<FileItem> items;
|
|
|
|
|
try {
|
|
|
|
|
items = upload.parseRequest(request);
|
|
|
|
|
} catch (FileUploadException e) {
|
|
|
|
|
throw new IOException("FileUploadException "+e.getMessage());
|
|
|
|
|
throw new IOException("FileUploadException " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final HashMap<String, byte[]> files = new HashMap<String, byte[]>();
|
|
|
|
|
int formFieldCount = 0;
|
|
|
|
|
for(FileItem item: items) {
|
|
|
|
|
if(item.isFormField()) {
|
|
|
|
|
for (FileItem item : items) {
|
|
|
|
|
if (item.isFormField()) {
|
|
|
|
|
// simple text
|
|
|
|
|
if(item.getContentType() == null || !item.getContentType().contains("charset")) {
|
|
|
|
|
if (item.getContentType() == null || !item.getContentType().contains("charset")) {
|
|
|
|
|
// old yacy clients use their local default charset, on most systems UTF-8 (I hope ;)
|
|
|
|
|
args.put(item.getFieldName(), item.getString("UTF-8"));
|
|
|
|
|
} else {
|
|
|
|
|