private void handlePostRequest(final HttpServletRequestImpl.Builder builder,
final InputStream in,
final Headers headers)
throws IOException, MalformedInputException {
int postLength;
if (headers.containsHeader(Headers.HEADER_CONTENT_LENGTH)) {
try {
postLength = Integer.parseInt(headers.getHeader(Headers.HEADER_CONTENT_LENGTH));
} catch (NumberFormatException e) {
throw new MalformedInputException(e.getMessage());
}
} else {
throw new LengthRequiredException();
}
if (postLength < 1) {
return;
}
if (postLength > POST_MAX_LENGTH) {
throw new PayloadTooLargeProtocolException("Payload of " + postLength + "b exceeds the limit of "
+ POST_MAX_LENGTH + "b");
}
if (isMultipartRequest(headers)) {
handlePostMultipartRequest(builder, headers, in, postLength);
} else {
handlePostPlainRequest(builder, in, postLength);
}
}