com.sun.slamd.http
Class HTTPClient

java.lang.Object
  extended by com.sun.slamd.http.HTTPClient

public class HTTPClient
extends java.lang.Object

This class defines a client that may be used for communicating with Web servers using HTTP or HTTPS. It offers a number of features for behaving like actual Web browsers, including the ability to parse the contents of an HTML document, the ability to include images when retrieving a page, and the ability to operate through a proxy server.

Author:
Neil A. Wilson

Field Summary
static java.lang.String AUTH_HEADER_PREFIX
          The prefix that will be used for the HTTP header that sends authentication information to the remote Web server.
static int BUFFER_SIZE
          The size of the buffer that we will use for reading data.
static java.lang.String PROXY_AUTH_HEADER_PREFIX
          The prefix that will be used for the HTTP header that sends authentication information to the proxy server.
static java.lang.String STAT_TRACKER_REDIRECTS_FOLLOWED
          The display name for the stat tracker used to keep track of the number of redirects followed.
static java.lang.String STAT_TRACKER_REQUESTS_PROCESSED
          The display name for the stat tracker used to keep track of the total number of requests processed.
static java.lang.String STAT_TRACKER_RESPONSE_BODY_TIME
          The display name for the stat tracker used to keep track of the length of time required to retrieve the body of the response.
static java.lang.String STAT_TRACKER_RESPONSE_CODES
          The display name for the stat tracker used to keep track of the response codes from all the requests.
static java.lang.String STAT_TRACKER_RESPONSE_HEADER_TIME
          The display name for the stat tracker used to keep track of the length of time required to retrieve send the request and retrieve the header.
static java.lang.String STAT_TRACKER_RESPONSE_SIZE
          The display name for the stat tracker used to keep track of the size in bytes of the response.
static java.lang.String STAT_TRACKER_TOTAL_REQUEST_TIME
          The display name for the stat tracker used to keep track of the total length of time required to handle a request.
 
Constructor Summary
HTTPClient()
          Creates a new instance of this HTTP client.
 
Method Summary
 void addCookie(HTTPCookie cookie)
          Adds the specified cookie to the set of cookies associated with this client.
 boolean authenticationEnabled()
          Indicates whether the client will attempt to provide authentication information to the remote HTTP server.
 void clearCommonHeaders()
          Removes all common headers that have been defined for this client.
 void clearCookies()
          Clears all cookie information associated with this client.
 void closeAll()
          Closes all open connections that are associated with this HTTP client.
 boolean cookiesEnabled()
          Indicates whether support for cookies is enabled in this client.
 void debug(java.lang.String message)
          Writes the provided message to the debug writer.
 boolean deleteLogoutCookies()
          Indicates whether this client will automatically delete any cookie whose value is set to "LOGOUT".
 void disableAuthentication()
          Indicates that no authentication should be performed for the remote Web server.
 void disableDebugMode()
          Indicates that this HTTP client should not operate in debug mode.
 void disableProxy()
          Indicates that the client should not use a proxy server but rather try to communicate directly with the remote Web server.
 void disableStatisticsCollection()
          Indicates that the client should not automatically maintain any statistics.
 void enableAuthentication(java.lang.String authID, java.lang.String authPW)
          Indicates that authentication should be performed for the remote Web server using the provided information.
 void enableDebugMode()
          Indicates that this HTTP client should operate in debug mode.
 void enableDebugMode(java.io.PrintStream debugStream)
          Indicates that this HTTP client should operate in debug mode.
 boolean enableGZIP()
          Indicates whether this client should support GZIP-compressed data.
 void enableProxy(java.lang.String proxyHost, int proxyPort)
          Indicates that the client should communicate with the specified proxy server rather than attempting to communicate directly with the remote Web server.
 void enableProxy(java.lang.String proxyHost, int proxyPort, java.lang.String proxyAuthID, java.lang.String proxyAuthPW)
          Indicates that the client should communicate with the specified proxy server rather than attempting to communicate directly with the remote Web server.
 void enableStatisticsCollection(java.lang.String clientID, java.lang.String threadID, int collectionInterval)
          Indicates that the client should automatically maintain a set of stat trackers that keep track of various statistics around HTTP processing.
 void enableStatisticsCollection(java.lang.String clientID, java.lang.String threadID, int collectionInterval, java.lang.String jobID, RealTimeStatReporter statReporter)
          Indicates that the client should automatically maintain a set of stat trackers that keep track of various statistics around HTTP processing.
 boolean followRedirects()
          Indicates whether this client will attempt to automatically follow redirects returned by the server.
 java.lang.String getAuthID()
          Retrieves the username that will be provided to the remote HTTP server if authentication will be performed.
 java.lang.String getAuthPassword()
          Retrieves the password that will be provided to the remote HTTP server if authentication will be performed.
 java.net.InetAddress getClientAddress()
          Retrieves the client address that will be used for the connections created by this HTTP client.
 java.lang.String getCommonHeader(java.lang.String name)
          Retrieves the value of the common header with the provided name.
 java.lang.String[] getCommonHeaderNames()
          Retrieves the names of the common headers that have been defined for this client.
 java.lang.String[][] getCommonHeaders()
          Retrieves a two-dimensional array containing the names and values of all headers that will always be included in requests sent using this client.
 java.lang.String[] getCommonHeaderValues()
          Retrieves the values of the common headers that have been defined for this client.
 HTTPCookie[] getCookies(java.net.URL requestURL)
          Retrieves an array of cookies that apply to the given URL.
 java.lang.String getProxyAuthID()
          Retrieves the username that will be provided to the HTTP proxy server if authentication will be performed.
 java.lang.String getProxyAuthPassword()
          Retrieves the password that will be provided to the HTTP proxy server if authentication will be performed.
 java.lang.String getProxyHost()
          Retrieves the address of the proxy server that has been configured.
 int getProxyPort()
          Retrieves the port number of the proxy server that has been configured.
 int getSocketTimeout()
          Retrieves the maximum length of time in milliseconds that the client should block while waiting for data from the server.
 javax.net.ssl.SSLSocketFactory getSSLSocketFactory()
          Retrieves the socket factory that will be used to create SSL-based connections.
 StatTracker[] getStatTrackers()
          Retrieves the set of stat trackers that have been maintained by this client.
 StatTracker[] getStatTrackerStubs(java.lang.String clientID, java.lang.String threadID, int collectionInterval)
          Retrieves the stat tracker stubs that will be used to indicate the types of statistics that will be collected by this HTTP client.
 void invalidateSSLSessions()
          Invalidates all SSL sessions associated with any connections held by this HTTP client.
static boolean isRedirect(int statusCode)
          Indicates whether the provided status code defines a redirect that may be followed to get the actual content.
 boolean proxyAuthenticationEnabled()
          Indicates whether the client will attempt to authenticate to an HTTP proxy server.
 boolean proxyEnabled()
          Indicates whether the client will attempt to forward requests through an HTTP proxy server.
 void removeCommonHeader(java.lang.String name)
          Removes the common header with the specified name.
 boolean removeCookie(java.lang.String name)
          Removes the cookie with the specified name from the set of cookies for this client.
 boolean removeCookie(java.lang.String name, java.lang.String value)
          Removes the cookie with the specified name and value from the set of cookies for this client.
 boolean retrieveAssociatedFiles()
          Indicates whether this client should automatically retrieve any additional files associated with the HTML documents that are retrieved.
 HTTPResponse sendRequest(HTTPRequest request)
          Sends the provided request to the specified server and returns the response.
 void setClientAddress(java.net.InetAddress clientAddress)
          Specifies the client address that should be used when this HTTP client creates outbound connections.
 void setClientAddress(java.lang.String clientAddress)
          Specifies the client address that should be used when this HTTP client creates outbound connections.
 void setCommonHeader(java.lang.String name, java.lang.String value)
          Adds a common header with the specified name and value.
 void setCookiesEnabled(boolean cookiesEnabled)
          Specifies whether cookie support should be enabled for this client.
 void setDeleteLogoutCookies(boolean deleteLogoutCookies)
          Specifies whether this client will automatically delete any cookie whose value is set to "LOGOUT".
 void setEnableGZIP(boolean enableGZIP)
          Specifies whether this client should support accepting GZIP-compressed data.
 void setFollowRedirects(boolean followRedirects)
          Specifies whether this client should attempt to automatically follow redirects returned by the server.
 void setRetrieveAssociatedFiles(boolean retrieveAssociatedFiles)
          Specifies whether this client should automatically retrieve any additional files (images, external style sheets, frame elements, etc.) associated with any HTML documents that it retrieves.
 void setSocketTimeout(int socketTimeout)
          Specifies the maximum length of time in milliseconds that the client should block while waiting for data from the server.
 void setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
          Specifies the socket factory that should be used to create SSL-based connections.
 void setUseKeepAlive(boolean useKeepAlive)
          Indicates whether to use HTTP 1.1 keepalive to possibly re-use the same connection for multiple requests.
 boolean statisticsCollectionEnabled()
          Indicates whether this HTTP client is currently configured to collect statistics about the operations it performs.
 void stopTrackers()
          Stops all the stat trackers associated with this client but still indicating stat statistics collection has been used so that the statistics will be returned by the getStatTrackers method.
 boolean useKeepAlive()
          Indicates whether this connection will attempt to use HTTP 1.1 keepalive to possibly re-use the same connection for multiple requests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
The size of the buffer that we will use for reading data.

See Also:
Constant Field Values

AUTH_HEADER_PREFIX

public static final java.lang.String AUTH_HEADER_PREFIX
The prefix that will be used for the HTTP header that sends authentication information to the remote Web server.

See Also:
Constant Field Values

PROXY_AUTH_HEADER_PREFIX

public static final java.lang.String PROXY_AUTH_HEADER_PREFIX
The prefix that will be used for the HTTP header that sends authentication information to the proxy server.

See Also:
Constant Field Values

STAT_TRACKER_REDIRECTS_FOLLOWED

public static final java.lang.String STAT_TRACKER_REDIRECTS_FOLLOWED
The display name for the stat tracker used to keep track of the number of redirects followed.

See Also:
Constant Field Values

STAT_TRACKER_REQUESTS_PROCESSED

public static final java.lang.String STAT_TRACKER_REQUESTS_PROCESSED
The display name for the stat tracker used to keep track of the total number of requests processed.

See Also:
Constant Field Values

STAT_TRACKER_RESPONSE_BODY_TIME

public static final java.lang.String STAT_TRACKER_RESPONSE_BODY_TIME
The display name for the stat tracker used to keep track of the length of time required to retrieve the body of the response.

See Also:
Constant Field Values

STAT_TRACKER_RESPONSE_CODES

public static final java.lang.String STAT_TRACKER_RESPONSE_CODES
The display name for the stat tracker used to keep track of the response codes from all the requests.

See Also:
Constant Field Values

STAT_TRACKER_RESPONSE_HEADER_TIME

public static final java.lang.String STAT_TRACKER_RESPONSE_HEADER_TIME
The display name for the stat tracker used to keep track of the length of time required to retrieve send the request and retrieve the header.

See Also:
Constant Field Values

STAT_TRACKER_RESPONSE_SIZE

public static final java.lang.String STAT_TRACKER_RESPONSE_SIZE
The display name for the stat tracker used to keep track of the size in bytes of the response.

See Also:
Constant Field Values

STAT_TRACKER_TOTAL_REQUEST_TIME

public static final java.lang.String STAT_TRACKER_TOTAL_REQUEST_TIME
The display name for the stat tracker used to keep track of the total length of time required to handle a request.

See Also:
Constant Field Values
Constructor Detail

HTTPClient

public HTTPClient()
Creates a new instance of this HTTP client. It will not use a proxy server, it will not perform authentication, and it will not automatically retrieve images when retrieving an HTML document.

Method Detail

enableDebugMode

public void enableDebugMode()
Indicates that this HTTP client should operate in debug mode. Debug messages will be sent to standard error.


enableDebugMode

public void enableDebugMode(java.io.PrintStream debugStream)
Indicates that this HTTP client should operate in debug mode. Debug messages will be sent to the provided print stream.

Parameters:
debugStream - The print stream to which debug messages should be sent.

disableDebugMode

public void disableDebugMode()
Indicates that this HTTP client should not operate in debug mode.


debug

public void debug(java.lang.String message)
Writes the provided message to the debug writer. Note that it is the responsibility of the caller to ensure that debugging is enabled before calling this method.

Parameters:
message - The message to be written.

getClientAddress

public java.net.InetAddress getClientAddress()
Retrieves the client address that will be used for the connections created by this HTTP client.

Returns:
The client address that will be used for the connections created by this HTTP client, or null if the default client address should be used.

setClientAddress

public void setClientAddress(java.net.InetAddress clientAddress)
Specifies the client address that should be used when this HTTP client creates outbound connections.

Parameters:
clientAddress - The client address that should be used when this HTTP client creates outbound connections.

setClientAddress

public void setClientAddress(java.lang.String clientAddress)
                      throws java.net.UnknownHostException
Specifies the client address that should be used when this HTTP client creates outbound connections.

Parameters:
clientAddress - The client address that should be used when this HTTP client creates outbound connections.
Throws:
java.net.UnknownHostException - If the provided address string cannot be resolved to an actual address.

enableGZIP

public boolean enableGZIP()
Indicates whether this client should support GZIP-compressed data.

Returns:
true if this client should support GZIP compression, or false if it should not.

setEnableGZIP

public void setEnableGZIP(boolean enableGZIP)
Specifies whether this client should support accepting GZIP-compressed data.

Parameters:
enableGZIP - Specifies whether this clietn should support accepting GZIP-compressed data.

setSSLSocketFactory

public void setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
Specifies the socket factory that should be used to create SSL-based connections.

Parameters:
sslSocketFactory - The socket factory that should be used to create SSL-based connections.

getSSLSocketFactory

public javax.net.ssl.SSLSocketFactory getSSLSocketFactory()
Retrieves the socket factory that will be used to create SSL-based connections.

Returns:
The socket factory that will be used to create SSL-based connections.

enableProxy

public void enableProxy(java.lang.String proxyHost,
                        int proxyPort)
Indicates that the client should communicate with the specified proxy server rather than attempting to communicate directly with the remote Web server. No authentication will be used when communicating with the proxy server.

Parameters:
proxyHost - The address of the proxy server.
proxyPort - The port of the proxy server.

enableProxy

public void enableProxy(java.lang.String proxyHost,
                        int proxyPort,
                        java.lang.String proxyAuthID,
                        java.lang.String proxyAuthPW)
Indicates that the client should communicate with the specified proxy server rather than attempting to communicate directly with the remote Web server. Basic authentication will be performed using the provided user ID and password.

Parameters:
proxyHost - The address of the proxy server.
proxyPort - The port of the proxy server.
proxyAuthID - The user ID to use to authenticate to the proxy server.
proxyAuthPW - The password to use to authenticate to the proxy server.

disableProxy

public void disableProxy()
Indicates that the client should not use a proxy server but rather try to communicate directly with the remote Web server.


proxyEnabled

public boolean proxyEnabled()
Indicates whether the client will attempt to forward requests through an HTTP proxy server.

Returns:
true if an HTTP proxy server will be used, or false if not.

proxyAuthenticationEnabled

public boolean proxyAuthenticationEnabled()
Indicates whether the client will attempt to authenticate to an HTTP proxy server.

Returns:
true if an HTTP proxy server will be used and authentication information will be provided to it, or false if not.

getProxyHost

public java.lang.String getProxyHost()
Retrieves the address of the proxy server that has been configured.

Returns:
The address of the proxy server that has been configured, or null if none has been specified.

getProxyPort

public int getProxyPort()
Retrieves the port number of the proxy server that has been configured.

Returns:
The port number of the proxy server that has been configured, or -1 if none has been specified.

getProxyAuthID

public java.lang.String getProxyAuthID()
Retrieves the username that will be provided to the HTTP proxy server if authentication will be performed.

Returns:
The username that will be provided to the HTTP proxy server if authentication will be performed, or null if no authentication will be performed.

getProxyAuthPassword

public java.lang.String getProxyAuthPassword()
Retrieves the password that will be provided to the HTTP proxy server if authentication will be performed.

Returns:
The password that will be provided to the HTTP proxy server if authentication will be performed, or null if no authentication will be performed.

enableAuthentication

public void enableAuthentication(java.lang.String authID,
                                 java.lang.String authPW)
Indicates that authentication should be performed for the remote Web server using the provided information.

Parameters:
authID - The user ID to use to authenticate to the remote Web server.
authPW - The password to use to authenticate to the remote Web server.

disableAuthentication

public void disableAuthentication()
Indicates that no authentication should be performed for the remote Web server.


authenticationEnabled

public boolean authenticationEnabled()
Indicates whether the client will attempt to provide authentication information to the remote HTTP server.

Returns:
true if HTTP authentication will be performed, or false if not.

getAuthID

public java.lang.String getAuthID()
Retrieves the username that will be provided to the remote HTTP server if authentication will be performed.

Returns:
The username that will be provided to the remote HTTP server if authentication will be performed, or null if no authentication will be performed.

getAuthPassword

public java.lang.String getAuthPassword()
Retrieves the password that will be provided to the remote HTTP server if authentication will be performed.

Returns:
The password that will be provided to the remote HTTP server if authentication will be performed, or null if no authentication will be performed.

deleteLogoutCookies

public boolean deleteLogoutCookies()
Indicates whether this client will automatically delete any cookie whose value is set to "LOGOUT".

Returns:
true if this client will automatically delete any cookie whose value is set to "LOGOUT", or false if not.

setDeleteLogoutCookies

public void setDeleteLogoutCookies(boolean deleteLogoutCookies)
Specifies whether this client will automatically delete any cookie whose value is set to "LOGOUT".

Parameters:
deleteLogoutCookies - Specifies whether this client will automatically delete any cookie whose value is set to "LOGOUT".

followRedirects

public boolean followRedirects()
Indicates whether this client will attempt to automatically follow redirects returned by the server.

Returns:
true if this client will attempt to follow redirects, or false if not.

setFollowRedirects

public void setFollowRedirects(boolean followRedirects)
Specifies whether this client should attempt to automatically follow redirects returned by the server.

Parameters:
followRedirects - Indicates whether to try to automatically follow redirects returned by the server.

useKeepAlive

public boolean useKeepAlive()
Indicates whether this connection will attempt to use HTTP 1.1 keepalive to possibly re-use the same connection for multiple requests.

Returns:
true if the connection should attempt to use keepalive, or false if not.

setUseKeepAlive

public void setUseKeepAlive(boolean useKeepAlive)
Indicates whether to use HTTP 1.1 keepalive to possibly re-use the same connection for multiple requests.

Parameters:
useKeepAlive - Indicates whether to use HTTP 1.1 keepalive to possibly re-use the same connection for multiple requests.

getSocketTimeout

public int getSocketTimeout()
Retrieves the maximum length of time in milliseconds that the client should block while waiting for data from the server.

Returns:
The maximum length of time in milliseconds that the client should block while waiting for data from the server, or 0 if it should wait indefinitely (until there is data to read).

setSocketTimeout

public void setSocketTimeout(int socketTimeout)
Specifies the maximum length of time in milliseconds that the client should block while waiting for data from the server. A value of zero indicates that there should not be any time limit.

Parameters:
socketTimeout - The maximum length of time in milliseconds that the client should block while waiting for data from the server.

retrieveAssociatedFiles

public boolean retrieveAssociatedFiles()
Indicates whether this client should automatically retrieve any additional files associated with the HTML documents that are retrieved. Note that the contents of those files will not be available to the client calling sendRequest() -- only the contents of the primary document requested.

Returns:
true if this client should automatically retrieve any additional files associated with the HTML documents that are retrieved, or false if not.

setRetrieveAssociatedFiles

public void setRetrieveAssociatedFiles(boolean retrieveAssociatedFiles)
Specifies whether this client should automatically retrieve any additional files (images, external style sheets, frame elements, etc.) associated with any HTML documents that it retrieves.

Parameters:
retrieveAssociatedFiles - Indicates whether this client should automatically retrieve any additional files associated with the HTML documents that are retrieved.

getCommonHeaders

public java.lang.String[][] getCommonHeaders()
Retrieves a two-dimensional array containing the names and values of all headers that will always be included in requests sent using this client.

Returns:
A two-dimensional array containing the names and values of all headers that will always be included in requests sent using this client.

getCommonHeader

public java.lang.String getCommonHeader(java.lang.String name)
Retrieves the value of the common header with the provided name.

Parameters:
name - The name of the common header whose value should be retrieved.
Returns:
The value of the specified common header, or null if no such header has been defined.

getCommonHeaderNames

public java.lang.String[] getCommonHeaderNames()
Retrieves the names of the common headers that have been defined for this client.

Returns:
The names of the common headers that have been defined for this client.

getCommonHeaderValues

public java.lang.String[] getCommonHeaderValues()
Retrieves the values of the common headers that have been defined for this client. The order of the header values will be the same as the order of the names returned by the getCommonHeaderNames() method.

Returns:
The values of the common headers that have been defined for this client.

setCommonHeader

public void setCommonHeader(java.lang.String name,
                            java.lang.String value)
Adds a common header with the specified name and value. If a header already exists with the specified name, then the given value will replace the existing value. If the given value is null, then any existing header with that name will be removed.

Parameters:
name - The name to use for the common header.
value - The value to use for the common header.

removeCommonHeader

public void removeCommonHeader(java.lang.String name)
Removes the common header with the specified name. If no such header is defined for this client, then no action will be performed.

Parameters:
name - The name of the common header to be removed.

clearCommonHeaders

public void clearCommonHeaders()
Removes all common headers that have been defined for this client.


cookiesEnabled

public boolean cookiesEnabled()
Indicates whether support for cookies is enabled in this client.

Returns:
true if support for cookies is enabled, or false if not.

setCookiesEnabled

public void setCookiesEnabled(boolean cookiesEnabled)
Specifies whether cookie support should be enabled for this client.

Parameters:
cookiesEnabled - Indicates whether cookie support should be enabled for this client.

getCookies

public HTTPCookie[] getCookies(java.net.URL requestURL)
Retrieves an array of cookies that apply to the given URL. If there are no applicable cookies, then an empty array will be returned.

Parameters:
requestURL - The URL for which to retrieve the applicable cookies.
Returns:
An array of cookies that apply to the given URL.

addCookie

public void addCookie(HTTPCookie cookie)
Adds the specified cookie to the set of cookies associated with this client. If the cookie information provided matches that of another cookie that already exists, then that cookie will be updated. If the provided cookie has an expiration date in the past, then the specified cookie will be removed.

Parameters:
cookie - The cookie to be added to this client.

removeCookie

public boolean removeCookie(java.lang.String name)
Removes the cookie with the specified name from the set of cookies for this client. If no cookie exists with the given name, then no action will be taken.

Parameters:
name - The name of the cookie to remove.
Returns:
true if the requested cookie was found and removed, or false if it was not.

removeCookie

public boolean removeCookie(java.lang.String name,
                            java.lang.String value)
Removes the cookie with the specified name and value from the set of cookies for this client. If no cookie exists with the given name, or if the specified cookie exists with a different value, then no action will be taken.

Parameters:
name - The name of the cookie to remove.
value - The value for the cookie to remove.
Returns:
true if the requested cookie was found and removed, or false if it was not.

clearCookies

public void clearCookies()
Clears all cookie information associated with this client.


statisticsCollectionEnabled

public boolean statisticsCollectionEnabled()
Indicates whether this HTTP client is currently configured to collect statistics about the operations it performs.

Returns:
true if this HTTP client is configured to collect statistics, or false if it is not.

enableStatisticsCollection

public void enableStatisticsCollection(java.lang.String clientID,
                                       java.lang.String threadID,
                                       int collectionInterval)
Indicates that the client should automatically maintain a set of stat trackers that keep track of various statistics around HTTP processing.

Parameters:
clientID - The client ID to use for the stat trackers.
threadID - The thread ID to use for the stat trackers.
collectionInterval - The statistics collection interval to use for the stat trackers.

enableStatisticsCollection

public void enableStatisticsCollection(java.lang.String clientID,
                                       java.lang.String threadID,
                                       int collectionInterval,
                                       java.lang.String jobID,
                                       RealTimeStatReporter statReporter)
Indicates that the client should automatically maintain a set of stat trackers that keep track of various statistics around HTTP processing.

Parameters:
clientID - The client ID to use for the stat trackers.
threadID - The thread ID to use for the stat trackers.
collectionInterval - The statistics collection interval to use for the stat trackers.
jobID - The job ID of the job with which this client is associated.
statReporter - The real-time stat reporter that should be used for the statistics collected.

stopTrackers

public void stopTrackers()
Stops all the stat trackers associated with this client but still indicating stat statistics collection has been used so that the statistics will be returned by the getStatTrackers method.


disableStatisticsCollection

public void disableStatisticsCollection()
Indicates that the client should not automatically maintain any statistics. Any data that the client might have already collected will be lost.


getStatTrackerStubs

public StatTracker[] getStatTrackerStubs(java.lang.String clientID,
                                         java.lang.String threadID,
                                         int collectionInterval)
Retrieves the stat tracker stubs that will be used to indicate the types of statistics that will be collected by this HTTP client. The stubs will be returned whether or not statistics collection is enabled.

Parameters:
clientID - The client ID to use for the stubs.
threadID - The thread ID to use for the stubs.
collectionInterval - The collection interval to use for the stubs.
Returns:
The requested stat tracker stubs.

getStatTrackers

public StatTracker[] getStatTrackers()
Retrieves the set of stat trackers that have been maintained by this client.

Returns:
The set of stat trackers that have been maintained by this client, or an empty array if statistics collection has not been enabled.

sendRequest

public HTTPResponse sendRequest(HTTPRequest request)
                         throws HTTPException
Sends the provided request to the specified server and returns the response. If so configured, any associated files will also be retrieved.

Parameters:
request - The request to send to the server.
Returns:
The response returned by the server.
Throws:
HTTPException - If a problem occurs while sending the request or reading the response.

isRedirect

public static boolean isRedirect(int statusCode)
Indicates whether the provided status code defines a redirect that may be followed to get the actual content.

Parameters:
statusCode - The HTTP status code for which to make the determination.
Returns:
true if the provided status code will be used for a redirect, or false if not.

closeAll

public void closeAll()
Closes all open connections that are associated with this HTTP client. The client will still be available for use.


invalidateSSLSessions

public void invalidateSSLSessions()
Invalidates all SSL sessions associated with any connections held by this HTTP client. The existing SSL-based connections will still be valid, but any new connections created will be required to complete the full SSL negotiation process.