Apache Nutch is an extensible and scalable web crawler
NUTCH-105 - Network error during robots.txt fetch causes file to beignored, contributed by Greg Kim
Sami Siren6dd287537269
diff --git a/CHANGES.txt b/CHANGES.txtindex 2df40a5d7..552da758f 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -23,6 +23,9 @@ Unreleased changes (0.9-dev)8. NUTCH-338 - Remove the text parser as an option for parsing PDF filesin parse-plugins.xml (Chris A. Mattmann via siren)++ 9. NUTCH-105 - Network error during robots.txt fetch causes file to+ be ignored (Greg Kim via siren)Release 0.8 - 2006-07-25diff --git a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/RobotRulesParser.java b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/RobotRulesParser.javaindex 6f3bbe15c..581f96797 100644--- a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/RobotRulesParser.java+++ b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/RobotRulesParser.java@@ -420,6 +420,8 @@ public class RobotRulesParser implements Configurable {RobotRuleSet robotRules = (RobotRuleSet)CACHE.get(host);+ boolean cacheRule = true;+if (robotRules == null) { // cache missif (LOG.isTraceEnabled()) { LOG.trace("cache miss " + url); }try {@@ -430,16 +432,22 @@ public class RobotRulesParser implements Configurable {robotRules = parseRules(response.getContent());else if ( (response.getCode() == 403) && (!allowForbidden) )robotRules = FORBID_ALL_RULES; // use forbid all- else+ else if (response.getCode() >= 500) {+ cacheRule = false;+ robotRules = EMPTY_RULES;+ }elserobotRules = EMPTY_RULES; // use default rules} catch (Throwable t) {if (LOG.isInfoEnabled()) {LOG.info("Couldn't get robots.txt for " + url + ": " + t.toString());}+ cacheRule = false;robotRules = EMPTY_RULES;}- CACHE.put(host, robotRules); // cache rules for host+ if (cacheRule){+ CACHE.put(host, robotRules); // cache rules for host+ }}return robotRules;}