From faceae34c53b2dad53da76fe5e672ab1770da4eb 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 --- 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 8851ae8d6e4893..0302da4b19426b 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1589,6 +1589,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`