Apache Nutch is an extensible and scalable web crawler
NUTCH-2699 Protocol-okhttp: needless loops to increment requested bytes counter when more content is already buffered - check whether http.content.limit is non-negative (not only -1) as defined in nutch-default.xml
Sebastian Nagelf51a276d619e
diff --git a/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttpResponse.java b/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttpResponse.javaindex 5e47386a6..7eaf19728 100644--- a/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttpResponse.java+++ b/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttpResponse.java@@ -148,7 +148,7 @@ public class OkHttpResponse implements Response {}int maxContentBytes = Integer.MAX_VALUE;- if (maxContent != -1) {+ if (maxContent >= 0) {maxContentBytes = Math.min(maxContentBytes, maxContent);}@@ -190,7 +190,7 @@ public class OkHttpResponse implements Response {}int bytesBuffered = (int) source.buffer().size();int bytesToCopy = bytesBuffered;- if (maxContent != -1 && bytesToCopy > maxContent) {+ if (maxContent >= 0 && bytesToCopy > maxContent) {// okhttp's internal buffer is larger than maxContenttruncated.setReason(TruncatedContentReason.LENGTH);bytesToCopy = maxContentBytes;