Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1647 protocol-http throws 'unzipBestEffort returned null' for redirected pages (jnioche)

Julien Nioched8fd479cb7f9
diff --git a/CHANGES.txt b/CHANGES.txt
index f079467fc..2a44a5d4f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Nutch Current Development
+* NUTCH-1647 protocol-http throws 'unzipBestEffort returned null' for redirected pages (jnioche)
+
* NUTCH-1736 Can't fetch page if http response header contains Transfer-Encoding:chunked (ysc via jnioche)
* NUTCH-1782 NodeWalker to return current node (markus)
diff --git a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.java b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.java
index 72830de78..0a56a30a7 100644
--- a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.java
+++ b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.java
@@ -359,6 +359,11 @@ public abstract class HttpBase implements Protocol {
if (LOGGER.isTraceEnabled()) { LOGGER.trace("uncompressing...."); }
+ // content can be empty (i.e. redirection) in which case
+ // there is nothing to unzip
+ if (compressed.length == 0)
+ return compressed;
+
byte[] content;
if (getMaxContent() >= 0) {
content = GZIPUtils.unzipBestEffort(compressed, getMaxContent());
@@ -379,6 +384,11 @@ public abstract class HttpBase implements Protocol {
public byte[] processDeflateEncoded(byte[] compressed, URL url) throws IOException {
+ // content can be empty (i.e. redirection) in which case
+ // there is nothing to deflate
+ if (compressed.length == 0)
+ return compressed;
+
if (LOGGER.isTraceEnabled()) { LOGGER.trace("inflating...."); }
byte[] content = DeflateUtils.inflateBestEffort(compressed, getMaxContent());