Skip to content

doc: clarify http.request supports headers as array #58769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -3820,7 +3820,19 @@ changes:
* `family` {number} IP address family to use when resolving `host` or
`hostname`. Valid values are `4` or `6`. When unspecified, both IP v4 and
v6 will be used.
* `headers` {Object} An object containing request headers.
* `headers` {Object | Array} Request headers to send with the request. This can be:
* An object like `{ 'Content-Type': 'application/json' }`.
* A flat array of header name/value pairs like
`[ 'Content-Type', 'text/plain', 'X-Custom', 'yes' ]`. This format is
the same as used in [`response.writeHead()`][] and exposed in
[`request.rawHeaders`][].

When passing `headers` as an array, it must be a flat list of alternating
header names and values. Nested arrays or objects are not supported in this
form. This array format is identical to that used in [`response.writeHead()`][]
and [`request.rawHeaders`][], and is often useful when working with raw header
data directly.

* `hints` {number} Optional [`dns.lookup()` hints][].
* `host` {string} A domain name or IP address of the server to issue the
request to. **Default:** `'localhost'`.
Expand Down Expand Up @@ -4329,3 +4341,4 @@ A browser-compatible implementation of [`WebSocket`][].
[`writable.uncork()`]: stream.md#writableuncork
[`writable.write()`]: stream.md#writablewritechunk-encoding-callback
[initial delay]: net.md#socketsetkeepaliveenable-initialdelay
[`request.rawHeaders`]: #requestrawheaders
Loading