From fc3f1c3c7106a586b6ec90c97ce1b0196791b89f Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Sun, 13 Dec 2020 16:25:14 -0800 Subject: [PATCH] http: attach request as res.req This change makes it possible for userland http-related modules to pave over edge cases that require referencing the original request when handling a response--making a "Lodash for HTTP" library possible. More information and research in https://github.com/nodejs/node/issues/28673 Fixes: https://github.com/nodejs/node/issues/28673 PR-URL: https://github.com/nodejs/node/pull/36505 Reviewed-By: Robert Nagy --- doc/api/http.md | 9 +++++ doc/api/http2.md | 9 +++++ lib/_http_server.js | 1 + lib/internal/http2/compat.js | 4 ++ test/parallel/test-http-server.js | 2 + .../test-http2-compat-serverresponse.js | 40 +++++++++++++++++++ 6 files changed, 65 insertions(+) create mode 100644 test/parallel/test-http2-compat-serverresponse.js diff --git a/doc/api/http.md b/doc/api/http.md index 6e6104c88a1599..813d5cf1e96f19 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1598,6 +1598,15 @@ Removes a header that's queued for implicit sending. response.removeHeader('Content-Encoding'); ``` +### `response.req` + + +* {http.IncomingMessage} + +A reference to the original HTTP `request` object. + ### `response.sendDate` + +* {http2.Http2ServerRequest} + +A reference to the original HTTP2 `request` object. + #### `response.sendDate`