String contentLen = contentLength();
if (contentLen != null) {
int len = Integer.parseInt(contentLen);
if (len > 0) {
FastCharArrayWriter fastCharArrayWriter = new FastCharArrayWriter(len);
try {
StreamUtil.copy(reader, fastCharArrayWriter, len);
} catch (IOException ioex) {
throw new HttpException(ioex);
}
bodyString = fastCharArrayWriter.toString();
}
}
// chunked encoding
String transferEncoding = header("Transfer-Encoding");
if (transferEncoding != null && transferEncoding.equalsIgnoreCase("chunked")) {
FastCharArrayWriter fastCharArrayWriter = new FastCharArrayWriter();
try {
while (true) {
String line = reader.readLine();
int len = Integer.parseInt(line, 16);
if (len > 0) {
StreamUtil.copy(reader, fastCharArrayWriter, len);
reader.readLine();
} else {
// end reached, read trailing headers, if there is any
readHeaders(reader);
break;
}
}
} catch (IOException ioex) {
throw new HttpException(ioex);
}
bodyString = fastCharArrayWriter.toString();
}
// no body yet - special case
if (bodyString == null) {
// body ends when stream closes
FastCharArrayWriter fastCharArrayWriter = new FastCharArrayWriter();
try {
StreamUtil.copy(reader, fastCharArrayWriter);
} catch (IOException ioex) {
throw new HttpException(ioex);
}
bodyString = fastCharArrayWriter.toString();
}
// BODY READY - PARSE BODY
String charset = this.charset;
if (charset == null) {