UNPKG

722 BTypeScriptView Raw
1/// <reference types="node" />
2
3import { ServerResponse } from "http";
4
5/**
6 * This will add the listener to fire when headers are emitted for res.
7 * The listener is passed the response object as its context (this).
8 * Headers are considered emitted only once, right before they
9 * are sent to the client.
10 *
11 * When this is called multiple times on the same res, the listeners
12 * are fired in the reverse order they were added.
13 *
14 * @param res HTTP server response object
15 * @param listener Function to call prior to headers being emitted,
16 * the response object is passed as this context.
17 */
18declare function onHeaders(res: ServerResponse, listener: (this: ServerResponse) => void): void;
19
20export = onHeaders;