uicc.scws
Interface HttpRequest


public interface HttpRequest

Interface providing the means to analyse the incoming HTTP request. The object implementing the HttpRequest interface is a Temporary Entry Point Object.


Method Summary
 void cancelProcessing()
          This method indicates to the SCWS that the applet does not want to be invoked with any data fragments related to this HTTP request any more.
 short findAndCopyKeywordValue(byte[] headerKeywordName, short nameOffs, short nameLength, byte[] buffer, short bufferOffs, short maxLength)
          Find and copy the value of a header.
 short findAndCopyKeywordValue(short keywordId, byte[] buffer, short bufferOffs, short maxLength)
          Find and copy the value of a header or the value of a keyword/value part of the URI indicated by a keywordId.
 int getContentLength()
          Returns the length of the HTTP request body if this is known from the header field Content-Length.
 short getContentType()
          Returns the content-type keyword of the HTTP request
 short getRequestHttpVersion()
          Returns the version of the HTTP protocol of the current request.
 short getRequestID()
          This method returns a unique identifier (per card session) for the HTTP request object.
 boolean isComplete()
          This method provides information if the HTTP request was completely received.
 boolean isFirst()
          This method provides information if the HTTP request is starting.
 short readContent(int requestOffset, byte[] data, short offset, short len)
          This method copies up to len bytes of the incoming HTTP request body to data.
 short readContentType(byte[] data, short offs, short len)
          Reads the content type given in the HTTP request (e.g.
 

Method Detail

findAndCopyKeywordValue

short findAndCopyKeywordValue(byte[] headerKeywordName,
                              short nameOffs,
                              short nameLength,
                              byte[] buffer,
                              short bufferOffs,
                              short maxLength)
                              throws java.lang.NullPointerException,
                                     java.lang.ArrayIndexOutOfBoundsException
Find and copy the value of a header.

Parameters:
headerKeywordName - buffer that contains the name of the requested header
nameOffs - offset within headerKeywordName
nameLength - length of data within headerKeywordName
buffer - buffer where the value shall be copied
bufferOffs - offset where the value shall be copied
maxLength - maximum length of the value that shall be copied
Returns:
bufferOffs+length of the copied value or KEYWORD_NOT_FOUND in case the keyword is not found
Throws:
java.lang.NullPointerException - if headerKeywordName or buffer is equal to null
java.lang.ArrayIndexOutOfBoundsException - if the copy operation would cause access out of bounds

findAndCopyKeywordValue

short findAndCopyKeywordValue(short keywordId,
                              byte[] buffer,
                              short bufferOffs,
                              short maxLength)
                              throws ScwsException,
                                     java.lang.NullPointerException,
                                     java.lang.ArrayIndexOutOfBoundsException
Find and copy the value of a header or the value of a keyword/value part of the URI indicated by a keywordId. The supported keywords are defined in ScwsConstants Interface.

Parameters:
keywordId - value of the request header name or part of the URI
buffer - buffer where the value shall be copied
bufferOffs - offset where the value shall be copied
maxLength - maximum length of the value that shall be copied
Returns:
bufferOffs+length of the copied value or KEYWORD_NOT_FOUND in case the keyword is not found
Throws:
ScwsException - with reason UNKNOWN_KEYWORD_ID if the keywordId is not recognized
java.lang.NullPointerException - if buffer is equal to null
java.lang.ArrayIndexOutOfBoundsException - if the copy operation would cause access out of bounds
See Also:
ScwsConstants

getContentLength

int getContentLength()
Returns the length of the HTTP request body if this is known from the header field Content-Length. If chunked transfer encoding is used this method shall return -1. Chunked transfer encoding is indicated in the header field Transfer-Encoding according to HTTP V1.1 [RFC2616].

Returns:
content length of the request or -1 if chunked transfer encoding is used

getRequestHttpVersion

short getRequestHttpVersion()
Returns the version of the HTTP protocol of the current request.

Returns:
HTTP version of the request or KEYWORD_NOT_FOUND in case the content type header field is not present, or CONTENT_TYPE_UNKNOWN in case the content type doesn't match one of the possible content type keywords defined in ScwsConstants.

getContentType

short getContentType()
Returns the content-type keyword of the HTTP request

Returns:
the content type of the request.
See Also:
ScwsConstants

readContentType

short readContentType(byte[] data,
                      short offs,
                      short len)
                      throws java.lang.NullPointerException,
                             java.lang.ArrayIndexOutOfBoundsException
Reads the content type given in the HTTP request (e.g. content type: text/html will write text/html into the buffer).

Parameters:
data - buffer to hold the content type from the request.
offs - start in the buffer to hold the content type.
len - maximum length of the content type to be copied
Returns:
offs+length of the copied value.
Throws:
java.lang.NullPointerException - if data is equal to null
java.lang.ArrayIndexOutOfBoundsException - if the read operation would cause access out of bounds

readContent

short readContent(int requestOffset,
                  byte[] data,
                  short offset,
                  short len)
                  throws ScwsException,
                         java.lang.NullPointerException,
                         java.lang.ArrayIndexOutOfBoundsException
This method copies up to len bytes of the incoming HTTP request body to data.

If chunked transfer encoding is not used:
The complete HTTP request body is contained in the HTTP request buffer at the time of invocation of the doXXX() method of the interface ScwsExtension. This method copies len bytes to data starting at requestOffset in the HTTP request buffer. If requestOffset + len exceeds the length of the HTTP request then the ScwsException with reason code UNREACHABLE_OFFSET will be thrown.

If chunked transfer encoding is used or the request does not fit into the HttpRequest buffer:
The HTTP request has (in general) not been completely received by the SCWS at the time of invocation of the doXXX() method of the interface ScwsExtension. This method copies len bytes to data starting at requestOffset in the HTTP request buffer which contains new HTTP request data which were not yet made available to the Applet in any previous invocation of the doXXX() method of the interface ScwsExtension. If there are less than len bytes in the HTTP request buffer then this method will return offset + length of the copied value.

Parameters:
requestOffset - Offset within the HTTP request buffer to start reading the request content. If the entire HTTP request fits into the buffer this is also the absolute offset into the HTTP request, otherwise it is the offset into the current subset of the HTTP request.
data - byte array where request content shall be copied.
offset - offset within buffer.
len - maximum length of the content to be copied.
Returns:
offset+length of the copied value.
Throws:
ScwsException - with reason UNREACHABLE_OFFSET if the requested offset could not be reached.
java.lang.NullPointerException - if data is equal to null
java.lang.ArrayIndexOutOfBoundsException - if the read operation would cause access out of bounds

isComplete

boolean isComplete()
This method provides information if the HTTP request was completely received.

Returns:
true if this fragment is the last fragment of this HTTP request, false if the HTTP request is not yet complete.

isFirst

boolean isFirst()
This method provides information if the HTTP request is starting.

Returns:
true if this fragment is the first fragment of this HTTP request, false otherwise.

getRequestID

short getRequestID()
This method returns a unique identifier (per card session) for the HTTP request object. This allows the application to distinguish between different requests when it is processing them concurrently.

Returns:
unique identifier for this HTTP request object

cancelProcessing

void cancelProcessing()
This method indicates to the SCWS that the applet does not want to be invoked with any data fragments related to this HTTP request any more.