src/main/java/js/http/encoder/MultipartMixedArgumentsReader.java
@Override
	public Object[] read(HttpServletRequest httpRequest, Type[] formalParameters) throws IOException, IllegalArgumentException {
		try {
			Object[] arguments = new Object[formalParameters.length];
			int argumentIndex = 0;

			ServletFileUpload multipart = new ServletFileUpload();
			FileItemIterator iterator = multipart.getItemIterator(httpRequest);

			FileItemStream fileItemStream = null;
			while (iterator.hasNext()) {
				fileItemStream = iterator.next();
				String contentType = fileItemStream.getContentType();
				Type parameterType = formalParameters[argumentIndex];

				ArgumentPartReader reader = argumentsReaderFactory.getArgumentPartReader(contentType, parameterType);
				boolean streamArgument = StreamFactory.isStream(parameterType);

				ArgumentPartReader argumentPartReader = (ArgumentPartReader) reader;
				InputStream inputStream = streamArgument ? new LazyFileItemStream(fileItemStream) : fileItemStream.openStream();

				arguments[argumentIndex] = argumentPartReader.read(inputStream, parameterType);
				++argumentIndex;

				// stream argument should be last on mixed arguments list
				// save it to local thread storage for clean-up after arguments processed by application
				if (streamArgument) {
					threadLocal.set(inputStream);
					break;
				}
				inputStream.close();
			}

			if (argumentIndex != formalParameters.length) {
				throw new IllegalArgumentException("Not all parameters processed due to stream argument that is not the last on arguments list.");
			}
			return arguments;
		} catch (FileUploadException e) {
			throw new IOException(e.getMessage());
		}
	}
@Override
	public Object[] read(HttpServletRequest httpRequest, Type[] formalParameters) throws IOException, IllegalArgumentException {
		try {
			Object[] arguments = new Object[formalParameters.length];
			int argumentIndex = 0;

			ServletFileUpload multipart = new ServletFileUpload();
			FileItemIterator iterator = multipart.getItemIterator(httpRequest);

			FileItemStream fileItemStream = null;
			while (iterator.hasNext()) {
				fileItemStream = iterator.next();
				String contentType = fileItemStream.getContentType();
				Type parameterType = formalParameters[argumentIndex];

				ArgumentPartReader reader = argumentsReaderFactory.getArgumentPartReader(contentType, parameterType);
				boolean streamArgument = StreamFactory.isStream(parameterType);

				ArgumentPartReader argumentPartReader = (ArgumentPartReader) reader;
				InputStream inputStream = streamArgument ? new LazyFileItemStream(fileItemStream) : fileItemStream.openStream();

				arguments[argumentIndex] = argumentPartReader.read(inputStream, parameterType);
				++argumentIndex;

				// stream argument should be last on mixed arguments list
				// save it to local thread storage for clean-up after arguments processed by application
				if (streamArgument) {
					threadLocal.set(inputStream);
					break;
				}
				inputStream.close();
			}

			if (argumentIndex != formalParameters.length) {
				throw new IllegalArgumentException("Not all parameters processed due to stream argument that is not the last on arguments list.");
			}
			return arguments;
		} catch (FileUploadException e) {
			throw new IOException(e.getMessage());
		}
	}
Read mixed body entities from HTTP request, creating and initializing arguments accordingly given formal parameters. The
number and order of arguments from multipart mixed message should respect formal parameter types. Also stream argument,
if present, should be a single one and the last on arguments list.

@param httpRequest HTTP request,
@param formalParameters formal parameter types.
@return arguments array.
@throws IOException if reading from request input stream fails.
@throws IllegalArgumentException if arguments from HTTP request cannot be parsed.
@throws IllegalArgumentException if content type for a mixed entity body is not supported.
@throws IllegalArgumentException if there is a stream argument but is not the last on arguments list.