public class HttpConnection
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_TIMEOUT
The default timeout value used for the http connection and read timeout values.
|
| Constructor and Description |
|---|
HttpConnection()
The default constructor.
|
HttpConnection(int ConnectionTimeout,
int ReadTimeout)
Creates a new HttpConnection object with the specified connect and read timeout
values.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
get(java.net.HttpURLConnection con)
Gets data at a specified HttpURLConnection.
|
int |
getConnectTimeout() |
int |
getReadTimeout() |
byte[] |
post(java.net.HttpURLConnection con,
byte[] data)
Posts data to the given HttpURLConnection and retrieve a response.
|
void |
setConnectTimeout(int milliseconds)
Sets the connect timeout for connecting to the HTTP resource
in milliseconds.
|
void |
setReadTimeout(int milliseconds)
Set the timeout for reading data from the connection in
milliseconds.
|
public static final int DEFAULT_TIMEOUT
public HttpConnection()
public HttpConnection(int ConnectionTimeout,
int ReadTimeout)
Under a Java 1.5.x or later environment, the Connection Timeout and Read Timeout values will be set through the HttpURLConnection object.
It is recommended that this value be set to an appropriate timeout value.
ConnectionTimeout - ReadTimeout - public byte[] post(java.net.HttpURLConnection con,
byte[] data)
throws java.io.IOException
Under a Java 1.4.x environment a separate thread is created so that a specified connection timeout can be used. The ConnectTimeout is the maximum length of time in milliseconds which the Java toolkit will allow for connecting to the OCSP responder.
Under a Java 1.5.x or later environment, the Connection Timeout (as well as the Read Timeout values) will be set through the HttpURLConnection object.
It is recommended that this value be set to an appropriate timeout value.
All associated parameters that should be used by the underlying HttpURLConnection object should already be set before calling this method. For example, when an OCSP request is sent, the following sequence of commands is already set before calling this method:
con = (HttpURLConnection)m_responderUrl.openConnection();
con.setRequestProperty("Content-Type", "application/ocsp-request");
con.setRequestProperty("Accept", "application/ocsp-response");
con.setDoOutput(true);
con - The HttpURLConnection object. All associateddata - The data to be postedjava.lang.InterruptedExceptionjava.io.IOExceptionpublic byte[] get(java.net.HttpURLConnection con)
throws java.io.IOException
Under a Java 1.4.x environment, a separate thread is created so that a specified connection timeout can be used. The ConnectTimeout is the maximum length of time in milliseconds which the Java toolkit will allow for connecting to the OCSP responder.
Under a Java 1.5.x or later environment, the Connection Timeout (as well as the Read Timeout values) will be set through the HttpURLConnection object.
It is recommended that this value be set to an appropriate timeout value.
All associated parameters that should be used by the underlying HttpURLConnection object should already be set before calling this method. For example, when getting an X509Certificate from a specified URL location, the following sequence of commands is already set before calling this method:
con = (HttpURLConnection)Url.openConnection();
con.setRequestProperty("accept", "application/pkix-cert, application/pkcs7-mime, application/octet-stream, text/plain, text/html, text/*, application/*");
con.setUseCaches(false);
con - The HttpURLConnection object. All associated parameters should already be set and
the openConnection() method should already be called.java.lang.InterruptedExceptionjava.io.IOExceptionpublic void setReadTimeout(int milliseconds)
milliseconds - public int getReadTimeout()
public void setConnectTimeout(int milliseconds)
milliseconds - public int getConnectTimeout()