sa_set_http_header system procedure

Permits a web service to set an HTTP header in the result.

Syntax
sa_set_http_header( 
fldname, 
val 
)
Arguments
  • fldname   Use this CHAR(128) parameter to specify a string containing the name of one of the HTTP header fields.

  • val   Use this LONG VARCHAR parameter to specify the value to which the named parameter should be set.

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 command sets the status code to 404 Not Found.

CALL dbo.sa_set_http_header( '@HttpStatus', '404' );

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.

With the exception of the Connection response header, response headers generated automatically by the database server can be removed. For example, the following command removes the Expires response header:

CALL dbo.sa_set_http_header( 'Expires', NULL );
Permissions

None

Side effects

None

See also
Example

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

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