Permits a web service to set an HTTP response header.
sa_set_http_header( fldname, val )
Setting the special header field @HttpStatus sets the status code returned with the request. The status code is also known as the response code. For example, the following script sets the status code to 404 Not Found:
CALL sa_set_http_header( '@HttpStatus', '404' );
You can create a user-defined status message by specifying a three digit status code with an optional colon-delimited text message. For example, the following script outputs a status code with the message "999 User Code":
CALL sa_set_http_header( '@HttpStatus', '999:User Code' );
The body of the error message is inserted automatically. Only valid HTTP error codes can be used. Setting the status to an invalid code causes a SQL error.
The sa_set_http_header procedure always overwrites the existing header value of the header field when called.
Response headers generated automatically by the database server can be removed. For example, the following command removes the Expires response header:
CALL sa_set_http_header( 'Expires', NULL );
None
None
The following example sets the Content-Type header field to text/html.
CALL sa_set_http_header( 'Content-Type', 'text/html' );