From 0c9343cb6ad469b1270b70fa574a52faa48aacff Mon Sep 17 00:00:00 2001 From: "K.C.Ashish Kumar" <703559+kcak11@users.noreply.github.com> Date: Thu, 7 Apr 2022 22:18:43 +0530 Subject: [PATCH] http: document that ClientRequest inherits from OutgoingMessage http: fix extends for ClientRequest from Stream to http.OutgoingMessage http: added page entry for http.OutgoingMessage http: updated order of links http: included entry for http.OutgoingMessage http: removed unnecessary entry from md file PR-URL: https://github.com/nodejs/node/pull/42642 Reviewed-By: Matteo Collina Reviewed-By: Paolo Insogna Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Benjamin Gruenbaum --- doc/api/http.md | 10 +++++----- tools/doc/type-parser.mjs | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index ca92068d0007ff..315146adb9d6cc 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -391,7 +391,7 @@ agent. Do not modify. added: v0.1.17 --> -* Extends: {Stream} +* Extends: {http.OutgoingMessage} This object is created internally and returned from [`http.request()`][]. It represents an _in-progress_ request whose header has already been queued. The @@ -2209,7 +2209,7 @@ Key-value pairs of header names and values. Header names are lower-cased. // { 'user-agent': 'curl/7.22.0', // host: '127.0.0.1:8000', // accept: '*/*' } -console.log(request.headers); +console.log(request.getHeaders()); ``` Duplicates in raw headers are handled in the following ways, depending on the @@ -2376,15 +2376,15 @@ Accept: text/plain To parse the URL into its parts: ```js -new URL(request.url, `http://${request.headers.host}`); +new URL(request.url, `http://${request.getHeaders().host}`); ``` When `request.url` is `'/status?name=ryan'` and -`request.headers.host` is `'localhost:3000'`: +`request.getHeaders().host` is `'localhost:3000'`: ```console $ node -> new URL(request.url, `http://${request.headers.host}`) +> new URL(request.url, `http://${request.getHeaders().host}`) URL { href: 'http://localhost:3000/status?name=ryan', origin: 'http://localhost:3000', diff --git a/tools/doc/type-parser.mjs b/tools/doc/type-parser.mjs index 71a4eb98976da6..fe22a6928e093a 100644 --- a/tools/doc/type-parser.mjs +++ b/tools/doc/type-parser.mjs @@ -148,6 +148,7 @@ const customTypesMap = { 'http.Agent': 'http.html#class-httpagent', 'http.ClientRequest': 'http.html#class-httpclientrequest', 'http.IncomingMessage': 'http.html#class-httpincomingmessage', + 'http.OutgoingMessage': 'http.html#class-httpoutgoingmessage', 'http.Server': 'http.html#class-httpserver', 'http.ServerResponse': 'http.html#class-httpserverresponse',