diff options
author | Luigi Pinca <luigipinca@gmail.com> | 2022-04-18 20:49:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-18 19:49:05 +0100 |
commit | bde889bd4ed68d33163897b4175557fbc669b66f (patch) | |
tree | 6f2425c531d86ff62670289bb32d3583b1d121a2 | |
parent | 3347361713b4af5266689cc603c9b5d0c63454c0 (diff) | |
download | node-new-bde889bd4ed68d33163897b4175557fbc669b66f.tar.gz |
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 <paolo@cowtech.it>
Reviewed-By: Mestery <mestery@protonmail.com>
-rw-r--r-- | doc/api/http.md | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/doc/api/http.md b/doc/api/http.md index 0174908eb5..56c8a89d42 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -729,6 +729,16 @@ deprecated: v13.0.0 See [`request.socket`][]. +### `request.cork()` + +<!-- YAML +added: + - v13.2.0 + - v12.16.0 +--> + +See [`writable.cork()`][]. + ### `request.end([data[, encoding]][, callback])` <!-- YAML @@ -846,6 +856,52 @@ const cookie = request.getHeader('Cookie'); // 'cookie' is of type string[] ``` +### `request.getHeaderNames()` + +<!-- YAML +added: v7.7.0 +--> + +* 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()` + +<!-- YAML +added: v7.7.0 +--> + +* 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()` <!-- YAML @@ -867,6 +923,22 @@ const headerNames = request.getRawHeaderNames(); // headerNames === ['Foo', 'Set-Cookie'] ``` +### `request.hasHeader(name)` + +<!-- YAML +added: v7.7.0 +--> + +* `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` @@ -1090,6 +1162,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()` + +<!-- YAML +added: + - v13.2.0 + - v12.16.0 +--> + +See [`writable.uncork()`][]. + ### `request.writableEnded` <!-- YAML |