in core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java [218:260]
private void readRawField() throws IOException, MimeException {
if (endOfHeader)
throw new IllegalStateException();
LineReaderInputStream instream = getDataStream();
try {
for (;;) {
// If there's still data stuck in the line buffer
// copy it to the field buffer
int len = linebuf.length();
if (len > 0) {
fieldBuilder.append(linebuf);
}
linebuf.clear();
if (instream.readLine(linebuf) == -1) {
monitor(Event.HEADERS_PREMATURE_END);
endOfHeader = true;
break;
}
len = linebuf.length();
if (len > 0 && linebuf.byteAt(len - 1) == '\n') {
len--;
}
if (len > 0 && linebuf.byteAt(len - 1) == '\r') {
len--;
}
if (len == 0) {
// empty line detected
endOfHeader = true;
break;
}
lineCount++;
if (lineCount > 1) {
int ch = linebuf.byteAt(0);
if (ch != CharsetUtil.SP && ch != CharsetUtil.HT) {
// new header detected
break;
}
}
}
} catch (MaxLineLimitException e) {
throw new MimeException(e);
}
}