|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.faban.driver.HttpTransport com.sun.faban.driver.transport.hc3.ApacheHC3Transport
public class ApacheHC3Transport
The ApacheHC3Transport provides initialization services and utility methods for using the HTTP and HTTPS protocols through the Apache HttpClient 3.x Libraries. The convention for the method names in this class are as follows:
Constructor Summary | |
---|---|
ApacheHC3Transport()
Constructs a new ApacheHC3Transport object. |
Method Summary | |
---|---|
void |
addTextType(String texttype)
Add a MIME type to the list of text types. |
void |
closeConnections()
Close all connections currently not in use. |
String |
dumpResponseHeaders()
Utility class to get responseHeaders as a string. |
StringBuilder |
fetchPage(String page,
String[] images,
String postRequest)
Makes a POST request, fetches the main page and all other image or resource pages. |
StringBuilder |
fetchResponseData(InputStream stream)
Fetches the data from the stream, converts to char, and returns it as a StringBuilder. |
StringBuilder |
fetchResponseData(Reader reader)
Fetches the data from the reader and returns it as a StringBuilder. |
StringBuilder |
fetchURL(String url)
Reads data from the URL and returns the data read. |
StringBuilder |
fetchURL(String url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts)
Makes a Multi-part POST request to the URL. |
StringBuilder |
fetchURL(String url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts,
Map<String,String> headers)
Makes a Multi-part POST request to the URL. |
StringBuilder |
fetchURL(String url,
Map<String,String> headers)
Reads data from the URL and returns the data read. |
StringBuilder |
fetchURL(String url,
String postRequest)
Makes a POST request to the URL. |
StringBuilder |
fetchURL(String url,
String postRequest,
Map<String,String> headers)
Makes a POST request to the URL. |
StringBuilder |
fetchURL(URL url)
Reads data from the URL and returns the data read. |
StringBuilder |
fetchURL(URL url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts)
Makes a Multi-part POST request to the URL. |
StringBuilder |
fetchURL(URL url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts,
Map<String,String> headers)
Makes a Multi-part POST request to the URL. |
StringBuilder |
fetchURL(URL url,
Map<String,String> headers)
Reads data from the URL and returns the data read. |
StringBuilder |
fetchURL(URL url,
String postRequest)
Makes a POST request to the URL. |
StringBuilder |
fetchURL(URL url,
String postRequest,
Map<String,String> headers)
Makes a POST request to the URL. |
StringBuilder |
fetchURL(URL page,
URL[] images,
String postRequest)
Method not implemented. |
int |
getContentSize()
Obtains the size of the last read page or resource. |
String[] |
getCookieValuesByName(String name)
Obtains the list of cookie values by the name of the cookies. |
org.apache.commons.httpclient.HttpClient |
getHttpClient()
Obtains the HttpClient instance backing this transport. |
StringBuilder |
getResponseBuffer()
Obtains the reference of the current response buffer. |
int |
getResponseCode()
Obtains the response code of the previous request. |
String[] |
getResponseHeader(String name)
Obtains the header fields of the last request's response. |
boolean |
isFollowRedirects()
Checks whether the connections managed by this transport follows redirects or not. |
boolean |
matchResponse(InputStream stream,
String regex)
Matches the regular expression against the data read from the stream. |
boolean |
matchResponse(Reader reader,
String regex)
Matches the regular expression against the data read from the reader. |
boolean |
matchResponse(String regex)
Maches the regular expression against the data in the current buffer. |
boolean |
matchURL(String url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts,
String regex)
Matches the regular expression against the response fetched from the multi-part post request made to the URL. |
boolean |
matchURL(String url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts,
String regex,
Map<String,String> headers)
Matches the regular expression against the response fetched from the multi-part post request made to the URL. |
boolean |
matchURL(String url,
String regex)
Matches the regular expression against the response fetched from the URL. |
boolean |
matchURL(String url,
String regex,
Map<String,String> headers)
Matches the regular expression against the response fetched from the URL. |
boolean |
matchURL(String url,
String postRequest,
String regex)
Mathces the regular expression against the response fetched from the post request made to the URL. |
boolean |
matchURL(String url,
String postRequest,
String regex,
Map<String,String> headers)
Matches the regular expression against the response fetched from the post request made to the URL. |
boolean |
matchURL(URL url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts,
String regex)
Matches the regular expression against the response fetched from the multi-part post request made to the URL. |
boolean |
matchURL(URL url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts,
String regex,
Map<String,String> headers)
Matches the regular expression against the response fetched from the multi-part post request made to the URL. |
boolean |
matchURL(URL url,
String regex)
Matches the regular expression against the response fetched from the URL. |
boolean |
matchURL(URL url,
String regex,
Map<String,String> headers)
Matches the regular expression against the response fetched from the URL. |
boolean |
matchURL(URL url,
String postRequest,
String regex)
Mathces the regular expression against the response fetched from the post request made to the URL. |
boolean |
matchURL(URL url,
String postRequest,
String regex,
Map<String,String> headers)
Mathces the regular expression against the response fetched from the post request made to the URL. |
int |
readURL(String url)
Reads data from the URL and discards it, keeping just the size of the total read. |
int |
readURL(String url,
byte[] postRequest)
Makes a POST request to the URL without encoding the data (the header type is application/octet-stream). |
int |
readURL(String url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts)
Makes a Multi-part POST request to the URL. |
int |
readURL(String url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts,
Map<String,String> headers)
Makes a Multi-part POST request to the URL. |
int |
readURL(String url,
Map<String,String> headers)
Reads data from the URL and discards it, keeping just the size of the total read. |
int |
readURL(String url,
String postRequest)
Makes a POST request to the URL. |
int |
readURL(String url,
String postRequest,
Map<String,String> headers)
Makes a POST request to the URL. |
int |
readURL(URL url)
Reads data from the URL and discards it, keeping just the size of the total read. |
int |
readURL(URL url,
byte[] postRequest,
Map<String,String> headers)
Makes a POST request to the URL without encoding the data (the header type is application/octet-stream). |
int |
readURL(URL url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts)
Makes a Multi-part POST request to the URL. |
int |
readURL(URL url,
List<org.apache.commons.httpclient.methods.multipart.Part> parts,
Map<String,String> headers)
Makes a Multi-part POST request to the URL. |
int |
readURL(URL url,
Map<String,String> headers)
Reads data from the URL and discards it, keeping just the size of the total read. |
int |
readURL(URL url,
String postRequest,
Map<String,String> headers)
Makes a POST request to the URL. |
void |
setFollowRedirects(boolean follow)
Sets the http connections managed by this transport to follow or not follow HTTP redirects. |
void |
setRetry(boolean retry)
Sets whether the client should retry or not. |
Methods inherited from class com.sun.faban.driver.HttpTransport |
---|
newInstance, readURL, setProvider |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ApacheHC3Transport()
Method Detail |
---|
public void setRetry(boolean retry)
retry
- Whether to retry failed attemptspublic org.apache.commons.httpclient.HttpClient getHttpClient()
public void setFollowRedirects(boolean follow)
setFollowRedirects
in class HttpTransport
follow
- True if HTTP redirects should be automatically followed,
false otherwisepublic void addTextType(String texttype)
addTextType
in class HttpTransport
texttype
- The content type of a HTTP response that contains text.public boolean isFollowRedirects()
isFollowRedirects
in class HttpTransport
public StringBuilder getResponseBuffer()
getResponseBuffer
in class HttpTransport
public int readURL(URL url, Map<String,String> headers) throws IOException
readURL
in class HttpTransport
url
- The URL to read fromheaders
- The request headers
IOException
public int readURL(URL url) throws IOException
readURL
in class HttpTransport
url
- The URL to read from
IOException
public int readURL(String url, Map<String,String> headers) throws IOException
readURL
in class HttpTransport
url
- The URL to read fromheaders
- The request headers
IOException
public int readURL(String url) throws IOException
readURL
in class HttpTransport
url
- The URL to read from
IOException
public int readURL(String url, String postRequest, Map<String,String> headers) throws IOException
readURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request stringheaders
- The request headers
IOException
public int readURL(URL url, String postRequest, Map<String,String> headers) throws IOException
readURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request stringheaders
- The request headers
IOException
public int readURL(URL url, byte[] postRequest, Map<String,String> headers) throws IOException
readURL
in class HttpTransport
url
- The URL to read frompostRequest
- The binary data to sendheaders
- The request headers
IOException
public int readURL(String url, byte[] postRequest) throws IOException
readURL
in class HttpTransport
url
- The URL to read frompostRequest
- The binary data to send
IOException
public int readURL(String url, String postRequest) throws IOException
readURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request string
IOException
public int readURL(String url, List<org.apache.commons.httpclient.methods.multipart.Part> parts, Map<String,String> headers) throws IOException
url
- The URL to read fromparts
- The parts listheaders
- The request headers
IOException
public int readURL(URL url, List<org.apache.commons.httpclient.methods.multipart.Part> parts) throws IOException
url
- The URL to read fromparts
- The parts list
IOException
public int readURL(String url, List<org.apache.commons.httpclient.methods.multipart.Part> parts) throws IOException
url
- The URL to read fromparts
- The parts list
IOException
public int readURL(URL url, List<org.apache.commons.httpclient.methods.multipart.Part> parts, Map<String,String> headers) throws IOException
url
- The URL to read fromparts
- The parts listheaders
- The request headers
IOException
public StringBuilder fetchURL(URL url, Map<String,String> headers) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read fromheaders
- The request headers
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(URL url) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read from
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url, Map<String,String> headers) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read fromheaders
- The request headers
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read from
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url, String postRequest) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request string
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url, String postRequest, Map<String,String> headers) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request stringheaders
- The request headers
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(URL url, String postRequest, Map<String,String> headers) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request stringheaders
- The request headers
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(URL url, String postRequest) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request string
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url, List<org.apache.commons.httpclient.methods.multipart.Part> parts, Map<String,String> headers) throws IOException
url
- The URL to read fromparts
- The parts listheaders
- The request headers
IOException
public StringBuilder fetchURL(URL url, List<org.apache.commons.httpclient.methods.multipart.Part> parts) throws IOException
url
- The URL to read fromparts
- The parts list
IOException
public StringBuilder fetchURL(String url, List<org.apache.commons.httpclient.methods.multipart.Part> parts) throws IOException
url
- The URL to read fromparts
- The parts list
IOException
public StringBuilder fetchURL(URL url, List<org.apache.commons.httpclient.methods.multipart.Part> parts, Map<String,String> headers) throws IOException
url
- The URL to read fromparts
- The parts listheaders
- The request headers
IOException
public StringBuilder fetchURL(URL page, URL[] images, String postRequest) throws IOException
fetchURL
in class HttpTransport
page
- The page URLimages
- The image or other resource URLs to fetch with pagepostRequest
- The post string
IOException
- If an I/O error occurredpublic StringBuilder fetchPage(String page, String[] images, String postRequest) throws IOException
fetchPage
in class HttpTransport
page
- The page URLimages
- The image or other resource URLs to fetch with pagepostRequest
- The post string
IOException
- If an I/O error occurredpublic int getContentSize()
getContentSize
in class HttpTransport
public StringBuilder fetchResponseData(InputStream stream) throws IOException
fetchResponseData
in class HttpTransport
stream
- The stream to read from
IOException
public StringBuilder fetchResponseData(Reader reader) throws IOException
fetchResponseData
in class HttpTransport
reader
- The reader to read from
IOException
public boolean matchResponse(String regex)
matchResponse
in class HttpTransport
regex
- The regular expression to match
public boolean matchResponse(InputStream stream, String regex) throws IOException
matchResponse
in class HttpTransport
stream
- The source of the dataregex
- The regular expression to match
IOException
public boolean matchResponse(Reader reader, String regex) throws IOException
matchResponse
in class HttpTransport
reader
- The source of the dataregex
- The regular expression to match
IOException
public boolean matchURL(String url, String regex) throws IOException
matchURL
in class HttpTransport
url
- The source of the dataregex
- THe regular expression to match
IOException
public boolean matchURL(String url, String regex, Map<String,String> headers) throws IOException
matchURL
in class HttpTransport
url
- The source of the dataregex
- The regular expression to matchheaders
- The request headers
IOException
public boolean matchURL(URL url, String regex) throws IOException
matchURL
in class HttpTransport
url
- The source of the dataregex
- The regular expression to match
IOException
public boolean matchURL(URL url, String regex, Map<String,String> headers) throws IOException
matchURL
in class HttpTransport
url
- The source of the dataregex
- The regular expression to matchheaders
- The request headers
IOException
public boolean matchURL(URL url, String postRequest, String regex) throws IOException
matchURL
in class HttpTransport
url
- The source of the datapostRequest
- The post request stringregex
- The regular expression to match
IOException
public boolean matchURL(URL url, String postRequest, String regex, Map<String,String> headers) throws IOException
matchURL
in class HttpTransport
url
- The source of the datapostRequest
- The post request stringregex
- The regular expression to matchheaders
- The request headers
IOException
public boolean matchURL(String url, String postRequest, String regex) throws IOException
matchURL
in class HttpTransport
url
- The source of the datapostRequest
- The post request stringregex
- The regular expression to match
IOException
public boolean matchURL(String url, String postRequest, String regex, Map<String,String> headers) throws IOException
matchURL
in class HttpTransport
url
- The source of the datapostRequest
- The post request stringregex
- The regular expression to matchheaders
- The request headers
IOException
public boolean matchURL(String url, List<org.apache.commons.httpclient.methods.multipart.Part> parts, String regex, Map<String,String> headers) throws IOException
url
- The URL to read fromparts
- The parts listregex
- The regular expression to matchheaders
- The request headers
IOException
public boolean matchURL(URL url, List<org.apache.commons.httpclient.methods.multipart.Part> parts, String regex) throws IOException
url
- The URL to read fromparts
- The parts listregex
- The regular expression to match
IOException
public boolean matchURL(String url, List<org.apache.commons.httpclient.methods.multipart.Part> parts, String regex) throws IOException
url
- The URL to read fromparts
- The parts listregex
- The regular expression to match
IOException
public boolean matchURL(URL url, List<org.apache.commons.httpclient.methods.multipart.Part> parts, String regex, Map<String,String> headers) throws IOException
url
- The URL to read fromparts
- The parts listregex
- The regular expression to matchheaders
- The request headers
IOException
public String[] getCookieValuesByName(String name)
getCookieValuesByName
in class HttpTransport
name
- The cookie name
public String[] getResponseHeader(String name)
getResponseHeader
in class HttpTransport
name
- The response header field of interest
public String dumpResponseHeaders()
dumpResponseHeaders
in class HttpTransport
public int getResponseCode()
getResponseCode
in class HttpTransport
public void closeConnections()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |