Core
Framework v2.x
2

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-Cookie values 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
NameTypeDescription
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"