uicc.scws
Interface HttpResponse


public interface HttpResponse

Interface providing the means to build a HTTP response. The object implementing the HttpResponse interface is a Temporary Entry Point Object.


Method Summary
 void appendContent(byte[] data, short offset, short length)
          Writes the content of data into the response object.
 void appendHeaderVariable(byte[] data, short offset, short length)
          Writes a header variable to outgoing buffer (e.g.
 void appendHeaderVariable(byte[] name, short nameOffset, short nameLength, byte[] value, short valueOffset, short valueLength)
          Appends a header variable to outgoing buffer (e.g.
 void appendHeaderVariable(short headerKeywordNameId, byte[] value, short valueOffset, short valueLength)
          Appends a header variable to the outgoing buffer (e.g.
 void enableChunkMode()
          Informs the SCWS to use the chunked mode for sending the response, chunked mode off is the default mode
 void finalizeHeader()
          Finalizes the header data in the outgoing buffer.
 void flush()
          Sends all data contained in the HTTP response.
 int getRemainingResponseBufferSize()
          Returns the remaining size of the Response Buffer available for this applet.
 void reset()
          Clears the Response Buffer content and reset the state of the HttpResponse Object to its initial state.
 void sendError(short errorCode)
          Sends an error code to the SCWS.
 void setContentType(short type)
          Sets the content type of the HTTP response
 void writeStatusCode(short code)
          Write an HTTP status code into the outgoing buffer (e.g.
 

Method Detail

finalizeHeader

void finalizeHeader()
                    throws ScwsException
Finalizes the header data in the outgoing buffer. It automatically adds missing header data with default values by the SCWS.

Throws:
ScwsException - with reason codes:
  • HEADER_ALREADY_FINALIZED if the HTTP header was already finalized.
  • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously
  • BUFFER_OVERFLOW if the adding of missing header data would cause access outside the Response buffer.

appendHeaderVariable

void appendHeaderVariable(byte[] name,
                          short nameOffset,
                          short nameLength,
                          byte[] value,
                          short valueOffset,
                          short valueLength)
                          throws ScwsException,
                                 java.lang.NullPointerException,
                                 java.lang.ArrayIndexOutOfBoundsException
Appends a header variable to outgoing buffer (e.g. "content-type: text/html"). The colon and space (":") as well as the "CRLF" will be appended automatically.

The header variables content-length or transfer-encoding are inserted by the framework depending on the transfer mode

Parameters:
name - buffer containing the header name (for example "content-type")
nameOffset - offset within name buffer
nameLength - length of the value within name buffer
value - buffer containing the header value (for example "text/html")
valueOffset - offset within value buffer
valueLength - length of the value within value buffer
Throws:
java.lang.NullPointerException - if name or value is equal to null
java.lang.ArrayIndexOutOfBoundsException - if the operation would cause access outside array bounds
ScwsException - with reason codes:
  • HEADER_ALREADY_FINALIZED if the HTTP header was already finalized.
  • BUFFER_OVERFLOW If appending the header variable would cause an overflow of the response buffer.
  • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously

appendHeaderVariable

void appendHeaderVariable(short headerKeywordNameId,
                          byte[] value,
                          short valueOffset,
                          short valueLength)
                          throws ScwsException,
                                 java.lang.NullPointerException,
                                 java.lang.ArrayIndexOutOfBoundsException
Appends a header variable to the outgoing buffer (e.g. "content-type:text/html"). The colon and space (":") as well as the "CRLF" will be appended automatically.

The header variables content-length or transfer-encoding are inserted by the framework depending on the transfer mode

Parameters:
headerKeywordNameId - Identifier of the required header name.
value - buffer containing the header value (for example "text/html").
valueOffset - offset within value buffer.
valueLength - length of the value within value buffer.
Throws:
java.lang.NullPointerException - if value is equal to null
java.lang.ArrayIndexOutOfBoundsException - if the operation would cause access outside array bounds
ScwsException - with reason codes:
  • HEADER_ALREADY_FINALIZED if the HTTP header was already finalized.
  • UNKNOWN_KEYWORD_ID if the headerKeywordNameId is not correct according to SCWSConstants
  • BUFFER_OVERFLOW If appending the header variable would cause an overflow of the response buffer.
  • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously

appendHeaderVariable

void appendHeaderVariable(byte[] data,
                          short offset,
                          short length)
                          throws ScwsException,
                                 java.lang.NullPointerException,
                                 java.lang.ArrayIndexOutOfBoundsException
Writes a header variable to outgoing buffer (e.g. "content-type: text/html") "CRLF" will be appended automatically.

The header variables content-length or transfer-encoding are inserted by the framework depending on the transfer mode

Parameters:
data - buffer holding the header variable
offset - start offset of the header variable in the data buffer
length - the length of the header variable in the buffer
Throws:
java.lang.NullPointerException - if data is equal to null
java.lang.ArrayIndexOutOfBoundsException - if the operation would cause access outside array bounds
ScwsException - with reason codes:
  • HEADER_ALREADY_FINALIZED if the HTTP header was already finalized.
  • BUFFER_OVERFLOW If appending the header variable would cause an overflow of the response buffer.
  • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously

appendContent

void appendContent(byte[] data,
                   short offset,
                   short length)
                   throws ScwsException,
                          java.lang.NullPointerException,
                          java.lang.ArrayIndexOutOfBoundsException
Writes the content of data into the response object.

Invoking this method implicitly finalizes the header of the HttpResponse. In case of chunked transfer encoding hex length of chunked data is automatically added by the framework.

Parameters:
data - buffer holding the content of the response
offset - start offset of the content in the data buffer
length - the length of the content in the buffer
Throws:
java.lang.NullPointerException - if data is equal to null.
java.lang.ArrayIndexOutOfBoundsException - if the operation would cause access outside array bounds
ScwsException - with reason codes:
  • BUFFER_OVERFLOW If appending the content would cause an overflow of the response buffer.
  • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously

writeStatusCode

void writeStatusCode(short code)
                     throws ScwsException
Write an HTTP status code into the outgoing buffer (e.g. 200)

Parameters:
code - status code of the HTTP 1.1 protocol
Throws:
ScwsException - with reason code
  • HEADER_ALREADY_FINALIZEDif the HTTP header was already finalized
  • STATUS_LINE_ALREADY_SET if the writeStatusCode or the appendHeaderVariable has already been invoked
  • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously
  • HTTP_CODE_UNKNOWN if the status code is unknown with respect to the HTTP 1.1 protocol

flush

void flush()
Sends all data contained in the HTTP response. If this method is invoked in fixed buffer mode after a previous invocation of the same method or the sendError() message was invoked previously the SCWS will do nothing.

Invoking this method for the first time implicitly finalizes the header of the HttpResponse.

Throws:
ScwsException - with reason codes:
  • BUFFER_OVERFLOW if the adding of missing header data would cause access outside the Response buffer.

sendError

void sendError(short errorCode)
Sends an error code to the SCWS. The HTTP response is sent immediately by the SCWS no other data is send by the SCWS. Missing header variables are added by the SCWS with their default values.

Invoking this method implicitly finalizes the header of the HttpResponse.

Parameters:
errorCode - The error code to be sent in the HTTP Response. //@exception ScwsException with reason code //
  • HTTP_CODE_UNKNOWN if the error code is unknown with respect to the HTTP // 1.1 protocol
    Throws:
    ScwsException - with reason codes:
    • HTTP_CODE_UNKNOWN if the error code is unknown with respect to the HTTP 1.1 protocol
    • HEADER_ALREADY_FINALIZED if the HTTP header was already finalized.
    • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously

  • getRemainingResponseBufferSize

    int getRemainingResponseBufferSize()
    Returns the remaining size of the Response Buffer available for this applet.

    The size returned by this method is guaranteed until the next header data or content data is added to the Response Buffer.

    Returns:
    The remaining size of the Buffer, or -1 if chunked mode is switched on
    Throws:
    ScwsException - with reason codes:
    • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously and the selected transfer mode is Fixed transfer mode

    enableChunkMode

    void enableChunkMode()
    Informs the SCWS to use the chunked mode for sending the response, chunked mode off is the default mode

    This allows the SCWS to handle large ammounts of response data

    Throws:
    ScwsException - with reason codes:
    • HEADER_ALREADY_FINALIZED if the HTTP header was already finalized.
    • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously

    setContentType

    void setContentType(short type)
                        throws ScwsException
    Sets the content type of the HTTP response

    Parameters:
    type - the content-type keyword ID of the response
    Throws:
    ScwsException - with reason codes:
    • UNKNOWN_KEYWORD_ID if type is unknown.
    • HEADER_ALREADY_FINALIZED if the HTTP header was already finalized.
    • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously.
      • BUFFER_OVERFLOW if the adding of header data would cause access outside the Response buffer.

    reset

    void reset()
               throws ScwsException
    Clears the Response Buffer content and reset the state of the HttpResponse Object to its initial state. All the header variables and content that was appended to the HttpResponse until the invocation of the reset method is lost.

    Throws:
    ScwsException - with reason codes:
    • HTTP_RESPONSE_ALREADY_SENT if the flush or sendError method was called previously or the method enableChunkMode was already invoked.