[TOC]

org.apache.nutch.protocol.file

Class 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

Constructors Constructor and Description FileResponse(URL url, CrawlDatum datum, File file, org.apache.hadoop.conf.Configuration conf) Default public constructor

Method Summary

Methods Modifier and Type Method and Description 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,
            CrawlDatum datum,
            File file,
            org.apache.hadoop.conf.Configuration conf)
             throws FileException,
                    IOException

Default public constructor

  - Parameters:
  - <code>url</code> - 
  - <code>datum</code> - 
  - <code>file</code> - 
  - <code>conf</code> -  
  - Throws: 
  - <code>FileException</code> 
  - <code>IOException</code>       

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 © 2014 The Apache Software Foundation