Skip to content

Commit 962d80b

Browse files
lpincatargos
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 <[email protected]> Reviewed-By: Mestery <[email protected]>
1 parent 222b3e6 commit 962d80b

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
@@ -729,6 +729,16 @@ deprecated: v13.0.0
729729

730730
See [`request.socket`][].
731731

732+
### `request.cork()`
733+
734+
<!-- YAML
735+
added:
736+
- v13.2.0
737+
- v12.16.0
738+
-->
739+
740+
See [`writable.cork()`][].
741+
732742
### `request.end([data[, encoding]][, callback])`
733743

734744
<!-- YAML
@@ -846,6 +856,52 @@ const cookie = request.getHeader('Cookie');
846856
// 'cookie' is of type string[]
847857
```
848858

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

851907
<!-- YAML
@@ -867,6 +923,22 @@ const headerNames = request.getRawHeaderNames();
867923
// headerNames === ['Foo', 'Set-Cookie']
868924
```
869925

926+
### `request.hasHeader(name)`
927+
928+
<!-- YAML
929+
added: v7.7.0
930+
-->
931+
932+
* `name` {string}
933+
* Returns: {boolean}
934+
935+
Returns `true` if the header identified by `name` is currently set in the
936+
outgoing headers. The header name matching is case-insensitive.
937+
938+
```js
939+
const hasContentType = request.hasHeader('content-type');
940+
```
941+
870942
### `request.maxHeadersCount`
871943

872944
* {number} **Default:** `2000`
@@ -1090,6 +1162,16 @@ This property is guaranteed to be an instance of the {net.Socket} class,
10901162
a subclass of {stream.Duplex}, unless the user specified a socket
10911163
type other than {net.Socket}.
10921164

1165+
### `request.uncork()`
1166+
1167+
<!-- YAML
1168+
added:
1169+
- v13.2.0
1170+
- v12.16.0
1171+
-->
1172+
1173+
See [`writable.uncork()`][].
1174+
10931175
### `request.writableEnded`
10941176

10951177
<!-- YAML

0 commit comments

Comments
 (0)