org.apache.nutch.protocol.file
Class FileResponse

java.lang.Object
  extended by 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?

Author:
John Xing

Constructor Summary
FileResponse(URL url, WebPage page, File file, Configuration conf)
           
 
Method Summary
 int getCode()
          Returns the response code.
 byte[] getContent()
           
 String getHeader(String name)
          Returns the value of a named header.
 Content toContent()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileResponse

public FileResponse(URL url,
                    WebPage page,
                    File file,
                    Configuration conf)
             throws FileException,
                    IOException
Throws:
FileException
IOException
Method Detail

getCode

public int getCode()
Returns the response code.


getHeader

public String getHeader(String name)
Returns the value of a named header.


getContent

public byte[] getContent()

toContent

public Content toContent()


Copyright © 2012 The Apache Software Foundation