|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.vity.freerapid.plugins.webclient.DownloadClient
public class DownloadClient
Robot to browse on the web.
HttpDownloadClient
Field Summary | |
---|---|
protected String |
asString
string content of last request |
protected org.apache.commons.httpclient.HttpClient |
client
Field client |
protected String |
referer
Field referer - HTTP referer |
Constructor Summary | |
---|---|
DownloadClient()
Constructor - creates a new DownloadClient instance. |
Method Summary | |
---|---|
String |
getContentAsString()
Method returns string content (web page - server response), which was gotten from the last GET or POST request |
protected String |
getContentPageCharset()
|
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 |
protected String |
inflate(InputStream in)
Converts given GZIPed input stream into string. |
void |
initClient(ConnectionSettings settings)
Initialization of client with connection settings that should be used for creating http connection |
protected boolean |
isRedirect(int statuscode)
Checks if the given status code is type redirect |
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. |
protected void |
setDefaultsForMethod(org.apache.commons.httpclient.HttpMethod method)
Method setDefaultsForMethod sets default header request values - emulates Mozilla Firefox |
void |
setReferer(String referer)
Sets referer value for the next HTTP request This method should be called before getGetMethod or getPostMethod |
protected void |
toString(org.apache.commons.httpclient.HttpMethod method)
Help method for to log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.apache.commons.httpclient.HttpClient client
HttpClient
protected String referer
protected String asString
Constructor Detail |
---|
public DownloadClient()
Method Detail |
---|
public void initClient(ConnectionSettings settings)
HttpDownloadClient
initClient
in interface HttpDownloadClient
settings
- internet connection settingsprotected void setDefaultsForMethod(org.apache.commons.httpclient.HttpMethod method)
method
- public org.apache.commons.httpclient.methods.PostMethod getPostMethod(String uri)
HttpDownloadClient
getPostMethod
in interface HttpDownloadClient
uri
- URI for given HTTP request
PostMethod
public String getReferer()
HttpDownloadClient
getReferer
in interface HttpDownloadClient
public InputStream makeFinalRequestForFile(org.apache.commons.httpclient.HttpMethod method, HttpFile file, boolean allowRedirect) throws IOException
HttpDownloadClient
makeFinalRequestForFile
in interface HttpDownloadClient
method
- a descendant of HttpMethod - PostMethod or GetMethodfile
- the file that is downloadedallowRedirect
- allow redirect flag
IOException
- error I/OHttpClient.executeMethod(org.apache.commons.httpclient.HttpMethod)
public InputStream makeRequestForFile(org.apache.commons.httpclient.HttpMethod method) throws IOException
HttpDownloadClient
makeRequestForFile
in interface HttpDownloadClient
method
- a descendant of HttpMethod - PostMethod or GetMethod
IOException
- error I/OHttpClient.executeMethod(org.apache.commons.httpclient.HttpMethod)
public int makeRequest(org.apache.commons.httpclient.HttpMethod method, boolean allowRedirect) throws IOException
HttpDownloadClient
makeRequest
in interface HttpDownloadClient
method
- a descendant of HttpMethod - PostMethod or GetMethodallowRedirect
- allow redirect flag
IOException
- error I/OHttpClient.executeMethod(org.apache.commons.httpclient.HttpMethod)
protected boolean isRedirect(int statuscode)
statuscode
- http response status code
public org.apache.commons.httpclient.methods.GetMethod getGetMethod(String uri)
HttpDownloadClient
getGetMethod
in interface HttpDownloadClient
uri
- URI for given HTTP request
GetMethod
protected void toString(org.apache.commons.httpclient.HttpMethod method)
method
- protected String inflate(InputStream in) throws IOException
in
- input stream which should be converted
IOException
- when there was an error during reading from the streamprotected String getContentPageCharset()
public void setReferer(String referer)
HttpDownloadClient
setReferer
in interface HttpDownloadClient
referer
- URI for the next request made by method makeRequestpublic ConnectionSettings getSettings()
HttpDownloadClient
getSettings
in interface HttpDownloadClient
public org.apache.commons.httpclient.HttpClient getHTTPClient()
HttpDownloadClient
getHTTPClient
in interface HttpDownloadClient
HttpClient
public String getContentAsString()
HttpDownloadClient
getContentAsString
in interface HttpDownloadClient
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |