com.ibm.etill.framework.io
Class HTTPInputStream
java.lang.Object
|
+--com.ibm.etill.framework.io.HTTPInputStream
- All Implemented Interfaces:
- HTTPConst
- public final class HTTPInputStream
- extends Object
- implements HTTPConst
This class defines a HTTP InputStream. It reads data from an Input stream,
looks for the HTTP banner, processes it to extract the response code and
the response message if there is one. It can be extended in the future.
An HTTP banner looks like: "HTTP/1.x 2XX " and this HTTPInput
Stream looks just for that line.
This implementation is based on the SET Advantis payment gateway book.
HOW TO USE IT
- connect this class to a TimeOutInputStream (done in the constructor)
- call readHTTP() to process the stream. If the TimeOutStream doesn't
contain any HTTP banner an exception is thrown.
- if the TimeOutInputStream does contain a HTTP banner the getters
getXxxx() can be called to retrieved the values of the fields.
Fields inherited from interface com.ibm.etill.framework.io.HTTPConst |
ACCEPT_ALL, ACCEPT_BITMAP, ACCEPT_GIF, ACCEPT_JPEG, ACCEPT_PJPEG, CA_AGENT, HTTP_ACCEPT, HTTP_CONNECTION, HTTP_EOL, HTTP_USER_AGENT, HTTP_VERSION, KEEP_ALIVE, MAX_SIZE_HTTPHEADER, POST, RC_BAD_REQUEST, RC_FORBIDDEN, RC_INTERNAL_SERVER_ERROR, RC_NOT_IMPLEMENTED, RC_OK, RC_SERVICE_UNAVAILABLE, RC_UNAUTHORIZED, RC_WRONG, RCS_BAD_REQUEST, RCS_FORBIDDEN, RCS_INTERNAL_SERVER_ERROR, RCS_NOT_IMPLEMENTED, RCS_OK, RCS_SERVICE_UNAVAILABLE, RCS_UNAUTHORIZED, responseCodeTable, UNKNOWN |
HTTPInputStream
public HTTPInputStream(TimeOutInputStream tois)
- Creates a new HTTP input stream to read data from the specified
TimeOut input stream.
- Parameters:
tois
- the TimeOut input stream
readResponse
public void readResponse()
throws IOException
- This method reads and parses a HTTP Request Message using a
TimeOutInputStream. This method must be called before any other method of
this class because it reads the input Stream, processes it and fills in the fields.
An IOException is thrown if no HTTP banner (or what could be interpreted
as an HTTP banner) is found before MAX_SIZE_HTTPHEADER bytes are read.
readRequest
public void readRequest()
throws IOException
- This method reads and parses a HTTP Request Message using a
TimeOutInputStream. This method must be called before any other method of
this class because it reads the input Stream, processes it and fills in the fields.
An IOException is thrown if no HTTP banner (or what could be interpreted
as an HTTP banner) is found before MAX_SIZE_HTTPHEADER bytes are read.
getContentType
public String getContentType()
- getContentType()
- Returns:
- The HTTP Content-Type
getContentLength
public int getContentLength()
- getContentLength()
- Returns:
- The HTTP Content-Length
getRequestMethod
public String getRequestMethod()
- getRequestMethod()
- Returns:
- The HTTP Request Method name
getRequestURI
public String getRequestURI()
- getRequestURI()
- Returns:
- The HTTP Request Method name
getResponseCode
public int getResponseCode()
- Returns the Response code (numeric value) found after calling
the readHTTP() method. If there is no response code, RC_WRONG is
returned instead.
For the SET Advantis payment gateway the possible response codes are
defined in HTTPConst.java.
- Returns:
- The Response Code
getResponseMessage
public String getResponseMessage()
- Returns the Response message found after calling
the readHTTP() method.
- Returns:
- The Response Code
getAdvantisResponseCodeMessage
public String getAdvantisResponseCodeMessage(int responseCode)
- Returns a message associated to a valid SET Advantis payment gateway
Response code.
The possible response codes and corresponding messages are defined
in HTTPConst.java
- Returns:
- The Response Code