|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.faban.driver.HttpTransport
public class HttpTransport
The HttpTransport provides initialization services and utility methods for using the HTTP and HTTPS protocols. The convention for the method names in this class are as follows:
Constructor Summary | |
---|---|
HttpTransport()
Deprecated. Replaced by the newInstance() method |
Method Summary | |
---|---|
void |
addTextType(String texttype)
Add a MIME type to the list of text types. |
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,
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,
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. |
StringBuilder |
getResponseBuffer()
Obtains the reference of the current response buffer. |
int |
getResponseCode()
Obtains the response code of the last 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,
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)
Mathces the regular expression against the response fetched from the 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. |
static HttpTransport |
newInstance()
Creates an instance of HttpTransport with a fresh state. |
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,
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,
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)
Makes a POST request to the URL. |
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. |
static void |
setProvider(String newProvider)
Sets the provider class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HttpTransport()
Method Detail |
---|
public static void setProvider(String newProvider)
newProvider
- The fully qualified name of the provider classpublic static HttpTransport newInstance()
setProvider(java.lang.String)
public void setFollowRedirects(boolean follow)
follow
- True if HTTP redirects should be automatically followed,
false otherwisepublic void addTextType(String texttype)
texttype
- The content type of a HTTP response that contains text.public boolean isFollowRedirects()
public StringBuilder getResponseBuffer()
public int readURL(URL url, Map<String,String> headers) throws IOException
url
- The URL to read fromheaders
- The request headers
IOException
public int readURL(URL url) throws IOException
url
- The URL to read from
IOException
public int readURL(String url, Map<String,String> headers) throws IOException
url
- The URL to read fromheaders
- The request headers
IOException
public int readURL(String url) throws IOException
url
- The URL to read from
IOException
public int readURL(URL url, String postRequest) throws IOException
url
- The URL to read frompostRequest
- The post request string
IOException
public int readURL(URL url, String postRequest, Map<String,String> headers) throws IOException
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
url
- The URL to read frompostRequest
- The binary data to sendheaders
- The request headers
IOException
public int readURL(String url, byte[] postRequest) throws IOException
url
- The URL to read frompostRequest
- The binary data to send
IOException
public int readURL(String url, String postRequest) throws IOException
url
- The URL to read frompostRequest
- The post request string
IOException
public int readURL(String url, String postRequest, Map<String,String> headers) throws IOException
url
- The URL to read frompostRequest
- The post request stringheaders
- The request headers
IOException
public StringBuilder fetchURL(URL url, Map<String,String> headers) throws IOException
url
- The URL to read fromheaders
- The request headers
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(URL url) throws IOException
url
- The URL to read from
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url, Map<String,String> headers) throws IOException
url
- The URL to read fromheaders
- The request headers
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url) throws IOException
url
- The URL to read from
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url, String postRequest) throws IOException
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
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
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
url
- The URL to read frompostRequest
- The post request string
IOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(URL page, URL[] images, String postRequest) throws IOException
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
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()
public StringBuilder fetchResponseData(InputStream stream) throws IOException
stream
- The stream to read from
IOException
public StringBuilder fetchResponseData(Reader reader) throws IOException
reader
- The reader to read from
IOException
public boolean matchResponse(String regex)
regex
- The regular expression to match
public boolean matchResponse(InputStream stream, String regex) throws IOException
stream
- The source of the dataregex
- The regular expression to match
IOException
public boolean matchResponse(Reader reader, String regex) throws IOException
reader
- The source of the dataregex
- The regular expression to match
IOException
public boolean matchURL(String url, String regex) throws IOException
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
url
- The source of the dataregex
- The regular expression to matchheaders
- The request headers
IOException
public boolean matchURL(URL url, String regex) throws IOException
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
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
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
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
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
url
- The source of the datapostRequest
- The post request stringregex
- The regular expression to matchheaders
- The request headers
IOException
public String[] getCookieValuesByName(String name)
name
- The cookie name
public String[] getResponseHeader(String name)
name
- The response header field of interest
public String dumpResponseHeaders()
public int getResponseCode()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |