com.cometway.httpd
Class HTTPCheckKMethod

java.lang.Object
  extended by com.cometway.util.KMethod
      extended by com.cometway.httpd.HTTPCheckKMethod

public class HTTPCheckKMethod
extends KMethod

This KMethod checks a web server by sending it a request for a URL. After the KMethod has been executed, the connection, request, and request latency is recorded in public fields. This method requires a host, port and request. An optional timeout field can be set if needed.


Field Summary
static int CONNECT_ERROR
          A connection error occured
static int CONNECTED
          The connection to the host and port was established
static int CONNECTION_REFUSED
          The connection to the host and port was refused
 int connectionResult
          This is set after the method has been executed and will contain the connection result
 java.lang.String host
           
static int NO_ROUTE_TO_HOST
          No route was available to the host and port
 int port
           
 java.lang.String request
           
static int REQUEST_DENIED
          A request was successful but the server denied access
static int REQUEST_ERROR
          A request error occured after connecting.
static int REQUEST_NOT_FOUND
          A request was successful but the page was not found, this is a 404 HTTP error
static int REQUEST_REDIRECTED
          A request was successful but the server returned a redirect
static int REQUEST_SUCCESSFUL
          A request was successful and a page was returned
static int REQUEST_TIMEOUT
          A request timed out.
static int REQUESTED_EMPTY_PAGE
          A request was successful but an empty page was returned
 long requestLatency
          This is set after the method has been executed and will contain the latency of the request
 java.lang.String requestPage
          This is set after the method has been executed and will contain the page returned from the server
 int requestResult
          This is set after the method has been executed and will contain the request result
 int timeout
          Set this variable if you care about the timeout (in milliseconds), default is 60 seconds
static int UNKNOWN_HOST
          The host was unknown, there was no dns entry for this host
 
Fields inherited from class com.cometway.util.KMethod
args, debugName, method, obj, print_errors, run, verbose
 
Constructor Summary
HTTPCheckKMethod(java.lang.String host, int port, java.lang.String request)
          Sets host, port, and request fields.
 
Method Summary
 void execute()
          Tests website for connection, request, and latency information.
 java.lang.String toString()
          Returns a String containing connection, request, and latency information.
 
Methods inherited from class com.cometway.util.KMethod
error, error, print
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONNECT_ERROR

public static final int CONNECT_ERROR
A connection error occured

See Also:
Constant Field Values

CONNECTION_REFUSED

public static final int CONNECTION_REFUSED
The connection to the host and port was refused

See Also:
Constant Field Values

NO_ROUTE_TO_HOST

public static final int NO_ROUTE_TO_HOST
No route was available to the host and port

See Also:
Constant Field Values

UNKNOWN_HOST

public static final int UNKNOWN_HOST
The host was unknown, there was no dns entry for this host

See Also:
Constant Field Values

CONNECTED

public static final int CONNECTED
The connection to the host and port was established

See Also:
Constant Field Values

REQUEST_ERROR

public static final int REQUEST_ERROR
A request error occured after connecting. An error may have occured on the server

See Also:
Constant Field Values

REQUEST_SUCCESSFUL

public static final int REQUEST_SUCCESSFUL
A request was successful and a page was returned

See Also:
Constant Field Values

REQUEST_TIMEOUT

public static final int REQUEST_TIMEOUT
A request timed out. The server did not respond in time

See Also:
Constant Field Values

REQUESTED_EMPTY_PAGE

public static final int REQUESTED_EMPTY_PAGE
A request was successful but an empty page was returned

See Also:
Constant Field Values

REQUEST_REDIRECTED

public static final int REQUEST_REDIRECTED
A request was successful but the server returned a redirect

See Also:
Constant Field Values

REQUEST_NOT_FOUND

public static final int REQUEST_NOT_FOUND
A request was successful but the page was not found, this is a 404 HTTP error

See Also:
Constant Field Values

REQUEST_DENIED

public static final int REQUEST_DENIED
A request was successful but the server denied access

See Also:
Constant Field Values

connectionResult

public int connectionResult
This is set after the method has been executed and will contain the connection result


requestResult

public int requestResult
This is set after the method has been executed and will contain the request result


requestLatency

public long requestLatency
This is set after the method has been executed and will contain the latency of the request


requestPage

public java.lang.String requestPage
This is set after the method has been executed and will contain the page returned from the server


request

public java.lang.String request

host

public java.lang.String host

port

public int port

timeout

public int timeout
Set this variable if you care about the timeout (in milliseconds), default is 60 seconds

Constructor Detail

HTTPCheckKMethod

public HTTPCheckKMethod(java.lang.String host,
                        int port,
                        java.lang.String request)
Sets host, port, and request fields.

Method Detail

toString

public java.lang.String toString()
Returns a String containing connection, request, and latency information.

Overrides:
toString in class java.lang.Object

execute

public void execute()
Tests website for connection, request, and latency information.

Overrides:
execute in class KMethod