setHeaders #
Available since 2.11.0
Sets several response headers at once, with setHeader.
Throws an api.assert.invalid_type error if headers is not an object.
Arguments #
setHeaders (headers: JSONObject, ifNotPresent: boolean = false): void| Name | Type | Description |
|---|---|---|
headers | JSONObject | Headers to set, as name: value pairs |
ifNotPresent | boolean | If true, only sets the headers that are not already set (default: false) |
Example #
request.response.setHeaders({
'Cache-Control': 'no-cache',
'X-Custom-Header': 'value',
});
// Does not change a Content-Type header already set
request.response.setHeaders({ 'Content-Type': 'text/plain' }, true);