org.apache.droids.protocol.http
Class HttpProtocol

java.lang.Object
  extended by org.apache.droids.helper.Loggable
      extended by org.apache.droids.protocol.http.HttpProtocol
All Implemented Interfaces:
Protocol

public class HttpProtocol
extends Loggable
implements Protocol

Protocol handler based on HttpClient 4.0.


Field Summary
 
Fields inherited from class org.apache.droids.helper.Loggable
log
 
Constructor Summary
HttpProtocol()
           
HttpProtocol(org.apache.http.client.HttpClient httpclient)
           
 
Method Summary
 java.lang.String getUserAgent()
           
 boolean isAllowed(java.net.URI uri)
          Some protocols (like http) offer a mechanism to evaluate whether the client can request a given url (in http this is the robots.txt configuration)
 boolean isForceAllow()
          You can force that a site is allowed (ignoring the robots.txt).
 ManagedContentEntity load(java.net.URI uri)
          Return the content entity represent of the url
 void setForceAllow(boolean forceAllow)
          You can force that a site is allowed (ignoring the robot.txt).
 void setUserAgent(java.lang.String userAgent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpProtocol

public HttpProtocol(org.apache.http.client.HttpClient httpclient)

HttpProtocol

public HttpProtocol()
Method Detail

load

public ManagedContentEntity load(java.net.URI uri)
                          throws java.io.IOException
Description copied from interface: Protocol
Return the content entity represent of the url

Specified by:
load in interface Protocol
Returns:
the content of the given url
Throws:
java.io.IOException

isAllowed

public boolean isAllowed(java.net.URI uri)
Description copied from interface: Protocol
Some protocols (like http) offer a mechanism to evaluate whether the client can request a given url (in http this is the robots.txt configuration)

Specified by:
isAllowed in interface Protocol
Parameters:
uri - the url to evaluate
Returns:
true if we can request the url. false if we are forbidden.

getUserAgent

public java.lang.String getUserAgent()

setUserAgent

public void setUserAgent(java.lang.String userAgent)

isForceAllow

public boolean isForceAllow()
You can force that a site is allowed (ignoring the robots.txt). This should only be used on server that you control and where you have the permission to ignore the robots.txt.

Returns:
true if you are rude and ignore robots.txt. false if you are playing nice.

setForceAllow

public void setForceAllow(boolean forceAllow)
You can force that a site is allowed (ignoring the robot.txt). This should only be used on server that you control and where you have the permission to ignore the robots.txt.

Parameters:
forceAllow - if you want to force an allow and ignore the robot.txt set to true. If you want to obey the rules and be polite set to false.


Copyright © 2007-2009. All Rights Reserved.