org.apache.nutch.protocol.file

## Class FileResponse

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

-     public class FileResponse
      extends java.lang.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

    Constructors
    Constructor and Description
    `FileResponse(java.net.URL url, CrawlDatum datum, File file, Configuration conf)` Default public constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getCode()` Returns the response code.
    `byte[]` | `getContent()`
    `java.lang.String` | `getHeader(java.lang.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(java.net.URL url,
                              CrawlDatum datum,
                              File file,
                              Configuration conf)
                       throws FileException,
                              java.io.IOException

      Default public constructor
      Parameters:
        `url` -
        `datum` -
        `file` -
        `conf` -
      Throws:
        `FileException`
        `java.io.IOException`

  - ### Method Detail

    - #### getCode

          public int getCode()

      Returns the response code.

    - #### getHeader

          public java.lang.String getHeader(java.lang.String name)

      Returns the value of a named header.

    - #### getContent

          public byte[] getContent()

    - #### toContent

          public Content toContent()

Copyright © 2019 The Apache Software Foundation