com.ibm.cics.server
Class HttpClientResponse

java.lang.Object
  extended bycom.ibm.cics.server.HttpClientResponse

public class HttpClientResponse
extends java.lang.Object

Usage:
This class provides the Java implementation of HTTP client response related to the following CICS API commands:

The setter methods allow instance variables to be set in the HttpClientResponse object. These variables relate to the following options on the CICS API command WEB RECEIVE SESSTOKEN:

By default MAXLENGTH is set to 32K and NOTRUNCATE is not set. These values can be overriden by the setters.

Method getContent() will receive the servers response body. This is equivalent to CICS API command WEB RECEIVE SESSTOKEN INTO.

Depending on the size of the body sent by the server and the MAXLENGTH value the complete body may not be received. Method isBodyComplete() returns boolean true if the whole body was returned by the getContent() method. If the whole body was not returned by getContent() then isBodyTruncated() returns boolean true unless setNoTruncate() was used to specify NOTRUNCATE. If NOTRUNCATE was specified and the complete body was not returned by getContent() then isBodyPartial() returns boolean true and getContent() can be used to obtain the next portion of the body.

Getters getStatusCode(), getStatusText(), getCharacterset() and getMediaType will return the STATUSCODE, STATUSTEXT, CHARACTERSET and MEDIATYPE of the servers response. These getters will only return information if the getContent() method has already been issued to obtain the body or part of the body.

Method getHeader() will return the contents of the required HTTP header, this is equivalent to CICS API command WEB READ SESSTOKEN.

Method startBrowseHeader() will start the browse of the HTTP headers, this is equivalent to CICS API command WEB STARTBROWSE SESSTOKEN.

Method getNextHeader() will return the next HTTP header name-value pair, this is equivalent to CICS API command WEB READNEXT SESSTOKEN.

Method endBrowseHeader() will terminate the browse of the HTTP headers, this is equivalent to CICS API command WEB ENDBROWSE SESSTOKEN.


Field Summary
static int NOTSET
           
 
Constructor Summary
HttpClientResponse()
          Usage:
Public default constructor.
 
Method Summary
 void endBrowseHeader(HttpSession session)
          Usage:
Signal the end of the HTTP header browse.
 java.lang.String getCharacterset()
          Usage:
Returns the characterset of the servers response.
 byte[] getContent(HttpSession session)
          Usage:
Returns the body of the servers response.
 java.lang.String getHeader(HttpSession session, java.lang.String header)
          Usage:
Returns the contents of a HTTP header.
 java.lang.String getMediaType()
          Usage:
Returns the mediatype of the servers response.
 HttpHeader getNextHeader(HttpSession session)
          Usage:
Returns the next HTTP header name-value pair to be browsed.
 int getStatusCode()
          Usage:
Returns the status code of the servers response.
 java.lang.String getStatusText()
          Usage:
Returns the status text of the servers response.
 boolean isBodyComplete()
          Usage:
Returns a boolean which indicates whether the body returned by getContent() was completely returned.
 boolean isBodyPartial()
          Usage:
Returns a boolean which indicates whether body returned by getContent() was a partial body or not.
 boolean isBodyTruncated()
          Usage:
Returns a boolean which indicates whether the body returned by getContent() was truncated or not.
 void setClientConvert()
          Usage:
Sets WEB RECEIVE SESSTOKEN command option CLIENTCONV to CLICONVERT.
 void setMaxLength(int maxLength)
          Usage:
Sets WEB RECEIVE SESSTOKEN command option MAXLENGTH.
 void setNoClientConvert()
          Usage:
Sets WEB RECEIVE SESSTOKEN command option CLIENTCONV to NOCLICONVERT.
 void setNoTruncate()
          Usage:
Sets WEB RECEIVE SESSTOKEN command option NOTRUNCATE.
 void setTruncate()
          Usage:
Resets WEB RECEIVE SESSTOKEN command option NOTRUNCATE.
 void startBrowseHeader(HttpSession session)
          Usage:
Signal the start of a browse of the HTTP headers from the first name-value pair.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTSET

public static final int NOTSET
See Also:
Constant Field Values
Constructor Detail

HttpClientResponse

public HttpClientResponse()
Usage:
Public default constructor.

Throws:
None
Method Detail

setClientConvert

public void setClientConvert()
Usage:
Sets WEB RECEIVE SESSTOKEN command option CLIENTCONV to CLICONVERT.

Returns:
None
Throws:
None

setNoClientConvert

public void setNoClientConvert()
Usage:
Sets WEB RECEIVE SESSTOKEN command option CLIENTCONV to NOCLICONVERT.

Returns:
None
Throws:
None

setNoTruncate

public void setNoTruncate()
Usage:
Sets WEB RECEIVE SESSTOKEN command option NOTRUNCATE.

Returns:
None
Throws:
None

setTruncate

public void setTruncate()
Usage:
Resets WEB RECEIVE SESSTOKEN command option NOTRUNCATE.

Returns:
None
Throws:
None

setMaxLength

public void setMaxLength(int maxLength)
                  throws LengthErrorException
Usage:
Sets WEB RECEIVE SESSTOKEN command option MAXLENGTH.

Parameters:
maxLength - contains the maximum length value
Returns:
None
Throws:
LengthErrorException - if maxlength is less than 1

getContent

public byte[] getContent(HttpSession session)
                  throws InvalidRequestException,
                         IOErrorException,
                         NotOpenException,
                         TimedOutException
Usage:
Returns the body of the servers response. This is equivalent to CICS API command WEB RECEIVE SESSTOKEN INTO.

Parameters:
session - is the HttpSession object associated with the RECEIVE.
Returns:
The body of the server response
Throws:
InvalidRequestException - a INVREQ condition occurred
IOErrorException - a IOERR condition occurred
NotOpenException - a NOTOPEN condition occurred
TimedOutException - a TIMEDOUT condition occurred

getStatusCode

public int getStatusCode()
                  throws InvalidRequestException
Usage:
Returns the status code of the servers response. This is equivalent to CICS API command WEB RECEIVE SESSTOKEN STATUSCODE. Method getContent() must have been used to receive the body or part of the body before this method is used, otherwise an InvalidRequestException will be throw.

Returns:
The servers response status code
Throws:
InvalidRequestException - if getContent() not issued before this method

getStatusText

public java.lang.String getStatusText()
                               throws InvalidRequestException
Usage:
Returns the status text of the servers response. This is equivalent to CICS API command WEB RECEIVE SESSTOKEN STATUSTEXT. Method getContent() must have been used to receive the body or part of the body before this method is used, otherwise an InvalidRequestException will be throw.

Returns:
The servers response status text
Throws:
InvalidRequestException - if getContent() not issued before this method

getMediaType

public java.lang.String getMediaType()
                              throws InvalidRequestException
Usage:
Returns the mediatype of the servers response. This is equivalent to CICS API command WEB RECEIVE SESSTOKEN MEDIATYPE. Method getContent() must have been used to receive the body or part of the body before this method is used, otherwise an InvalidRequestException will be throw.

Returns:
The servers response mediatype
Throws:
InvalidRequestException - if getContent() not issued before this method

getCharacterset

public java.lang.String getCharacterset()
                                 throws InvalidRequestException
Usage:
Returns the characterset of the servers response. This is equivalent to CICS API command WEB RECEIVE SESSTOKEN CHARACTERSET. Method getContent() must have been used to receive the body or part of the body before this method is used, otherwise an InvalidRequestException will be throw.

Returns:
The servers response characterset
Throws:
InvalidRequestException - if getContent() not issued before this method

isBodyComplete

public boolean isBodyComplete()
Usage:
Returns a boolean which indicates whether the body returned by getContent() was completely returned. If more than one getContent() used to return the body then the isBodyComplete() will indicate when the last portion of the body has been returned.

Returns:
True if complete body returned by getContent() or this is last portion of body returned by getContent()
Throws:
None

isBodyTruncated

public boolean isBodyTruncated()
Usage:
Returns a boolean which indicates whether the body returned by getContent() was truncated or not.

Returns:
True if truncated body returned by getContent()
Throws:
None

isBodyPartial

public boolean isBodyPartial()
Usage:
Returns a boolean which indicates whether body returned by getContent() was a partial body or not. If true getContent() can be used to receive the next portion of the body.

Returns:
True if partial body returned by getContent()
Throws:
None

getHeader

public java.lang.String getHeader(HttpSession session,
                                  java.lang.String header)
                           throws InvalidRequestException,
                                  NotOpenException
Usage:
Returns the contents of a HTTP header. If the requsted header is not found a null string is returned. This is equivalent to CICS API command WEB READ HTTPHEADER SESSTOKEN.

Parameters:
session - is the HttpSession object associated with the READ
header - contains the name of the HTTP header
Returns:
The named HTTP header value
Throws:
InvalidRequestException - a INVREQ condition occurred
NotOpenException - a NOTOPEN condition occurred

startBrowseHeader

public void startBrowseHeader(HttpSession session)
                       throws InvalidRequestException,
                              NotOpenException,
                              LogicException
Usage:
Signal the start of a browse of the HTTP headers from the first name-value pair. This is equivalent to CICS API command WEB STARTBROWSE HTTPHEADER SESSTOKEN.

Parameters:
session - is the HttpSession object associated with the BROWSE
Returns:
None
Throws:
InvalidRequestException - a INVREQ condition occurred
NotOpenException - a NOTOPEN condition occurred
LogicException - a ILLOGIC condition occurred

getNextHeader

public HttpHeader getNextHeader(HttpSession session)
                         throws LogicException,
                                NotOpenException,
                                EndOfFileException
Usage:
Returns the next HTTP header name-value pair to be browsed. This is equivalent to CICS API command WEB READNEXT HTTPHEADER SESSTOKEN.

Parameters:
session - is the HttpSession object associated with the BROWSE
Returns:
The next HTTP header name-value pair
Throws:
LogicException - a ILLOGIC condition occurred
NotOpenException - a NOTOPEN condition occurred
EndOfFileException - a ENDFILE condition occurred

endBrowseHeader

public void endBrowseHeader(HttpSession session)
                     throws LogicException,
                            NotOpenException
Usage:
Signal the end of the HTTP header browse. This is equivalent to CICS API command WEB ENDBROWSE HTTPHEADER SESSTOKEN.

Parameters:
session - is the HttpSession object associated with the BROWSE
Returns:
None
Throws:
LogicException - a ILLOGIC condition occurred
NotOpenException - a NOTOPEN condition occurred