Apache Nutch is an extensible and scalable web crawler
NUTCH-2562 protocol-http fails to read large chunked HTTP responses - if http.content.limit is reached skip remaining chunked content including any headers in the trailer
Sebastian Nagelc658d753635e
diff --git a/src/plugin/protocol-http/src/java/org/apache/nutch/protocol/http/HttpResponse.java b/src/plugin/protocol-http/src/java/org/apache/nutch/protocol/http/HttpResponse.javaindex 591b94298..56ae789f3 100644--- a/src/plugin/protocol-http/src/java/org/apache/nutch/protocol/http/HttpResponse.java+++ b/src/plugin/protocol-http/src/java/org/apache/nutch/protocol/http/HttpResponse.java@@ -437,9 +437,11 @@ public class HttpResponse implements Response {break;}- if (http.getMaxContent() >= 0 && (contentBytesRead + chunkLen) > http- .getMaxContent())+ if (http.getMaxContent() >= 0+ && (contentBytesRead + chunkLen) > http.getMaxContent()) {+ // content will be trimmed when processing this chunkchunkLen = http.getMaxContent() - contentBytesRead;+ }// read one chunkint chunkBytesRead = 0;@@ -465,17 +467,26 @@ public class HttpResponse implements Response {}contentBytesRead += chunkBytesRead;+ if (http.getMaxContent() >= 0+ && contentBytesRead >= http.getMaxContent()) {+ Http.LOG.trace("Http: content limit reached");+ break;+ }+readLine(in, line, false);}+ content = out.toByteArray();+if (!doneChunks) {+ // content trimmedif (contentBytesRead != http.getMaxContent())throw new HttpException("chunk eof: !doneChunk && didn't max out");return;}- content = out.toByteArray();+ // read trailing headersparseHeaders(in, line, null);}