anon.infoservice
Class HttpResponseStructure

java.lang.Object
  extended by anon.infoservice.HttpResponseStructure

public final class HttpResponseStructure
extends java.lang.Object

This class stores the HTTP response for the requests which reaches the InfoService. Every response will have an HTTP header, which prevents proxies to store the response in their cache.


Field Summary
static java.lang.String HTML_BAD_REQUEST
           
static java.lang.String HTML_INTERNAL_SERVER_ERROR
           
static java.lang.String HTML_NOT_FOUND
           
static java.lang.String HTTP_11_STRING
           
static java.lang.String HTTP_CRLF_STRING
           
static int HTTP_ENCODING_GZIP
           
static java.lang.String HTTP_ENCODING_GZIP_STRING
           
static int HTTP_ENCODING_PLAIN
           
static int HTTP_ENCODING_ZLIB
           
static java.lang.String HTTP_ENCODING_ZLIB_STRING
           
static java.lang.String HTTP_HEADER_CACHE_CONTROL_STRING
           
static java.lang.String HTTP_HEADER_CACHE_CONTROL_STRINGS
           
static java.lang.String HTTP_HEADER_DATE_STRING
           
static java.lang.String HTTP_HEADER_ENCODING_STRING
           
static java.lang.String HTTP_HEADER_EXPIRES_STRING
           
static java.lang.String HTTP_HEADER_LENGTH_STRING
           
static java.lang.String HTTP_HEADER_PRAGMA_STRING
           
static java.lang.String HTTP_HEADER_TYPE_STRING
           
static int HTTP_RETURN_ACCEPTED
           
static java.lang.String HTTP_RETURN_ACCEPTED_STRING
           
static int HTTP_RETURN_BAD_REQUEST
          This constant is used, when HTTP BAD REQUEST (400) shall be returned.
static java.lang.String HTTP_RETURN_BAD_REQUEST_STRING
           
static int HTTP_RETURN_INTERNAL_SERVER_ERROR
          This constant is used, when HTTP INTERNAL SERVER ERROR (500) shall be returned.
static java.lang.String HTTP_RETURN_INTERNAL_SERVER_ERROR_STRING
           
static int HTTP_RETURN_NOT_FOUND
          This constant is used, when HTTP NOT FOUND (404) shall be returned.
static java.lang.String HTTP_RETURN_NOT_FOUND_STRING
           
static int HTTP_RETURN_OK
          This constant is used, when HTTP OK (200) shall be returned.
static java.lang.String HTTP_RETURN_OK_STRING
           
static int HTTP_TYPE_APPLICATION_JNLP
          This constant is used, when the content part is a JNLP file.
static java.lang.String HTTP_TYPE_APPLICATION_JNLP_STRING
           
static int HTTP_TYPE_NO_TYPE
          This constant is used, when no content type shall be specified in the HTTP header.
static int HTTP_TYPE_TEXT_HTML
          This constant is used, when the content part is in the HTML format.
static java.lang.String HTTP_TYPE_TEXT_HTML_STRING
           
static int HTTP_TYPE_TEXT_PLAIN
          This constant is used, when the content part is plain text.
static java.lang.String HTTP_TYPE_TEXT_PLAIN_STRING
           
static int HTTP_TYPE_TEXT_XML
          This constant is used, when the content part is in the XML format.
static java.lang.String HTTP_TYPE_TEXT_XML_STRING
           
private  byte[] m_httpReturnData
          Stores the whole HTTP response, including HTTP code, header and data.
 
Constructor Summary
HttpResponseStructure(org.w3c.dom.Document a_xmlDocument)
          Creates a new HTTP response with HTTP return code OK (200) and the specified XML data in the content part.
HttpResponseStructure(org.w3c.dom.Document a_xmlDocument, int a_supportedEncodings)
          Creates a new HTTP response with HTTP return code OK (200) and the specified XML data in the content part.
HttpResponseStructure(int a_returnCode)
          Creates a new HTTP response, which only consists of the return code specified and sometimes a describing HTML message.
HttpResponseStructure(int a_httpDataType, int a_httpEncoding, byte[] a_httpData)
          Creates a new HTTP response with HTTP return code OK (200) and the content type and content data specified.
HttpResponseStructure(int a_httpDataType, int a_httpEncoding, java.lang.String a_httpData)
          Creates a new HTTP response with HTTP return code OK (200) and the content type and content data specified.
HttpResponseStructure(int a_httpDataType, int a_httpEncoding, java.lang.String a_httpData, boolean a_onlyHeader)
          Creates a new HTTP response with HTTP return code OK (200) and the content type and content data specified.
HttpResponseStructure(int httpReturnCode, java.lang.String httpData)
           
 
Method Summary
private  byte[] createHttpMessage(int a_httpReturnCode, int a_httpDataType, int a_httpEncoding, byte[] a_httpData, boolean a_onlyHeader)
          Creates the whole HTTP response, including HTTP return code, HTTP header and the specified content.
private  byte[] createHttpMessage(int a_httpReturnCode, int a_httpDataType, int a_httpEncoding, byte[] a_httpData, boolean a_onlyHeader, java.text.DateFormat dateFormat)
          Creates the whole HTTP response, including HTTP return code, HTTP header and the specified content.
 byte[] getResponseData()
          Returns the data of this HTTP response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_RETURN_OK

public static final int HTTP_RETURN_OK
This constant is used, when HTTP OK (200) shall be returned.

See Also:
Constant Field Values

HTTP_RETURN_ACCEPTED

public static final int HTTP_RETURN_ACCEPTED
See Also:
Constant Field Values

HTTP_RETURN_BAD_REQUEST

public static final int HTTP_RETURN_BAD_REQUEST
This constant is used, when HTTP BAD REQUEST (400) shall be returned.

See Also:
Constant Field Values

HTTP_RETURN_NOT_FOUND

public static final int HTTP_RETURN_NOT_FOUND
This constant is used, when HTTP NOT FOUND (404) shall be returned.

See Also:
Constant Field Values

HTTP_RETURN_INTERNAL_SERVER_ERROR

public static final int HTTP_RETURN_INTERNAL_SERVER_ERROR
This constant is used, when HTTP INTERNAL SERVER ERROR (500) shall be returned.

See Also:
Constant Field Values

HTTP_TYPE_TEXT_PLAIN

public static final int HTTP_TYPE_TEXT_PLAIN
This constant is used, when the content part is plain text.

See Also:
Constant Field Values

HTTP_TYPE_TEXT_HTML

public static final int HTTP_TYPE_TEXT_HTML
This constant is used, when the content part is in the HTML format.

See Also:
Constant Field Values

HTTP_TYPE_TEXT_XML

public static final int HTTP_TYPE_TEXT_XML
This constant is used, when the content part is in the XML format.

See Also:
Constant Field Values

HTTP_TYPE_APPLICATION_JNLP

public static final int HTTP_TYPE_APPLICATION_JNLP
This constant is used, when the content part is a JNLP file.

See Also:
Constant Field Values

HTTP_ENCODING_PLAIN

public static final int HTTP_ENCODING_PLAIN
See Also:
Constant Field Values

HTTP_ENCODING_ZLIB

public static final int HTTP_ENCODING_ZLIB
See Also:
Constant Field Values

HTTP_ENCODING_GZIP

public static final int HTTP_ENCODING_GZIP
See Also:
Constant Field Values

HTTP_TYPE_NO_TYPE

public static final int HTTP_TYPE_NO_TYPE
This constant is used, when no content type shall be specified in the HTTP header. This is only for internal use.

See Also:
Constant Field Values

HTTP_11_STRING

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

HTTP_CRLF_STRING

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

HTTP_RETURN_OK_STRING

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

HTTP_RETURN_ACCEPTED_STRING

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

HTTP_RETURN_BAD_REQUEST_STRING

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

HTTP_RETURN_NOT_FOUND_STRING

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

HTTP_RETURN_INTERNAL_SERVER_ERROR_STRING

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

HTTP_HEADER_TYPE_STRING

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

HTTP_HEADER_ENCODING_STRING

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

HTTP_HEADER_LENGTH_STRING

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

HTTP_HEADER_DATE_STRING

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

HTTP_HEADER_EXPIRES_STRING

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

HTTP_HEADER_CACHE_CONTROL_STRING

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

HTTP_HEADER_PRAGMA_STRING

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

HTTP_HEADER_CACHE_CONTROL_STRINGS

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

HTTP_ENCODING_ZLIB_STRING

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

HTTP_ENCODING_GZIP_STRING

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

HTTP_TYPE_APPLICATION_JNLP_STRING

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

HTTP_TYPE_TEXT_PLAIN_STRING

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

HTTP_TYPE_TEXT_HTML_STRING

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

HTTP_TYPE_TEXT_XML_STRING

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

HTML_NOT_FOUND

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

HTML_BAD_REQUEST

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

HTML_INTERNAL_SERVER_ERROR

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

m_httpReturnData

private byte[] m_httpReturnData
Stores the whole HTTP response, including HTTP code, header and data.

Constructor Detail

HttpResponseStructure

public HttpResponseStructure(int a_returnCode)
Creates a new HTTP response, which only consists of the return code specified and sometimes a describing HTML message.


HttpResponseStructure

public HttpResponseStructure(org.w3c.dom.Document a_xmlDocument)
Creates a new HTTP response with HTTP return code OK (200) and the specified XML data in the content part.

Parameters:
a_xmlDocument - The XML data for the body of the HTTP response.

HttpResponseStructure

public HttpResponseStructure(org.w3c.dom.Document a_xmlDocument,
                             int a_supportedEncodings)
Creates a new HTTP response with HTTP return code OK (200) and the specified XML data in the content part.

Parameters:
a_xmlDocument - The XML data for the body of the HTTP response.

HttpResponseStructure

public HttpResponseStructure(int a_httpDataType,
                             int a_httpEncoding,
                             java.lang.String a_httpData)
Creates a new HTTP response with HTTP return code OK (200) and the content type and content data specified.

Parameters:
a_httpDataType - The content type of the data, see the HTTP_TYPE constants in this class.
a_httpData - The content data for the HTTP response.

HttpResponseStructure

public HttpResponseStructure(int a_httpDataType,
                             int a_httpEncoding,
                             byte[] a_httpData)
Creates a new HTTP response with HTTP return code OK (200) and the content type and content data specified.

Parameters:
a_httpDataType - The content type of the data, see the HTTP_TYPE constants in this class.
a_httpData - The content data for the HTTP response.

HttpResponseStructure

public HttpResponseStructure(int a_httpDataType,
                             int a_httpEncoding,
                             java.lang.String a_httpData,
                             boolean a_onlyHeader)
Creates a new HTTP response with HTTP return code OK (200) and the content type and content data specified. It is possible to include only the HTTP header (needed as response to the HTTP HEAD command) for the specified data in the response, but not the data itself.

Parameters:
a_httpDataType - The content type of the data, see the HTTP_TYPE constants in this class.
a_httpData - The content data for the HTTP response.
a_onlyHeader - If this is true, only the matching HTTP header (including content type and content length) is included in the response, but not the data itself. It is needed as response for the HTTP HEAD command. If this parameter is set to false, the full response including header and data is created.

HttpResponseStructure

public HttpResponseStructure(int httpReturnCode,
                             java.lang.String httpData)
Method Detail

getResponseData

public byte[] getResponseData()
Returns the data of this HTTP response.

Returns:
The HTTP response data stored in this instance.

createHttpMessage

private byte[] createHttpMessage(int a_httpReturnCode,
                                 int a_httpDataType,
                                 int a_httpEncoding,
                                 byte[] a_httpData,
                                 boolean a_onlyHeader)
Creates the whole HTTP response, including HTTP return code, HTTP header and the specified content.

Parameters:
a_httpReturnCode - The HTTP return code for the response, see the HTTP_RETURN constants in this class.
a_httpDataType - The content type, which shall be set in the HTTP header of the response. See the HTTP_TYPE constants in this class. If HTTP_TYPE_NO_TYPE is specified here, the content type will not be set in the HTTP header.
a_httpData - The content for the HTTP response. The data should be in the specified content type. If null is specified here, no content will be in the HTTP response (response will consist of HTTP return code and header only) and the content lenght field in the header is not set. In any other case, the content length will be the length of this data structure.
a_onlyHeader - If this is true, only the matching HTTP header (including content type and content length, if available) is included in the response, but not the content data itself. It is needed as response for the HTTP HEAD command. If this parameter is set to false, the full response including header and data is created.
Returns:
The created HTTP response.

createHttpMessage

private byte[] createHttpMessage(int a_httpReturnCode,
                                 int a_httpDataType,
                                 int a_httpEncoding,
                                 byte[] a_httpData,
                                 boolean a_onlyHeader,
                                 java.text.DateFormat dateFormat)
Creates the whole HTTP response, including HTTP return code, HTTP header and the specified content.

Parameters:
a_httpReturnCode - The HTTP return code for the response, see the HTTP_RETURN constants in this class.
a_httpDataType - The content type, which shall be set in the HTTP header of the response. See the HTTP_TYPE constants in this class. If HTTP_TYPE_NO_TYPE is specified here, the content type will not be set in the HTTP header.
a_httpData - The content for the HTTP response. The data should be in the specified content type. If null is specified here, no content will be in the HTTP response (response will consist of HTTP return code and header only) and the content lenght field in the header is not set. In any other case, the content length will be the length of this data structure.
a_onlyHeader - If this is true, only the matching HTTP header (including content type and content length, if available) is included in the response, but not the content data itself. It is needed as response for the HTTP HEAD command. If this parameter is set to false, the full response including header and data is created.
dateFormat - The DatFormatfor headers that contains the actual date. if null is specified the default format "EEE, dd MMM yyyy HH:mm:ss zzz" is used.
Returns:
The created HTTP response.