public class ApacheHC3Transport extends HttpTransport
BUFFER_SIZE
Constructor and Description |
---|
ApacheHC3Transport()
Constructs a new ApacheHC3Transport object.
|
Modifier and Type | Method and Description |
---|---|
void |
addTextType(String texttype)
Add a MIME type to the list of text types.
|
void |
closeConnections()
Close all connections currently not in use.
|
StringBuilder |
deleteURL(String url)
Makes a DELETE request to the URL.
|
StringBuilder |
deleteURL(String url,
Map<String,String> headers)
Makes a DELETE request to the URL.
|
StringBuilder |
deleteURL(URL url)
Makes a DELETE request to the URL.
|
StringBuilder |
deleteURL(URL url,
Map<String,String> headers)
Makes a DELETE request to the URL.
|
byte[] |
downloadURL(String url)
Retrieve large response from the URL and returns the data read.
|
byte[] |
downloadURL(String url,
Map<String,String> headers)
Retrieve large response from the URL and returns the data read.
|
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.
|
org.apache.commons.httpclient.Cookie[] |
getCookies()
Returns all the cookies
|
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.
|
StringBuilder |
optionsURL(String url,
Map<String,String> headers)
Makes a OPTIONS request to the URL.
|
StringBuilder |
optionsURL(URL url) |
StringBuilder |
optionsURL(URL url,
Map<String,String> headers) |
StringBuilder |
putURL(String url,
byte[] buffer)
Makes a PUT request to the URL.
|
StringBuilder |
putURL(String url,
byte[] buffer,
Map<String,String> headers)
Makes a PUT request to the URL.
|
StringBuilder |
putURL(String url,
byte[] buffer,
String contentType)
Makes a PUT request to the URL.
|
StringBuilder |
putURL(String url,
byte[] buffer,
String contentType,
Map<String,String> headers)
Makes a PUT request to the URL.
|
StringBuilder |
putURL(URL url,
byte[] buffer)
Makes a PUT request to the URL.
|
StringBuilder |
putURL(URL url,
byte[] buffer,
Map<String,String> headers)
Makes a PUT request to the URL.
|
StringBuilder |
putURL(URL url,
byte[] buffer,
String contentType)
Makes a PUT request to the URL.
|
StringBuilder |
putURL(URL url,
byte[] buffer,
String contentType,
Map<String,String> headers)
Makes a PUT request 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.
|
newInstance, readURL, setDownloadSpeed, setProvider, setUploadSpeed
public ApacheHC3Transport()
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 headersIOException
public int readURL(URL url) throws IOException
readURL
in class HttpTransport
url
- The URL to read fromIOException
public int readURL(String url, Map<String,String> headers) throws IOException
readURL
in class HttpTransport
url
- The URL to read fromheaders
- The request headersIOException
public int readURL(String url) throws IOException
readURL
in class HttpTransport
url
- The URL to read fromIOException
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 headersIOException
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 headersIOException
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 headersIOException
public int readURL(String url, byte[] postRequest) throws IOException
readURL
in class HttpTransport
url
- The URL to read frompostRequest
- The binary data to sendIOException
public int readURL(String url, String postRequest) throws IOException
readURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request stringIOException
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 headersIOException
public int readURL(URL url, List<org.apache.commons.httpclient.methods.multipart.Part> parts) throws IOException
url
- The URL to read fromparts
- The parts listIOException
public int readURL(String url, List<org.apache.commons.httpclient.methods.multipart.Part> parts) throws IOException
url
- The URL to read fromparts
- The parts listIOException
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 headersIOException
public StringBuilder fetchURL(URL url, Map<String,String> headers) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read fromheaders
- The request headersIOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(URL url) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read fromIOException
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 headersIOException
addTextType(String)
,
getContentSize()
public StringBuilder fetchURL(String url) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read fromIOException
addTextType(String)
,
getContentSize()
public byte[] downloadURL(String url) throws IOException
downloadURL
in class HttpTransport
url
- The URL to read fromIOException
getContentSize()
public byte[] downloadURL(String url, Map<String,String> headers) throws IOException
url
- The URL to read fromheaders
- List of request headersIOException
getContentSize()
public StringBuilder fetchURL(String url, String postRequest) throws IOException
fetchURL
in class HttpTransport
url
- The URL to read frompostRequest
- The post request stringIOException
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 headersIOException
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 headersIOException
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 stringIOException
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 headersIOException
public StringBuilder fetchURL(URL url, List<org.apache.commons.httpclient.methods.multipart.Part> parts) throws IOException
url
- The URL to read fromparts
- The parts listIOException
public StringBuilder fetchURL(String url, List<org.apache.commons.httpclient.methods.multipart.Part> parts) throws IOException
url
- The URL to read fromparts
- The parts listIOException
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 headersIOException
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 stringIOException
- 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 stringIOException
- 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 fromIOException
public StringBuilder fetchResponseData(Reader reader) throws IOException
fetchResponseData
in class HttpTransport
reader
- The reader to read fromIOException
public boolean matchResponse(String regex)
matchResponse
in class HttpTransport
regex
- The regular expression to matchpublic boolean matchResponse(InputStream stream, String regex) throws IOException
matchResponse
in class HttpTransport
stream
- The source of the dataregex
- The regular expression to matchIOException
public boolean matchResponse(Reader reader, String regex) throws IOException
matchResponse
in class HttpTransport
reader
- The source of the dataregex
- The regular expression to matchIOException
public boolean matchURL(String url, String regex) throws IOException
matchURL
in class HttpTransport
url
- The source of the dataregex
- THe regular expression to matchIOException
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 headersIOException
public boolean matchURL(URL url, String regex) throws IOException
matchURL
in class HttpTransport
url
- The source of the dataregex
- The regular expression to matchIOException
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 headersIOException
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 matchIOException
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 headersIOException
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 matchIOException
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 headersIOException
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 headersIOException
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 matchIOException
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 matchIOException
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 headersIOException
public StringBuilder putURL(String url, byte[] buffer, String contentType, Map<String,String> headers) throws IOException
url
- The URL to read frombuffer
- containing the PUT datacontentType
- the content type, or nullheaders
- The request headers, or nullIOException
public StringBuilder putURL(String url, byte[] buffer) throws IOException
url
- The URL to read frombuffer
- containing the PUT dataIOException
public StringBuilder putURL(String url, byte[] buffer, String contentType) throws IOException
url
- The URL to read frombuffer
- containing the PUT datacontentType
- the content type, or nullIOException
public StringBuilder putURL(String url, byte[] buffer, Map<String,String> headers) throws IOException
url
- The URL to read frombuffer
- containing the PUT dataheaders
- The request headers, or nullIOException
public StringBuilder putURL(URL url, byte[] buffer, String contentType, Map<String,String> headers) throws IOException
url
- The URL to read frombuffer
- containing the PUT datacontentType
- the content type, or nullheaders
- The request headers, or nullIOException
public StringBuilder putURL(URL url, byte[] buffer) throws IOException
url
- The URL to read frombuffer
- containing the PUT dataIOException
public StringBuilder putURL(URL url, byte[] buffer, String contentType) throws IOException
url
- The URL to read frombuffer
- containing the PUT datacontentType
- the content type, or nullIOException
public StringBuilder putURL(URL url, byte[] buffer, Map<String,String> headers) throws IOException
url
- The URL to read frombuffer
- containing the PUT dataheaders
- The request headers, or nullIOException
public StringBuilder deleteURL(String url, Map<String,String> headers) throws IOException
url
- The URL to read fromheaders
- The request headers, or nullIOException
public StringBuilder deleteURL(String url) throws IOException
url
- The URL to read fromIOException
public StringBuilder deleteURL(URL url, Map<String,String> headers) throws IOException
url
- The URL to read fromheaders
- The request headers, or nullIOException
public StringBuilder deleteURL(URL url) throws IOException
url
- The URL to read fromIOException
public StringBuilder optionsURL(String url, Map<String,String> headers) throws IOException
url
- The URL to read fromheaders
- The request headers, or nullIOException
public StringBuilder optionsURL(URL url, Map<String,String> headers) throws IOException
IOException
public StringBuilder optionsURL(URL url) throws IOException
IOException
public String[] getCookieValuesByName(String name)
getCookieValuesByName
in class HttpTransport
name
- The cookie namepublic org.apache.commons.httpclient.Cookie[] getCookies()
getCookies
in class HttpTransport
public String[] getResponseHeader(String name)
getResponseHeader
in class HttpTransport
name
- The response header field of interestpublic String dumpResponseHeaders()
dumpResponseHeaders
in class HttpTransport
public int getResponseCode()
getResponseCode
in class HttpTransport
public void closeConnections()