setHeader #
Available since 2.11.0
Sets a response header, with the same behavior as Node.js response.setHeader. Header names are case-insensitive.
If the header is already set:
- standard single-value headers (
Content-Type,Content-Length,Authorization,ETag,Expires,Retry-After,User-Agent...) are overwritten; Set-Cookievalues are added to an array;- any other value is appended to the existing one, separated by
,.
The value is converted to a string. Returns true.
Arguments #
setHeader (name: string, value: string): any| Name | Type | Description |
|---|---|---|
name | string | Header name |
value | string | Header value |
Example #
request.response.setHeader('Cache-Control', 'no-cache');
request.response.setHeader('Cache-Control', 'no-store');
request.response.getHeader('cache-control');
// "no-cache, no-store"