public byte[] parseBody(InputStream is, IHttpHeaders headers) {
ContentLengthHttpHeader contentLengthHeader = ((ContentLengthHttpHeader) headers.getHeader("Content-Length"));
ContentTypeHttpHeader contentTypeHeader = ((ContentTypeHttpHeader) headers.getHeader("Content-Type"));
IHttpHeader transferEncoding = headers.getHeader("Transfer-Encoding");
TransferEncodingHttpHeader transferEncodingHeader = null;
if (transferEncoding != null) {
transferEncodingHeader = (TransferEncodingHttpHeader) transferEncoding;
}
String contentType = contentTypeHeader.getMediaType().getType();
Charset charset = contentTypeHeader.getMediaType().getCharset();
if (transferEncodingHeader == null || transferEncodingHeader.getValue() == null) {
return null;
} else {
if (transferEncodingHeader.getValue().compareTo("chunked") == 0) {
return readChunked(is, headers);
} else {
throw new HttpException(HttpStatusCode.STATUS_501_NOT_IMPLEMENTED,
String.format("The Transfer-Encoding '%1s' is not supported.", transferEncoding));
}