Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

* fix negative filelength for files >2G

f1orie4aabaa1c30e
diff --git a/source/de/anomic/crawler/retrieval/Response.java b/source/de/anomic/crawler/retrieval/Response.java
index bb21ba980..d3f29fda6 100755
--- a/source/de/anomic/crawler/retrieval/Response.java
+++ b/source/de/anomic/crawler/retrieval/Response.java
@@ -243,7 +243,7 @@ public class Response {
public long size() {
if (this.responseHeader != null) {
// take the size from the response header
- return this.responseHeader.getContentLength();
+ return this.responseHeader.getContentLengthLong();
}
if (this.content != null) return this.content.length;
// the size is unknown
diff --git a/source/net/yacy/cora/protocol/HeaderFramework.java b/source/net/yacy/cora/protocol/HeaderFramework.java
index 4b21f7622..266aa5979 100644
--- a/source/net/yacy/cora/protocol/HeaderFramework.java
+++ b/source/net/yacy/cora/protocol/HeaderFramework.java
@@ -442,6 +442,23 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stri
return -1;
}
+ /*
+ * provide method, which can handle big filelengths (for example from ftp)
+ * because we can't change the interface in apache httpclient
+ *
+ * @see org.apache.commons.fileupload.RequestContext#getContentLength()
+ */
+ public long getContentLengthLong() {
+ if (containsKey(CONTENT_LENGTH)) {
+ try {
+ return Long.parseLong(get(CONTENT_LENGTH));
+ } catch (final NumberFormatException e) {
+ return -1;
+ }
+ }
+ return -1;
+ }
+
/*
* (non-Javadoc)
*