Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

Fix content.limit inconsistency in http, ftp and file

Jerome Charronce45896b42e1
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index ac801eaba..f7ea8b617 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -13,8 +13,8 @@
<name>file.content.limit</name>
<value>65536</value>
<description>The length limit for downloaded content, in bytes.
- If this value is larger than zero, content longer than it will be
- truncated; otherwise (zero or negative), no truncation at all.
+ If this value is nonnegative (>=0), content longer than it will be truncated;
+ otherwise, no truncation at all.
</description>
</property>
@@ -150,11 +150,11 @@
<name>ftp.content.limit</name>
<value>65536</value>
<description>The length limit for downloaded content, in bytes.
- If this value is larger than zero, content longer than it is truncated;
- otherwise (zero or negative), no truncation at all. Caution: classical
- ftp RFCs never defines partial transfer and, in fact, some ftp servers
- out there do not handle client side forced close-down very well.
- Our implementation tries its best to handle such situations smoothly.
+ If this value is nonnegative (>=0), content longer than it will be truncated;
+ otherwise, no truncation at all.
+ Caution: classical ftp RFCs never defines partial transfer and, in fact,
+ some ftp servers out there do not handle client side forced close-down very
+ well. Our implementation tries its best to handle such situations smoothly.
</description>
</property>
diff --git a/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/FileResponse.java b/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/FileResponse.java
index 58bb51bc5..cbf5c072f 100644
--- a/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/FileResponse.java
+++ b/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/FileResponse.java
@@ -167,7 +167,7 @@ public class FileResponse {
// capture content
int len = (int) size;
- if (this.file.maxContentLength > 0 && len > this.file.maxContentLength)
+ if (this.file.maxContentLength >= 0 && len > this.file.maxContentLength)
len = this.file.maxContentLength;
this.content = new byte[len];
diff --git a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Client.java b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Client.java
index 02607f5c7..ebd88ebc4 100644
--- a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Client.java
+++ b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Client.java
@@ -344,9 +344,9 @@ public class Client extends FTP
}
entries.add(ftpFile);
count += line.length();
- // impose download limit if limit > 0, otherwise no limit
+ // impose download limit if limit >= 0, otherwise no limit
// here, cut off is up to the line when total bytes is just over limit
- if (limit > 0 && count > limit) {
+ if (limit >= 0 && count > limit) {
mandatory_close = true;
break;
}
@@ -409,9 +409,9 @@ public class Client extends FTP
new byte[org.apache.commons.net.io.Util.DEFAULT_COPY_BUFFER_SIZE];
while((len=input.read(buf,0,buf.length)) != -1){
count += len;
- // impose download limit if limit > 0, otherwise no limit
+ // impose download limit if limit >= 0, otherwise no limit
// here, cut off is exactly of limit bytes
- if (limit > 0 && count > limit) {
+ if (limit >= 0 && count > limit) {
os.write(buf,0,len-(count-limit));
mandatory_close = true;
break;