| 1 23 package org.archive.crawler.fetcher; 24 25 import java.io.IOException ; 26 import java.net.SocketTimeoutException ; 27 28 import org.apache.commons.httpclient.HttpMethod; 29 import org.apache.commons.httpclient.HttpMethodRetryHandler; 30 import org.apache.commons.httpclient.NoHttpResponseException; 31 import org.apache.commons.httpclient.methods.PostMethod; 32 33 45 public class HeritrixHttpMethodRetryHandler implements HttpMethodRetryHandler { 46 private static final int DEFAULT_RETRY_COUNT = 10; 47 48 private final int maxRetryCount; 49 50 53 public HeritrixHttpMethodRetryHandler() { 54 this(DEFAULT_RETRY_COUNT); 55 } 56 57 61 public HeritrixHttpMethodRetryHandler(int maxRetryCount) { 62 this.maxRetryCount = maxRetryCount; 63 } 64 65 public boolean retryMethod(HttpMethod method, IOException exception, 66 int executionCount) { 67 if(exception instanceof SocketTimeoutException ) { 68 return false; 71 } 72 if (executionCount >= this.maxRetryCount) { 73 return false; 75 } 76 if (exception instanceof NoHttpResponseException) { 77 return true; 79 } 80 if (!method.isRequestSent() && (!(method instanceof PostMethod))) { 81 return true; 84 } 85 return false; 87 } 88 } 89 | Popular Tags |