Class HTTPResponseImpl
- All Implemented Interfaces:
Externalizable,Serializable,Runnable,CGIConstants
Server-side Serialization The server (NetFactor method server) constructs response objects to carry response information back to the gateway. The object contains fields to store response header information, an output stream reference, and a target class and method.
Object serialization stores the RMI marshal stream reference in the object and invokes the target method using Java's reflection API. The target method uses methods on the response object to set response attributes (content-type, status, etc.) and eventually calls a method to retrieve the output stream on which to write the response body. This call causes the response attributes to be written to the marshal stream. When the target method returns, serialization is complete.
Client-side Deserialization The client (HTTP gateway) receives the response object as the return value of a RMI call. It is deserialized before the RMI call completes. In order to support processing of streamed data, the deserialization code looks up the corresponding HTTPGateway object and uses it to send the response directly from the deserialization code.
First the headers are set on the real gateway response, then the content body is forwarded by reading blocks of data from the input stream and writing them to real response output stream until the entire body has been sent.
Note: Four response headers are set by default:
Protocol is set to HTTP/1.0;
Status is set to 200 (OK); and
Content-Type is set to text/html.
Expires is set to long ago, the Java epoch - date(0)
If you need to set other headers or change these defaults,
you must do so in your response processing PRIOR to calling
getOutputStream.
Supported API: true
Extendable: false
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the response header is present.Called to get the output stream to write the data to.voidsetDateHeader(String s1, long date) Sets a date type response header.voidSets a string type response header.voidsetIntHeader(String s1, int v1) Sets a int type response header.voidsetStatus(int v1) Sets a simple Status response header.voidSets a Status response header.
-
Method Details
-
getOutputStream
Called to get the output stream to write the data to. It also causes the HTTPResponseHeaders object to be written out to the RMI marshal stream.
Supported API: true- Specified by:
getOutputStreamin classHTTPResponse- Returns:
- OutputStream for writing response body
- Throws:
IOException- if not marshaling response in writeObject. the output stream is null until such time. Also, if the response target class or method is null. There is not a proper business class or method to write the response.
-
containsHeader
Checks if the response header is present.
Supported API: true- Specified by:
containsHeaderin classHTTPResponse- Parameters:
s- String the header to search for.- Returns:
- A boolean if the header is set.
-
setHeader
Sets a string type response header.
Supported API: true- Specified by:
setHeaderin classHTTPResponse- Parameters:
s1- String name of the headers2- String value to which header is set
-
setDateHeader
Sets a date type response header.
Supported API: true- Specified by:
setDateHeaderin classHTTPResponse- Parameters:
s1- String name of the headerdate- long value to which header is set value is milliseconds since the epoch.
-
setIntHeader
Sets a int type response header.
Supported API: true- Specified by:
setIntHeaderin classHTTPResponse- Parameters:
s1- String name of the headerv1- int value to which header is set
-
setStatus
public void setStatus(int v1) Sets a simple Status response header.
Supported API: true- Specified by:
setStatusin classHTTPResponse- Parameters:
v1- Integer Status code
-
setStatus
Sets a Status response header.
Supported API: true- Specified by:
setStatusin classHTTPResponse- Parameters:
v1- Integer Status codes1- String Status reason code
-