Skip to content

Commit cc90d11

Browse files
lpincajuanarbol
authored andcommitted
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: #42691 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Mestery <mestery@protonmail.com>
1 parent 2d8dbe8 commit cc90d11

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

doc/api/http.md

+82
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,16 @@ deprecated: v13.0.0
723723

724724
See [`request.socket`][].
725725

726+
### `request.cork()`
727+
728+
<!-- YAML
729+
added:
730+
- v13.2.0
731+
- v12.16.0
732+
-->
733+
734+
See [`writable.cork()`][].
735+
726736
### `request.end([data[, encoding]][, callback])`
727737

728738
<!-- YAML
@@ -840,6 +850,52 @@ const cookie = request.getHeader('Cookie');
840850
// 'cookie' is of type string[]
841851
```
842852

853+
### `request.getHeaderNames()`
854+
855+
<!-- YAML
856+
added: v7.7.0
857+
-->
858+
859+
* Returns: {string\[]}
860+
861+
Returns an array containing the unique names of the current outgoing headers.
862+
All header names are lowercase.
863+
864+
```js
865+
request.setHeader('Foo', 'bar');
866+
request.setHeader('Cookie', ['foo=bar', 'bar=baz']);
867+
868+
const headerNames = request.getHeaderNames();
869+
// headerNames === ['foo', 'Cookie']
870+
```
871+
872+
### `request.getHeaders()`
873+
874+
<!-- YAML
875+
added: v7.7.0
876+
-->
877+
878+
* Returns: {Object}
879+
880+
Returns a shallow copy of the current outgoing headers. Since a shallow copy
881+
is used, array values may be mutated without additional calls to various
882+
header-related http module methods. The keys of the returned object are the
883+
header names and the values are the respective header values. All header names
884+
are lowercase.
885+
886+
The object returned by the `response.getHeaders()` method _does not_
887+
prototypically inherit from the JavaScript `Object`. This means that typical
888+
`Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`, and others
889+
are not defined and _will not work_.
890+
891+
```js
892+
request.setHeader('Foo', 'bar');
893+
request.setHeader('Cookie', ['foo=bar', 'bar=baz']);
894+
895+
const headers = response.getHeaders();
896+
// headers === { foo: 'bar', 'cookie': ['foo=bar', 'bar=baz'] }
897+
```
898+
843899
### `request.getRawHeaderNames()`
844900

845901
<!-- YAML
@@ -859,6 +915,22 @@ const headerNames = request.getRawHeaderNames();
859915
// headerNames === ['Foo', 'Set-Cookie']
860916
```
861917

918+
### `request.hasHeader(name)`
919+
920+
<!-- YAML
921+
added: v7.7.0
922+
-->
923+
924+
* `name` {string}
925+
* Returns: {boolean}
926+
927+
Returns `true` if the header identified by `name` is currently set in the
928+
outgoing headers. The header name matching is case-insensitive.
929+
930+
```js
931+
const hasContentType = request.hasHeader('content-type');
932+
```
933+
862934
### `request.maxHeadersCount`
863935

864936
* {number} **Default:** `2000`
@@ -1082,6 +1154,16 @@ This property is guaranteed to be an instance of the {net.Socket} class,
10821154
a subclass of {stream.Duplex}, unless the user specified a socket
10831155
type other than {net.Socket}.
10841156

1157+
### `request.uncork()`
1158+
1159+
<!-- YAML
1160+
added:
1161+
- v13.2.0
1162+
- v12.16.0
1163+
-->
1164+
1165+
See [`writable.uncork()`][].
1166+
10851167
### `request.writableEnded`
10861168

10871169
<!-- YAML

0 commit comments

Comments
 (0)