issrg.utils.webdav
Class HTTPMessage

java.lang.Object
  extended by issrg.utils.webdav.HTTPMessage
Direct Known Subclasses:
COPY, DELETE, GET, HEAD, LOCK, MKCOL, MOVE, OPTIONS, PROPFIND, PROPPATCH, PUT, UNLOCK

public abstract class HTTPMessage
extends java.lang.Object

The HTTPMessage abstract class is the super class for creating implementations of HTTP methods. It provides all the necessary methods to send a request message, receive the response message and extract the entity body for manipulation as the developer sees fit. It contains various public static Strings which are useful in other classes. It uses the WebDAVSocket interface to communicate with the server, the actual implementation of the Socket does not matter to this class i.e. it does not care whether the line of communication is secure or not, that is for the developer to decide.

Version:
19/03/2007
Author:
Sean Antony

Field Summary
static java.lang.String CRLF
           
static java.lang.String EMPTY
           
static java.lang.String FS
           
protected  java.lang.String host
           
static java.lang.String HTTPVersion
           
static java.lang.String LF
           
protected  java.lang.String method
           
static java.lang.String padSP
           
protected  int port
           
protected  WebDAVSocket socket
           
static java.lang.String SP
           
protected  java.lang.String URI
           
 
Constructor Summary
HTTPMessage(WebDAVSocket socket, java.lang.String host, int port, java.lang.String method, java.lang.String URI)
          The constructor for the HTTPMessage common to all HTTP methods.
 
Method Summary
protected  java.lang.String getRequestMessage()
           
protected  byte[] getRequestMessageByte()
           
 java.lang.String getResponseCode()
          This method returns the status code in the response message.
 int getResponseContentLength()
          This method returns the value in the Content Length HTTP header in the response message.
 java.lang.String getResponseEntity()
           
 byte[] getResponseEntityByte()
           
protected  java.lang.String getResponseMessage()
           
protected  byte[] getResponseMessageByte()
           
 java.lang.String getResponseParagraph()
          This message returns the String in between the HTML p tag in a server response.
 java.lang.String getResponseTitle()
          This message returns the String in between the HTML title tag in a server response.
 boolean isResponseSuccessful()
          This method tells you whether the response message has a status code within the 2xx successful range.
 void transceive()
          Once you have created an instance of a class which extends this class, use this method to send the client request and receive the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FS

public static final java.lang.String FS
See Also:
Constant Field Values

SP

public static final java.lang.String SP
See Also:
Constant Field Values

padSP

public static final java.lang.String padSP
See Also:
Constant Field Values

EMPTY

public static final java.lang.String EMPTY
See Also:
Constant Field Values

HTTPVersion

public static final java.lang.String HTTPVersion
See Also:
Constant Field Values

LF

public static final java.lang.String LF
See Also:
Constant Field Values

CRLF

public static final java.lang.String CRLF
See Also:
Constant Field Values

host

protected final java.lang.String host

port

protected final int port

socket

protected final WebDAVSocket socket

method

protected final java.lang.String method

URI

protected final java.lang.String URI
Constructor Detail

HTTPMessage

public HTTPMessage(WebDAVSocket socket,
                   java.lang.String host,
                   int port,
                   java.lang.String method,
                   java.lang.String URI)
The constructor for the HTTPMessage common to all HTTP methods.

Parameters:
socket - any class that implements the WebDAVSocket interface
host - e.g. the IP address (127.0.0.1) or FQDN (mysite.org)
port - e.g. 80 for HTTP and 443 for HTTPS
method - e.g. GET or MKCOL
URI - e.g. the root of the server will be /
Method Detail

transceive

public void transceive()
                throws HTTPMessageException
Once you have created an instance of a class which extends this class, use this method to send the client request and receive the response.

Throws:
HTTPMessageException - on I/O or Unknown Host error.

getResponseParagraph

public java.lang.String getResponseParagraph()
This message returns the String in between the HTML p tag in a server response.

Returns:
paragraph

getResponseTitle

public java.lang.String getResponseTitle()
This message returns the String in between the HTML title tag in a server response.

Returns:
title

getResponseContentLength

public int getResponseContentLength()
This method returns the value in the Content Length HTTP header in the response message.

Returns:
content length

getResponseCode

public java.lang.String getResponseCode()
This method returns the status code in the response message.

Returns:
server status code

isResponseSuccessful

public boolean isResponseSuccessful()
This method tells you whether the response message has a status code within the 2xx successful range.

Returns:
true if status code is within 2xx range

getResponseEntity

public java.lang.String getResponseEntity()

getResponseEntityByte

public byte[] getResponseEntityByte()

getResponseMessage

protected java.lang.String getResponseMessage()

getResponseMessageByte

protected byte[] getResponseMessageByte()

getRequestMessage

protected java.lang.String getRequestMessage()

getRequestMessageByte

protected byte[] getRequestMessageByte()