Skip to content
Open
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -3820,7 +3820,9 @@ 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' }`, or
* An array of key-value pairs like `[ 'Content-Type', 'text/plain', 'X-Custom', 'yes' ]`, similar to how headers are passed to `response.writeHead()`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a series of extra spaces here (are passed), and this line is very long, which will be why the markdown linting is failing here. Can you fix that? You can run the markdown linting locally by running make lint-md.

"An array of key-value pairs" is not clear I think - that will make people think of [["key1", "value1"], ["key2", "value2"]] which is not what's happening. We should be specific that this is a flat array of values, not tuples, since this can be confusing.

I think it would be good to link to response.writeHead here, and request.rawHeaders as well (which uses the same format).

It might be better to keep the text inline here simple (a very short explanation of "headers object or flat array of raw headers" or similar) and then include the larger explanation & examples as a paragraph in the text below. What do you think? See what looks best - you can test the docs locally by running make docserve and then looking at http://localhost:8000.

* `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
Loading