Author: snagel
Date: Wed Aug 7 21:10:17 2013
New Revision: 1511496
URL: http://svn.apache.org/r1511496
Log:
NUTCH-911 protocol-file to return proper protocol status for notmodified, gone,
access_denied
Modified:
nutch/branches/2.x/CHANGES.txt
nutch/branches/2.x/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/File.java
Modified: nutch/branches/2.x/CHANGES.txt
URL:
http://svn.apache.org/viewvc/nutch/branches/2.x/CHANGES.txt?rev=1511496&r1=1511495&r2=1511496&view=diff
==============================================================================
--- nutch/branches/2.x/CHANGES.txt (original)
+++ nutch/branches/2.x/CHANGES.txt Wed Aug 7 21:10:17 2013
@@ -2,6 +2,8 @@ Nutch Change Log
Current Development
+* NUTCH-911 protocol-file to return proper protocol status (Peter Lundberg via
snagel)
+
* NUTCH-1587 misspelled property "threshold" in conf/log4j.properties (snagel)
* NUTCH-1604 ProtocolFactory not thread-safe (jnioche)
Modified:
nutch/branches/2.x/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/File.java
URL:
http://svn.apache.org/viewvc/nutch/branches/2.x/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/File.java?rev=1511496&r1=1511495&r2=1511496&view=diff
==============================================================================
---
nutch/branches/2.x/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/File.java
(original)
+++
nutch/branches/2.x/src/plugin/protocol-file/src/java/org/apache/nutch/protocol/file/File.java
Wed Aug 7 21:10:17 2013
@@ -114,6 +114,16 @@ public class File implements Protocol {
if (code == 200) { // got a good response
return new ProtocolOutput(response.toContent()); // return it
+
+ } else if (code == 304) { // got not modified
+ return new ProtocolOutput(response.toContent(),
ProtocolStatusUtils.STATUS_NOTMODIFIED);
+
+ } else if (code == 401) { // access denied / no read permissions
+ return new ProtocolOutput(response.toContent(),
ProtocolStatusUtils.makeStatus(ProtocolStatusUtils.ACCESS_DENIED));
+
+ } else if (code == 404) { // no such file
+ return new ProtocolOutput(response.toContent(),
ProtocolStatusUtils.STATUS_NOTFOUND);
+
} else if (code >= 300 && code < 400) { // handle redirect
if (redirects == MAX_REDIRECTS)
throw new FileException("Too many redirects: " + url);