Skip to main content
Http2ServerResponse.prototype.getHeaders - node__http2.d.ts - Node documentation
method Http2ServerResponse.prototype.getHeaders

Usage in Deno

```typescript import { Http2ServerResponse } from "node:node__http2.d.ts"; ```
Http2ServerResponse.prototype.getHeaders(): OutgoingHttpHeaders
Returns a shallow copy of the current outgoing headers. Since a shallow copy is used, array values may be mutated without additional calls to various header-related http module methods. The keys of the returned object are the header names and the values are the respective header values. All header names are lowercase. The object returned by the `response.getHeaders()` method _does not_ prototypically inherit from the JavaScript `Object`. This means that typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`, and others are not defined and _will not work_. ```js response.setHeader('Foo', 'bar'); response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); const headers = response.getHeaders(); // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] } ```

Return Type