CX_HTTP_RESPONSE
Class hierarchy
- CX_CLASS
- CX_HTTP_RESPONSE 159571
Description:
Class to assemble an HTTP response (consisting of status code, header and body) in InstantView code via method calls. At the end of a message that handles an HTTP request, the Web service server expects either a string returned with ReturnStack and implicitly converted into an HTTP response object with status code 200. Alternatively, a CX_HTTP_RESPONSE object can be returned directly with ReturnStack .
When an HTTP request is sent via SendRequest , the server response is placed on the stack as a CX_HTTP_RESPONSE object.
The specification of an HTTP response can be found at http://tools.ietf.org/html/rfc2616#section-6
Code example:
Incoming GET request
Implementation of the message (the two macros "GetPersonFromName" and "FormatPersonAsJSON" are assumed to be implemented)
CALL_PERSON_GET: "person_name" Swap Call(GetParameter) GetPersonFromName FormatPersonAsJSON -> jsonReturnValue
CreateTransObject(CX_HTTP_RESPONSE) -> response
jsonReturnValue response Call(SetBody)
"Content-Type" "application/json" response Call(SetHeader)
"Server" "ClassiX/4.5.2" response Call(SetHeader)
200 response Call(SetStatus) // not actually neccessary, as this is already the default
response ReturnStack
This results in the following outgoing HTTP response:
Date: Thu, 15 Jul 2004 19:20:21 GMT
Content-length: 42
Content-type: application/json
Connection: close
Server: ClassiX/4.5.2
{ "vorname" : "Hugo", "name" : "Schmidt" }
Function | MA* | Parameters | Return | Brief description |
---|---|---|---|---|
GetBody | STRING | Returns the Reponse Body | ||
GetBodyAsBase64 222628 | STRING | Returns the response body as a base64 encoded string. | ||
GetBodyAsFile 222628 | STRING | Writes the response body to the specified file. | ||
GetHeader | STRING | STRING | Returns the header of the response object | |
GetHeaderNames |
| Returns the names of all set headers | ||
GetStatus | INTEGER | Returns the set HTTP status | ||
GetTime | CX_DATETIME | Returns the time at which the request has been completely processed | ||
SetBody | STRING | Defines the body of the response | ||
SetBodyFromBase64 222628 | STRING | Sets the response body from a Base64-encoded string | ||
SetBodyFromFile 222628 | STRING | Sets the response body from the content of the transferred file. | ||
SetHeader | STRING, STRING | Defines the value for a header field | ||
SetStatus | INTEGER | Defines the status code of the response |
* MA = Member Access function,
grey background = inherited function
Data field | Type | Reference class | I* | Brief description |
---|---|---|---|---|
status | INTEGER | HTTP status of the response |
* I = Indexable data field,
grey background = inherited data field
Module | Brief description |
---|---|