Apache Nutch is an extensible and scalable web crawler
NUTCH-954 Strict application of Content-Length limit for http protocols (Alexis Detreglode via jnioche)
Julien Nioche3e960180336a
diff --git a/CHANGES.txt b/CHANGES.txtindex fdd47f7e2..69c3ce3d0 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogRelease 1.3 - Current Development+* NUTCH-954 Strict application of Content-Length limit for http protocols (Alexis Detreglode via jnioche)+* NUTCH-950 DomainURLFilter throws NPE on bogus urls (Alexis Detreglode via jnioche)* NUTCH-935 basicurlnormalizer removes unnecessary /./ in URLsdiff --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 9ed77f513..65b83f717 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@@ -225,12 +225,10 @@ public class HttpResponse implements Response {ByteArrayOutputStream out = new ByteArrayOutputStream(Http.BUFFER_SIZE);byte[] bytes = new byte[Http.BUFFER_SIZE];int length = 0; // read content- for (int i = in.read(bytes); i != -1; i = in.read(bytes)) {+ for (int i = in.read(bytes); i != -1 && length + i <= contentLength; i = in.read(bytes)) {out.write(bytes, 0, i);length += i;- if (length >= contentLength)- break;}content = out.toByteArray();}diff --git a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpResponse.java b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpResponse.javaindex 43baf371c..84a57c53b 100644--- a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpResponse.java+++ b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpResponse.java@@ -124,7 +124,7 @@ public class HttpResponse implements Response {int totalRead = 0;ByteArrayOutputStream out = new ByteArrayOutputStream();while ((bufferFilled = in.read(buffer, 0, buffer.length)) != -1- && totalRead < contentLength) {+ && totalRead + bufferFilled < contentLength) {totalRead += bufferFilled;out.write(buffer, 0, bufferFilled);}