From 902f5417258ac5adcacb5c03a76b6c9b09e30419 Mon Sep 17 00:00:00 2001 From: XadillaX Date: Thu, 28 May 2020 18:27:37 +0800 Subject: [PATCH 1/3] http: add res.req and res.redirect() Add `res.req` and `res.redirect()` in http server for convenience. Fixes: https://github.com/nodejs/node/issues/28673 --- doc/api/http.md | 28 +++++++++ lib/_http_outgoing.js | 20 +++++++ lib/_http_server.js | 1 + test/parallel/test-http-response-redirect.js | 62 ++++++++++++++++++++ test/parallel/test-http-server.js | 2 + 5 files changed, 113 insertions(+) create mode 100644 test/parallel/test-http-response-redirect.js diff --git a/doc/api/http.md b/doc/api/http.md index 357d8b16928d47..a19d0df91c7a82 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1350,6 +1350,13 @@ deprecated: v13.0.0 See [`response.socket`][]. +### `response.req` + +* {IncomingMessage|undefined} + +If it's a response object in an HTTP request, this object will be it's +`request` object. + ### `response.cork()` -* {IncomingMessage|undefined} +* {http.IncomingMessage|undefined} If it's a response object in an HTTP request, this object will be it's `request` object. @@ -1391,10 +1394,16 @@ If `callback` is specified, it will be called when the response stream is finished. ### `response.send()` + This is an alias for `response.end()`. ### `response.redirect(url[, statusCode][, body][, callback])` + * `url` {string} * `statusCode` {number}