Skip to main content
Http2ServerResponse.prototype.appendHeader - http2 - Node documentation
method Http2ServerResponse.prototype.appendHeader

Usage in Deno

import { Http2ServerResponse } from "node:http2";
Http2ServerResponse.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

name: string
value: string | string[]

Return Type

void