Skip to content

doc: add Array type in http request headers - #58049

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mikaws:doc-http-request-headers-array
Jun 27, 2025
Merged

doc: add Array type in http request headers#58049
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mikaws:doc-http-request-headers-array

Conversation

@mikaws

Copy link
Copy Markdown
Contributor

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

Fixes: #57986

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-botnodejs-github-bot added doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem. labels Apr 27, 2025
@anonriganonrig added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 27, 2025
Comment threaddoc/api/http.md Outdated

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.

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.

@mikawsmikawsApr 28, 2025

Copy link
Copy Markdown
ContributorAuthor

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
mikawsforce-pushed the doc-http-request-headers-array branch from ff83ffa to ad2fb4dCompareApril 28, 2025 11:34
@mikaws
mikawsforce-pushed the doc-http-request-headers-array branch from ad2fb4d to 0b8059eCompareApril 28, 2025 20:46
@mikaws

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threaddoc/api/http.md Outdated

@trivikrtrivikrApr 29, 2025

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.

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`][].

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed as suggested, thanks for the careful review. See 238caa5.

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#58049Fixes: nodejs#57986
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@mikaws
mikawsforce-pushed the doc-http-request-headers-array branch from 0b8059e to 238caa5CompareApril 30, 2025 18:00
@mikaws
mikaws requested review from lpinca and trivikrMay 1, 2025 23:53
@Ethan-ArrowoodEthan-Arrowood added backported-to-v20.x backported-to-v22.x PRs backported to the v22.x-staging branch. backported-to-v24.x PRs backported to the v24.x-staging branch. labels May 8, 2025
jeremymeng added a commit to jeremymeng/azure-sdk-for-js that referenced this pull request May 12, 2025
The latest @types/node changes add `string[]` to the `RequestOptions.headers` type:
DefinitelyTyped/DefinitelyTyped#72617nodejs/node#58049
This PR adds a check and narrow the the type to `http.OutgoingHttpHeaders` before accessing user-agent
property. We don't ever set the user agent header using the `string[]` form so this should be fine.
jeremymeng added a commit to jeremymeng/azure-sdk-for-js that referenced this pull request May 12, 2025
The latest @types/node changes add `string[]` to the `RequestOptions.headers` type:
DefinitelyTyped/DefinitelyTyped#72617nodejs/node#58049
This PR adds a check and narrow the the type to `http.OutgoingHttpHeaders` before accessing user-agent
property. We don't ever set the user agent header using the `string[]` form so this should be fine.
jeremymeng added a commit to Azure/azure-sdk-for-js that referenced this pull request May 12, 2025
The latest @types/node changes add `string[]` to the
`RequestOptions.headers` type:
DefinitelyTyped/DefinitelyTyped#72617nodejs/node#58049
This PR adds a check and narrow the type to `http.OutgoingHttpHeaders`
before accessing user-agent
property. We don't ever set the user agent header using the `string[]`
form so this should be fine.
@aduh95aduh95 added commit-queue Add this label to land a pull request using GitHub Actions. and removed backported-to-v20.x backported-to-v22.x PRs backported to the v22.x-staging branch. backported-to-v24.x PRs backported to the v24.x-staging branch. labels Jun 27, 2025
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 27, 2025
@nodejs-github-bot
nodejs-github-bot merged commit db8ca62 into nodejs:mainJun 27, 2025
4 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in db8ca62

targos pushed a commit that referenced this pull request Jul 3, 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: #58049Fixes: #57986
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
aduh95 pushed a commit that referenced this pull request Jul 21, 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: #58049Fixes: #57986
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
aduh95 pushed a commit that referenced this pull request Jul 24, 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: #58049Fixes: #57986
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.docIssues and PRs related to the documentations.httpIssues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http.request should be documented to receive an headers array

11 participants

@mikaws@nodejs-github-bot@ShogunPanda@jasnell@lpinca@anonrig@trivikr@Ethan-Arrowood@marco-ippolito@bjohansebas@aduh95