cz.vity.freerapid.plugins.webclient.interfaces
Interface HttpDownloadClient

All Known Implementing Classes:
DownloadClient

public interface HttpDownloadClient

Interface that represents HTTP robot - a client - for browsing pages. Robot emulates WebBrowser.

Author:
Vity

Method Summary
 String getContentAsString()
          Method returns string content (web page - server response), which was gotten from the last GET or POST request
 org.apache.commons.httpclient.methods.GetMethod getGetMethod(String uri)
          Returns setuble object for creation GET HTTP request
 org.apache.commons.httpclient.HttpClient getHTTPClient()
          Method returns direct access to instance of HttpClient
 org.apache.commons.httpclient.methods.PostMethod getPostMethod(String uri)
          Returns setuble object for creation POST HTTP request
 String getReferer()
          Return value of HTTP referer from the last HTTP request
 ConnectionSettings getSettings()
          Getter
 void initClient(ConnectionSettings settings)
          Initialization of client with connection settings that should be used for creating http connection
 InputStream makeFinalRequestForFile(org.apache.commons.httpclient.HttpMethod method, HttpFile file, boolean allowRedirect)
          Runs HTTP request to get file specified in file parameter.
 int makeRequest(org.apache.commons.httpclient.HttpMethod method, boolean allowRedirect)
          Runs simple HTTP request with optional redirect.
 InputStream makeRequestForFile(org.apache.commons.httpclient.HttpMethod method)
          Runs simple direct HTTP request to get a file - eg.
 void setReferer(String referer)
          Sets referer value for the next HTTP request This method should be called before getGetMethod or getPostMethod
 

Method Detail

initClient

void initClient(ConnectionSettings settings)
Initialization of client with connection settings that should be used for creating http connection

Parameters:
settings - internet connection settings

getPostMethod

org.apache.commons.httpclient.methods.PostMethod getPostMethod(String uri)
Returns setuble object for creation POST HTTP request

Parameters:
uri - URI for given HTTP request
Returns:
new instance of PostMethod with default settings; referer is already set
See Also:
PostMethod

getGetMethod

org.apache.commons.httpclient.methods.GetMethod getGetMethod(String uri)
Returns setuble object for creation GET HTTP request

Parameters:
uri - URI for given HTTP request
Returns:
new instance of GetMethod with default settings
See Also:
GetMethod

getReferer

String getReferer()
Return value of HTTP referer from the last HTTP request

Returns:
actual value of referer parsed from HTTP response header

setReferer

void setReferer(String referer)
Sets referer value for the next HTTP request This method should be called before getGetMethod or getPostMethod

Parameters:
referer - URI for the next request made by method makeRequest

makeFinalRequestForFile

InputStream makeFinalRequestForFile(org.apache.commons.httpclient.HttpMethod method,
                                    HttpFile file,
                                    boolean allowRedirect)
                                    throws IOException
Runs HTTP request to get file specified in file parameter. According to HTTP response filename and file size attributes are updated.

Parameters:
method - a descendant of HttpMethod - PostMethod or GetMethod
file - the file that is downloaded
allowRedirect - allow redirect flag
Returns:
beginning of the stream for reading or null if there was no file stream in response
Throws:
IOException - error I/O
See Also:
HttpClient.executeMethod(org.apache.commons.httpclient.HttpMethod)

makeRequestForFile

InputStream makeRequestForFile(org.apache.commons.httpclient.HttpMethod method)
                               throws IOException
Runs simple direct HTTP request to get a file - eg. CAPTCHA picture
Redirection is off

Parameters:
method - a descendant of HttpMethod - PostMethod or GetMethod
Returns:
beginning of the stream for reading or null if there was no file stream in HTTP response
Throws:
IOException - error I/O
See Also:
HttpClient.executeMethod(org.apache.commons.httpclient.HttpMethod)

makeRequest

int makeRequest(org.apache.commons.httpclient.HttpMethod method,
                boolean allowRedirect)
                throws IOException
Runs simple HTTP request with optional redirect.

Parameters:
method - a descendant of HttpMethod - PostMethod or GetMethod
allowRedirect - allow redirect flag
Returns:
HTTP result code
Throws:
IOException - error I/O
See Also:
HttpClient.executeMethod(org.apache.commons.httpclient.HttpMethod)

getSettings

ConnectionSettings getSettings()
Getter

Returns:
Returns actual internet connection settings used by HTTP client

getHTTPClient

org.apache.commons.httpclient.HttpClient getHTTPClient()
Method returns direct access to instance of HttpClient

Returns:
actual used HttpClient instance
See Also:
HttpClient

getContentAsString

String getContentAsString()
Method returns string content (web page - server response), which was gotten from the last GET or POST request

Returns:
webpage content, If request returned a file stream then this method empty string.