sa_set_http_header system procedure

Permits a web service to set an HTTP response header.

Syntax

sa_set_http_header( 
fldname, 
val 
)

Arguments

Remarks

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' );
Note: A user defined status text message is not translated into a database character-set when logged using the LogOptions protocol option.

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 );

Permissions

None

Side effects

None

Example

The following example sets the Content-Type header field to text/html.

CALL sa_set_http_header( 'Content-Type', 'text/html' );