node icon indicating copy to clipboard operation
node copied to clipboard

http.request should be documented to receive an headers array

Open yotamN opened this issue 8 months ago β€’ 3 comments

Affected URL(s)

https://nodejs.org/docs/latest/api/http.html#httprequesturl-options-callback

Description of the problem

It appears that the implementation of http.request allows sending headers as an array of strings, similar to response.writeHead. However, this feature is not documented. I am wondering if this is an oversight or intentionally left undocumented. If it is not intentional, I would be happy to update the documentation to reflect this functionality. I just wanted to confirm before proceeding.

yotamN avatar Apr 23 '25 07:04 yotamN

Hey how can i contribute, please assign me

TanzimHossainSafin avatar May 01 '25 18:05 TanzimHossainSafin

Hey @tanzimsafin, we don’t assign issues, but you’re more than welcome to contribute by opening a PR! 😁

pmarchini avatar May 01 '25 20:05 pmarchini

From my shallow analysis of https://github.com/nodejs/node/blob/4a4aa58fa4a3736744f605abc70eb6c167aadf9d/lib/_http_client.js#L294 it seems that Array here is not something coincidentally working but rather explicitly handled as one of the possible value on options.headers so I thing it should be also mentioned in documentation, but of course I may be wrong πŸ˜…

Edit: on the other side I found some old issue https://github.com/nodejs/node/issues/2400 - this is about Array in Array ([['Content-Type', 'text/plain'], ['X-Data', 'hello world']] in options.headers but maybe it also has relevance in context of this issue.

arturgawlik avatar May 03 '25 09:05 arturgawlik

would anyone please help me how to solve it. i am new to opesource.

souravmanikandan avatar May 31 '25 15:05 souravmanikandan

Hi, I'm interested in contributing to this issue. I'll prepare a PR for the documentation update.

Dinesh0007000 avatar Jun 20 '25 05:06 Dinesh0007000