in client/src/main/java/org/apache/ahc/codec/HttpDecoder.java [102:136]
public String decodeLine(IoBuffer in) throws Exception {
int beginPos = in.position();
int limit = in.limit();
boolean lastIsCR = false;
int terminatorPos = -1;
for (int i = beginPos; i < limit; i++) {
byte b = in.get(i);
if (b == CR) {
lastIsCR = true;
} else {
if (b == LF && lastIsCR) {
terminatorPos = i;
break;
}
lastIsCR = false;
}
}
//Check if we don't have enough data to process or found a full readable line
if (terminatorPos == -1) {
return null;
}
String result = null;
if (terminatorPos > 1) {
IoBuffer line = in.slice();
line.limit(terminatorPos - beginPos - 1);
result = line.getString(decoder);
}
in.position(terminatorPos + 1);
return result;
}