LOGGER.error("Tried to read the two consecutive characters after inter boundary separator. Could have been either CRLF or DASHDASH.", ioex);
throw new HttpException(HttpStatusCode.STATUS_400_BAD_REQUEST, ioex.getMessage());
}
IHttpHeadersParser headersParser = new HttpHeadersParser();
IHttpHeaders headers = headersParser.parse(inputStream);
ContentDispositionHttpHeader partContentDisposition = (ContentDispositionHttpHeader) headers.getHeader("Content-Disposition");
if (partContentDisposition == null
|| !partContentDisposition.getDispositionType().getType().equalsIgnoreCase("form-data")
|| !partContentDisposition.getDispositionType().getParameters().containsName("name")) {
throw new HttpException(HttpStatusCode.STATUS_400_BAD_REQUEST,
String.format("Bad Content-Disposition: %s.", partContentDisposition.getRawValue()));
}
ContentTypeHttpHeader partContentType = (ContentTypeHttpHeader) headers.getHeader("Content-Type");
BoundaryDelimitedInputStream bdis = new BoundaryDelimitedInputStream(inputStream, boundary);
IHttpRequestBodyParserFactory bodyParserFactory = new HttpRequestBodyParserFactory();
IHttpRequestBodyParser partBodyParser = bodyParserFactory.build(partContentType, partContentDisposition);