Class FileResponse

java.lang.Object
org.apache.nutch.protocol.file.FileResponse

public class FileResponse extends Object
FileResponse.java mimics file replies as http response. It tries its best to follow http's way for headers, response codes as well as exceptions. Comments: (1) java.net.URL and java.net.URLConnection can handle file: scheme. However they are not flexible enough, so not used in this implementation. (2) java.io.File is used for its abstractness across platforms. Warning: java.io.File API (1.4.2) does not elaborate on how special files, such as /dev/* in unix and /proc/* on linux, are treated. Tests show (a) java.io.File.isFile() return false for /dev/* (b) java.io.File.isFile() return true for /proc/* (c) java.io.File.length() return 0 for /proc/* We are probably oaky for now. Could be buggy here. How about special files on windows? (3) java.io.File API (1.4.2) does not seem to know unix hard link files. They are just treated as individual files. (4) No funcy POSIX file attributes yet. May never need?
  • Constructor Details

    • FileResponse

      public FileResponse(URL url, CrawlDatum datum, File file, Configuration conf) throws FileException, IOException
      Default public constructor
      Parameters:
      url - the canonical URL associated with the response
      datum - crawl information for the URL
      file - the actual File containing content for the url
      conf - a populated Configuration
      Throws:
      FileException - if the input file does not use file protocol
      IOException - if there is a fatal I/O error obtaining the input file
  • Method Details

    • getCode

      public int getCode()
      Get the response code.
      Returns:
      the int response code
    • getHeader

      public String getHeader(String name)
      Returns the value of a named header.
      Parameters:
      name - header key to retrieve a value for
      Returns:
      the header value
    • getContent

      public byte[] getContent()
    • toContent

      public Content toContent()