This class is a protocol plugin used for ftp: scheme. It creates FtpResponse object and gets the content of the url from it. Configurable parameters are ftp.username, ftp.password, ftp.content.limit, ftp.timeout, ftp.server.timeout, {@code ftp.password
| 44 | * . For details see "FTP properties" section in {@code nutch-default.xml}. |
| 45 | */ |
| 46 | public class Ftp implements Protocol { |
| 47 | |
| 48 | protected static final Logger LOG = LoggerFactory |
| 49 | .getLogger(MethodHandles.lookup().lookupClass()); |
| 50 | |
| 51 | private static final Collection<WebPage.Field> FIELDS = new HashSet<WebPage.Field>(); |
| 52 | |
| 53 | static { |
| 54 | FIELDS.add(WebPage.Field.MODIFIED_TIME); |
| 55 | FIELDS.add(WebPage.Field.HEADERS); |
| 56 | } |
| 57 | |
| 58 | static final int BUFFER_SIZE = 16384; // 16*1024 = 16384 |
| 59 | |
| 60 | static final int MAX_REDIRECTS = 5; |
| 61 | |
| 62 | int timeout; |
| 63 | |
| 64 | int maxContentLength; |
| 65 | |
| 66 | String userName; |
| 67 | String passWord; |
| 68 | |
| 69 | // typical/default server timeout is 120*1000 millisec. |
| 70 | // better be conservative here |
| 71 | int serverTimeout; |
| 72 | |
| 73 | // when to have client start anew |
| 74 | long renewalTime = -1; |
| 75 | |
| 76 | boolean keepConnection; |
| 77 | |
| 78 | boolean followTalk; |
| 79 | |
| 80 | // ftp client |
| 81 | Client client = null; |
| 82 | // ftp dir list entry parser |
| 83 | FTPFileEntryParser parser = null; |
| 84 | |
| 85 | private Configuration conf; |
| 86 | |
| 87 | private FtpRobotRulesParser robots = null; |
| 88 | |
| 89 | // constructor |
| 90 | public Ftp() { |
| 91 | robots = new FtpRobotRulesParser(); |
| 92 | } |
| 93 | |
| 94 | /** Set the timeout. */ |
| 95 | public void setTimeout(int to) { |
| 96 | timeout = to; |
| 97 | } |
| 98 | |
| 99 | /** Set the point at which content is truncated. */ |
| 100 | public void setMaxContentLength(int length) { |
| 101 | maxContentLength = length; |
| 102 | } |
| 103 |