Skip to main content

appendHeader

method Http2ServerResponse.prototype.appendHeader
Jump to headingHttp2ServerResponse.prototype.appendHeader(
name: string,
value: string | string[],
): void

Append a single header value to the header object.

If the value is an array, this is equivalent to calling this method multiple times.

If there were no previous values for the header, this is equivalent to calling setHeader.

Attempting to set a header field name or value that contains invalid characters will result in a TypeError being thrown.

// Returns headers including "set-cookie: a" and "set-cookie: b"
const server = http2.createServer((req, res) => {
  res.setHeader('set-cookie', 'a');
  res.appendHeader('set-cookie', 'b');
  res.writeHead(200);
  res.end('ok');
});

Parameters Jump to heading

Jump to headingname: string
Jump to headingvalue: string | string[]

Return Type Jump to heading

void
Back to top