public class HttpClientResponse extends API
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 overridden 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.
The HTTP body can also be received into a named container by method getContentAsContainer(). If the HTTP body is received into a named container any instance variables set by the setter methods are ignored.
Getters getStatusCode(), getStatusText(), getBodyCharset() and getMediaType() will return the STATUSCODE, STATUSTEXT, the HTTP BODYCHARSET and MEDIATYPE of the servers response. These getters will only return information if the getContent() method or getContentAsContainer() 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.
com.ibm.cics.server.API
for general restrictions on using the JCICS API.
Modifier and Type | Field and Description |
---|---|
static int |
NOTSET
Constant for an unset status code
|
Constructor and Description |
---|
HttpClientResponse()
Usage:
Public default constructor. |
Modifier and Type | Method and Description |
---|---|
void |
endBrowseHeader(HttpSession session)
Usage:
Signal the end of the HTTP header browse. |
java.lang.String |
getBodyCharset()
Usage:
Returns the HTTP body character-set of the servers response. |
java.lang.String |
getCharacterset()
Usage:
Returns the HTTP body character-set of the servers response. |
java.lang.String |
getCharactersetTrim()
Usage:
Returns the HTTP body character-set of the servers response. |
byte[] |
getContent(HttpSession session)
Usage:
Returns the body of the servers response. |
Container |
getContentAsContainer(HttpSession session,
java.lang.String toContainer)
Usage:
Stores the body of the HTTP response in a named container. |
Container |
getContentAsContainer(HttpSession session,
java.lang.String toContainer,
java.lang.String toChannel)
Usage:
Stores the body of the HTTP response in a named container. |
java.lang.String |
getContentAsString(HttpSession session)
Usage:
Returns the body of the servers response in String format. |
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. |
java.lang.String |
getMediaTypeTrim()
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. |
public static final int NOTSET
public HttpClientResponse()
public void setClientConvert()
public void setNoClientConvert()
public void setNoTruncate()
public void setTruncate()
public void setMaxLength(int maxLength) throws LengthErrorException
maxLength
- contains the maximum length valueLengthErrorException
- if maxLength is less than 1public byte[] getContent(HttpSession session) throws InvalidRequestException, IOErrorException, NotOpenException, TimedOutException
session
- is the HttpSession object associated with the RECEIVE.InvalidRequestException
- a INVREQ condition occurredIOErrorException
- a IOERR condition occurredNotOpenException
- a NOTOPEN condition occurredTimedOutException
- a TIMEDOUT condition occurredpublic java.lang.String getContentAsString(HttpSession session) throws InvalidRequestException, IOErrorException, NotOpenException, TimedOutException
session
- is the HttpSession object associated with the RECEIVE.InvalidRequestException
- a INVREQ condition occurredIOErrorException
- a IOERR condition occurredNotOpenException
- a NOTOPEN condition occurredTimedOutException
- a TIMEDOUT condition occurredpublic Container getContentAsContainer(HttpSession session, java.lang.String toContainer, java.lang.String toChannel) throws InvalidRequestException, IOErrorException, NotOpenException, TimedOutException, ChannelErrorException, ContainerErrorException
session
- is the HttpSesion object.toContainer
- is the name if the container into which the HTTP body is to be storedtoChannel
- is the channel that owns the containerInvalidRequestException
- a INVREQ condition occurredIOErrorException
- a IOERR condition occurredNotOpenException
- a NOTOPEN condition occurredTimedOutException
- a TIMEDOUT condition occurredChannelErrorException
- a CHANNELERR condition occurredContainerErrorException
- a CONTAINERERR condition occurredpublic Container getContentAsContainer(HttpSession session, java.lang.String toContainer) throws InvalidRequestException, IOErrorException, NotOpenException, TimedOutException, ChannelErrorException, ContainerErrorException
session
- is the HttpSesion object.toContainer
- is the name if the container into which the HTTP body is to be storedInvalidRequestException
- a INVREQ condition occurredIOErrorException
- a IOERR condition occurredNotOpenException
- a NOTOPEN condition occurredTimedOutException
- a TIMEDOUT condition occurredChannelErrorException
- a CHANNELERR condition occurredContainerErrorException
- a CONTAINERERR condition occurredpublic int getStatusCode() throws InvalidRequestException
InvalidRequestException
- if getContent() or getContentAsContainer() not issued before this methodpublic java.lang.String getStatusText() throws InvalidRequestException
InvalidRequestException
- if getContent() or getContentAsContainer() not issued before this methodpublic java.lang.String getMediaType() throws InvalidRequestException
InvalidRequestException
- if getContent() or getCotentAsContainer() not issued before this methodpublic java.lang.String getMediaTypeTrim() throws InvalidRequestException
InvalidRequestException
- if getContent() or getCotentAsContainer() not issued before this methodpublic java.lang.String getCharacterset() throws InvalidRequestException
InvalidRequestException
- if getContent() or getContentAsContainer() not issued before this methodpublic java.lang.String getCharactersetTrim() throws InvalidRequestException
InvalidRequestException
- if getContent() or getContentAsContainer() not issued before this methodpublic java.lang.String getBodyCharset() throws InvalidRequestException
InvalidRequestException
- if getContent() or getContentAsContainer() not issued before this methodpublic boolean isBodyComplete()
public boolean isBodyTruncated()
public boolean isBodyPartial()
public java.lang.String getHeader(HttpSession session, java.lang.String header) throws InvalidRequestException, NotOpenException
session
- is the HttpSession object associated with the READheader
- contains the name of the HTTP headerInvalidRequestException
- a INVREQ condition occurredNotOpenException
- a NOTOPEN condition occurredpublic void startBrowseHeader(HttpSession session) throws InvalidRequestException, NotOpenException, LogicException
session
- is the HttpSession object associated with the BROWSEInvalidRequestException
- a INVREQ condition occurredNotOpenException
- a NOTOPEN condition occurredLogicException
- a ILLOGIC condition occurredpublic HttpHeader getNextHeader(HttpSession session) throws LogicException, NotOpenException, EndOfFileException
session
- is the HttpSession object associated with the BROWSELogicException
- a ILLOGIC condition occurredNotOpenException
- a NOTOPEN condition occurredEndOfFileException
- a ENDFILE condition occurredpublic void endBrowseHeader(HttpSession session) throws LogicException, NotOpenException
session
- is the HttpSession object associated with the BROWSELogicException
- a ILLOGIC condition occurredNotOpenException
- a NOTOPEN condition occurred