netapp.manage.http
Class HTTPClient

java.lang.Object
  extended bynetapp.manage.http.HTTPClient

public class HTTPClient
extends java.lang.Object

An HTTP client implements the client portion of RFC2616.


Field Summary
static int snoop
          The debug level.
 
Constructor Summary
HTTPClient(boolean ssl, java.net.InetAddress host, int port)
          Constructs a HTTPClient.
HTTPClient(boolean ssl, java.net.InetAddress host, int port, boolean reservedPort)
          Constructs a HTTPClient.
HTTPClient(boolean ssl, java.lang.String host, int port)
          Constructs a HTTPClient.
HTTPClient(boolean ssl, java.lang.String host, int port, boolean reservedPort)
          Constructs a HTTPClient.
 
Method Summary
 void close()
          Close this HTTP client's connections.
 HTTPResponse doRequest(HTTPRequest request)
          Send a HTTPRequest and receive the corresponding HTTPResponse.
 int getUseCount()
          Get the number of requests that have been processed by this HTTPClient.
 boolean isCompatible(boolean ssl, java.net.InetAddress host, int port)
          Test whether this HTTPClient was created with some particular paramters.
 boolean isCompatible(boolean ssl, java.lang.String host, int port)
          Test whether this HTTPClient was created with some particular paramters.
 boolean isTimedOut()
          Test whether the connection has been idle for too long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

snoop

public static int snoop
The debug level. Set this to a positive integer and information about HTTP transactions will be printed to System.err.

Constructor Detail

HTTPClient

public HTTPClient(boolean ssl,
                  java.lang.String host,
                  int port)
           throws java.io.IOException,
                  java.net.UnknownHostException
Constructs a HTTPClient. A single socket connection is made to the HTTP server,

Parameters:
ssl - flag to use HTTPS instead of HTTP.
host - the server hostname.
port - the server TCP port.
Throws:
java.io.IOException - if the connection cannot be established.
java.net.UnknownHostException - if the hostname is not known.

HTTPClient

public HTTPClient(boolean ssl,
                  java.lang.String host,
                  int port,
                  boolean reservedPort)
           throws java.io.IOException,
                  java.net.UnknownHostException
Constructs a HTTPClient. A single socket connection is made to the HTTP server,

Parameters:
ssl - flag to use HTTPS instead of HTTP.
host - the server hostname.
port - the server TCP port.
reservedPort - flag indicating to bind to a reserved port.
Throws:
java.io.IOException - if the connection cannot be established.
java.net.UnknownHostException - if the hostname is not known.

HTTPClient

public HTTPClient(boolean ssl,
                  java.net.InetAddress host,
                  int port)
           throws java.io.IOException
Constructs a HTTPClient. A single socket connection is made to the HTTP server,

Parameters:
ssl - flag to use HTTPS instead of HTTP.
host - the server address.
port - the server TCP port.
Throws:
java.io.IOException - if the connection cannot be established.

HTTPClient

public HTTPClient(boolean ssl,
                  java.net.InetAddress host,
                  int port,
                  boolean reservedPort)
           throws java.io.IOException
Constructs a HTTPClient. A single socket connection is made to the HTTP server,

Parameters:
ssl - flag to use HTTPS instead of HTTP.
host - the server address.
port - the server TCP port.
reservedPort - flag indicating to bind to a reserved port.
Throws:
java.io.IOException - if the connection cannot be established.
Method Detail

close

public void close()
Close this HTTP client's connections. Call this function to free resources after you are done using the HTTPClient.


isCompatible

public boolean isCompatible(boolean ssl,
                            java.lang.String host,
                            int port)
Test whether this HTTPClient was created with some particular paramters.

Parameters:
ssl - flag to use HTTPS instead of HTTP.
host - the server hostname.
port - the server TCP port.
Returns:
true if all the parameters are the same as when the object was created, otherwise false.

isCompatible

public boolean isCompatible(boolean ssl,
                            java.net.InetAddress host,
                            int port)
Test whether this HTTPClient was created with some particular paramters.

Parameters:
ssl - flag to use HTTPS instead of HTTP.
host - the server address.
port - the server TCP port.
Returns:
true if all the parameters are the same as when the object was created, otherwise false.

isTimedOut

public boolean isTimedOut()
Test whether the connection has been idle for too long. A connection that has timed out should be closed and discarded.

Returns:
true if the connection was idle for too long, otherwise false.

getUseCount

public int getUseCount()
Get the number of requests that have been processed by this HTTPClient.

Returns:
number of requests.

doRequest

public HTTPResponse doRequest(HTTPRequest request)
                       throws java.io.IOException,
                              HTTPException
Send a HTTPRequest and receive the corresponding HTTPResponse. This function will automatically set the "Host" header in the request based on the parameters of this HTTPClient.

Parameters:
request - the request to send.
Returns:
the response recieved.
Throws:
java.io.IOException - if there is a communication error.
HTTPException - if there is a HTTP protocol error.