class IfMultipart extends AbstractPipe {

	@Override
	public PipeRunResult doPipe(Message message, IPipeLineSession session) throws PipeRunException {
		String forward;
		PipeForward pipeForward = null;

		if (message == null || message.asObject() == null) {
			forward = elseForwardName;
		} else {
			if (!(message.asObject() instanceof HttpServletRequest)) {
				throw new PipeRunException(this, getLogPrefix(null) + "expected HttpServletRequest as input, got [" + ClassUtils.nameOf(message) + "]");
			}

			HttpServletRequest request = (HttpServletRequest) message.asObject();
			String contentType = request.getContentType();
			if (StringUtils.isNotEmpty(contentType) && contentType.startsWith("multipart")) {
				forward = thenForwardName;
			} else {
				forward = elseForwardName;
			}
		}

		log.debug(getLogPrefix(session) + "determined forward [" + forward + "]");

		pipeForward = findForward(forward);

		if (pipeForward == null) {
			throw new PipeRunException(this, getLogPrefix(null) + "cannot find forward or pipe named [" + forward + "]");
		}
		log.debug(getLogPrefix(session) + "resolved forward [" + forward + "] to path [" + pipeForward.getPath() + "]");
		return new PipeRunResult(pipeForward, message);
	}

}