com.norconex.collector.http.handler.impl
Class SimpleHttpHeadersFetcher

java.lang.Object
  extended by com.norconex.collector.http.handler.impl.SimpleHttpHeadersFetcher
All Implemented Interfaces:
IHttpHeadersFetcher, IXMLConfigurable, Serializable

public class SimpleHttpHeadersFetcher
extends Object
implements IHttpHeadersFetcher, IXMLConfigurable

Basic implementation of IHttpHeadersFetcher.

XML configuration usage:

  <httpHeadersFetcher 
      class="com.norconex.collector.http.handler.impl.SimpleHttpHeadersFetcher" >
      <validStatusCodes>200</validStatusCodes>
      <headersPrefix>(string to prefix headers)</headersPrefix>
  </httpHeadersFetcher>
 

The "validStatusCodes" attribute expects a coma-separated list of HTTP response code.

Author:
Pascal Essiembre
See Also:
Serialized Form

Field Summary
static int[] DEFAULT_VALID_STATUS_CODES
           
 
Constructor Summary
SimpleHttpHeadersFetcher()
           
SimpleHttpHeadersFetcher(int[] validStatusCodes)
           
 
Method Summary
 Properties fetchHTTPHeaders(org.apache.http.impl.client.DefaultHttpClient httpClient, String url)
          Returning null means the headers could not be fetched and the associated document will be skipped (treated as rejected).
 String getHeadersPrefix()
           
 int[] getValidStatusCodes()
           
 void loadFromXML(Reader in)
           
 void saveToXML(Writer out)
           
 void setHeadersPrefix(String headersPrefix)
           
 void setValidStatusCodes(int[] validStatusCodes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_VALID_STATUS_CODES

public static final int[] DEFAULT_VALID_STATUS_CODES
Constructor Detail

SimpleHttpHeadersFetcher

public SimpleHttpHeadersFetcher()

SimpleHttpHeadersFetcher

public SimpleHttpHeadersFetcher(int[] validStatusCodes)
Method Detail

getValidStatusCodes

public int[] getValidStatusCodes()

setValidStatusCodes

public void setValidStatusCodes(int[] validStatusCodes)

getHeadersPrefix

public String getHeadersPrefix()

setHeadersPrefix

public void setHeadersPrefix(String headersPrefix)

fetchHTTPHeaders

public Properties fetchHTTPHeaders(org.apache.http.impl.client.DefaultHttpClient httpClient,
                                   String url)
Description copied from interface: IHttpHeadersFetcher
Returning null means the headers could not be fetched and the associated document will be skipped (treated as rejected).

Specified by:
fetchHTTPHeaders in interface IHttpHeadersFetcher
Parameters:
httpClient - the HTTP Client
url - the url from which to fetch the headers
Returns:
HTTP headers as metadata

loadFromXML

public void loadFromXML(Reader in)
Specified by:
loadFromXML in interface IXMLConfigurable

saveToXML

public void saveToXML(Writer out)
               throws IOException
Specified by:
saveToXML in interface IXMLConfigurable
Throws:
IOException


Copyright © 2009-2013 Norconex Inc.. All Rights Reserved.