From 70ee7dce62b046d55d606f2bd8ffdef0b35ba045 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 9e526333b664ad..a93fb3d3164796 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1584,6 +1584,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`