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.net.InetAddress host, int port, boolean reservedPort, int timeOut)
          Constructs a HTTPClient.
HTTPClient(boolean ssl, java.net.InetAddress host, int port, boolean reservedPort, int timeOut, AuthInfo authInfo)
          Constructs a HTTPClient.
HTTPClient(boolean ssl, java.net.InetAddress host, int port, boolean reservedPort, int timeOut, AuthInfo authInfo, boolean useTLS)
          Constructs a HTTPClient.
HTTPClient(boolean ssl, java.net.InetAddress host, int port, boolean reservedPort, int timeOut, AuthInfo authInfo, boolean useTLS, boolean useSSL)
          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.
 void disableTLS()
          Disables TLS protocol for use over HTTPS Transport.
 HTTPResponse doRequest(HTTPRequest request)
          Send a HTTPRequest and receive the corresponding HTTPResponse.
 void enableTLS()
          Enables TLS protocol for use on connection over HTTPS Transport.
 int getUseCount()
          Get the number of requests that have been processed by this HTTPClient.
 boolean isCompatible(boolean ssl, java.net.InetAddress host, int port, AuthInfo authInfo, boolean useTLS)
          Test whether this HTTPClient was created with some particular paramters.
 boolean isCompatible(boolean ssl, java.lang.String host, int port, AuthInfo authInfo)
          Test whether this HTTPClient was created with some particular paramters.
 boolean isTimedOut()
          Test whether the connection has been idle for too long.
 boolean isTLSEnabled()
          Determines whether TLS protocol is enabled for use over HTTPS Transport.
 
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.

HTTPClient

public HTTPClient(boolean ssl,
                  java.net.InetAddress host,
                  int port,
                  boolean reservedPort,
                  int timeOut)
           throws java.io.IOException,
                  java.net.SocketTimeoutException,
                  java.lang.IllegalArgumentException,
                  java.nio.channels.IllegalBlockingModeException
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.
timeOut - the connection timeout value.
reservedPort - flag indicating to bind to a reserved port.
Throws:
java.io.IOException - if the connection cannot be established.
java.net.SocketTimeoutException - if timeout expires before connecting.
java.lang.IllegalArgumentException - if endpoint is null or is a SocketAddress subclass not supported by this socket.
java.nio.channels.IllegalBlockingModeException - if this socket has an associated channel, and the channel is in non-blocking mode.

HTTPClient

public HTTPClient(boolean ssl,
                  java.net.InetAddress host,
                  int port,
                  boolean reservedPort,
                  int timeOut,
                  AuthInfo authInfo)
           throws java.io.IOException,
                  java.net.SocketTimeoutException,
                  java.lang.IllegalArgumentException,
                  java.nio.channels.IllegalBlockingModeException
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.
timeOut - the connection timeout value.
authInfo - certificate bsed authentication info structure.
Throws:
java.io.IOException - if the connection cannot be established.
java.net.SocketTimeoutException - if timeout expires before connecting.
java.lang.IllegalArgumentException - if endpoint is null or is a SocketAddress subclass not supported by this socket.
java.nio.channels.IllegalBlockingModeException - if this socket has an associated channel, and the channel is in non-blocking mode.

HTTPClient

public HTTPClient(boolean ssl,
                  java.net.InetAddress host,
                  int port,
                  boolean reservedPort,
                  int timeOut,
                  AuthInfo authInfo,
                  boolean useTLS)
           throws java.io.IOException,
                  java.net.SocketTimeoutException,
                  java.lang.IllegalArgumentException,
                  java.nio.channels.IllegalBlockingModeException
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.
timeOut - the connection timeout value.
authInfo - certificate bsed authentication info structure.
useTLS - flag to enable TLS protocol during SSL communication.
Throws:
java.io.IOException - if the connection cannot be established.
java.net.SocketTimeoutException - if timeout expires before connecting.
java.lang.IllegalArgumentException - if endpoint is null or is a SocketAddress subclass not supported by this socket.
java.nio.channels.IllegalBlockingModeException - if this socket has an associated channel, and the channel is in non-blocking mode.

HTTPClient

public HTTPClient(boolean ssl,
                  java.net.InetAddress host,
                  int port,
                  boolean reservedPort,
                  int timeOut,
                  AuthInfo authInfo,
                  boolean useTLS,
                  boolean useSSL)
           throws java.io.IOException,
                  java.net.SocketTimeoutException,
                  java.lang.IllegalArgumentException,
                  java.nio.channels.IllegalBlockingModeException
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.
timeOut - the connection timeout value.
authInfo - certificate bsed authentication info structure.
useTLS - flag to enable TLS protocol during SSL communication.
useSSL - flag to enable SSLv3 protocol during SSL communication.
Throws:
java.io.IOException - if the connection cannot be established.
java.net.SocketTimeoutException - if timeout expires before connecting.
java.lang.IllegalArgumentException - if endpoint is null or is a SocketAddress subclass not supported by this socket.
java.nio.channels.IllegalBlockingModeException - if this socket has an associated channel, and the channel is in non-blocking mode.
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,
                            AuthInfo authInfo)
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.
authInfo - certificate bsed authentication info structure.
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,
                            AuthInfo authInfo,
                            boolean useTLS)
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.
authInfo - certificate bsed authentication info structure.
useTLS - flag to enable TLS protocol during SSL communication.
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.

enableTLS

public void enableTLS()
Enables TLS protocol for use on connection over HTTPS Transport. By default, TLS protocol is enabled.


disableTLS

public void disableTLS()
Disables TLS protocol for use over HTTPS Transport. By default, TLS protocol is enabled.


isTLSEnabled

public boolean isTLSEnabled()
Determines whether TLS protocol is enabled for use over HTTPS Transport.


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.