From cc90d1161d2fb9b2f91bb5381725b8dec6acb979 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 18 Apr 2022 20:49:05 +0200 Subject: [PATCH] doc: add documentation for inherited methods These methods are inherited from `http.OutgoingMessage` and they are already documented as methods of the `http.ServerResponse` class. For consistency, document them also as methods of the `http.ClientRequest` class. PR-URL: https://github.com/nodejs/node/pull/42691 Reviewed-By: Paolo Insogna Reviewed-By: Mestery --- doc/api/http.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/doc/api/http.md b/doc/api/http.md index 761660ece84300..db77df49715618 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -723,6 +723,16 @@ deprecated: v13.0.0 See [`request.socket`][]. +### `request.cork()` + + + +See [`writable.cork()`][]. + ### `request.end([data[, encoding]][, callback])` + +* Returns: {string\[]} + +Returns an array containing the unique names of the current outgoing headers. +All header names are lowercase. + +```js +request.setHeader('Foo', 'bar'); +request.setHeader('Cookie', ['foo=bar', 'bar=baz']); + +const headerNames = request.getHeaderNames(); +// headerNames === ['foo', 'Cookie'] +``` + +### `request.getHeaders()` + + + +* Returns: {Object} + +Returns a shallow copy of the current outgoing headers. Since a shallow copy +is used, array values may be mutated without additional calls to various +header-related http module methods. The keys of the returned object are the +header names and the values are the respective header values. All header names +are lowercase. + +The object returned by the `response.getHeaders()` method _does not_ +prototypically inherit from the JavaScript `Object`. This means that typical +`Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`, and others +are not defined and _will not work_. + +```js +request.setHeader('Foo', 'bar'); +request.setHeader('Cookie', ['foo=bar', 'bar=baz']); + +const headers = response.getHeaders(); +// headers === { foo: 'bar', 'cookie': ['foo=bar', 'bar=baz'] } +``` + ### `request.getRawHeaderNames()` + +* `name` {string} +* Returns: {boolean} + +Returns `true` if the header identified by `name` is currently set in the +outgoing headers. The header name matching is case-insensitive. + +```js +const hasContentType = request.hasHeader('content-type'); +``` + ### `request.maxHeadersCount` * {number} **Default:** `2000` @@ -1082,6 +1154,16 @@ This property is guaranteed to be an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specified a socket type other than {net.Socket}. +### `request.uncork()` + + + +See [`writable.uncork()`][]. + ### `request.writableEnded`