String rectypeStr = (String)rec.getHeader().getHeaderValue("WARC-Type");
WARCRecordType rectype;
try {
rectype = WARCRecordType.valueOf(rectypeStr);
} catch (IllegalArgumentException ex) {
throw new RecoverableIOException("unrecognized WARC-Type \"" + rectypeStr + "\"");
}
if (rectype == WARCRecordType.response || rectype == WARCRecordType.revisit) {
byte [] statusBytes = LaxHttpParser.readRawLine(rec);
int eolCharCount = getEolCharsCount(statusBytes);
if (eolCharCount <= 0) {
throw new RecoverableIOException("Failed to read http status where one " +
" was expected: " + new String(statusBytes));
}
String statusLineStr = EncodingUtil.getString(statusBytes, 0,
statusBytes.length - eolCharCount, ARCConstants.DEFAULT_ENCODING);
if ((statusLineStr == null) ||
!StatusLine.startsWithHTTP(statusLineStr)) {
throw new RecoverableIOException("Failed parse of http status line.");
}
StatusLine statusLine = new StatusLine(statusLineStr);
this.status = statusLine.getStatusCode();