Skip to content

doc: add Array type in http request headers #58049

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 1 commit into
base: main
Choose a base branch
from

Conversation

mikaws
Copy link

@mikaws mikaws commented Apr 27, 2025

The http.request allows sending headers as an array of strings.

Fixes: #57986

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem. labels Apr 27, 2025
@anonrig anonrig added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 27, 2025
doc/api/http.md Outdated
@@ -3818,7 +3818,7 @@ 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} An object or an array of strings containing request headers. The array is in the same format as request.rawHeaders.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* `headers` {Object|Array} An object or an array of strings containing request headers. The array is in the same format as request.rawHeaders.
* `headers` {Object|Array} An object or an array of strings containing request headers. The array is in the same format as [`message.rawHeaders`][].

and

[`message.rawHeaders`]: #messagerawheaders

at the end of the file.

Copy link
Author

@mikaws mikaws Apr 28, 2025

Choose a reason for hiding this comment

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

Thank you :)
I've updated the commit with the suggested change to reference [message.rawHeaders][].
Please let me know if there's anything else needed. See ad2fb4d.

mikaws added a commit to mikaws/node that referenced this pull request Apr 28, 2025
Document that the headers option in http.request() can be either an object or an array of strings, similar to message.rawHeaders.

PR-URL: nodejs#58049
Fixes: nodejs#57986
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@mikaws mikaws force-pushed the doc-http-request-headers-array branch from ff83ffa to ad2fb4d Compare April 28, 2025 11:34
Document that the headers option in http.request() can be either an
object or an array of strings, similar to message.rawHeaders.

PR-URL: nodejs#58049
Fixes: nodejs#57986
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@mikaws mikaws force-pushed the doc-http-request-headers-array branch from ad2fb4d to 0b8059e Compare April 28, 2025 20:46
@mikaws
Copy link
Author

mikaws commented Apr 28, 2025

Error: not ok 2 fixes-url: Fixes must be a URL, not an issue number.
Error: not ok 4 line-length: Line should be <= 72 columns.

I've fixed the commit message issues.
This is my first time contributing — I'll make sure to review the guidelines more carefully moving forward.

@@ -3818,7 +3818,7 @@ 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} An object or an array of strings containing request headers. The array is in the same format as [`message.rawHeaders`][].
Copy link
Member

@trivikr trivikr Apr 29, 2025

Choose a reason for hiding this comment

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

nit: limit line length to 80 characters, and remove extra space

Suggested change
* `headers` {Object|Array} An object or an array of strings containing request headers. The array is in the same format as [`message.rawHeaders`][].
* `headers` {Object|Array} An object or an array of strings containing request
headers. The array is in the same format as [`message.rawHeaders`][].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem.
8 participants