Skip to content

doc, http: Type specification incomplete for ServerResponse.getHeader() #13825

@Flarna

Description

@Flarna
  • Version: 8.1.2 (but applicable to others)
  • Platform: all
  • Subsystem: doc, http
  • ServerResponse.setHeader() specifies name as string and value as string | string[].
  • ServerResponse.writeHead() allows an object for headers (key is header name, value is header value). All samples use string for keys and string | string[] for values - except one which uses Buffer.byteLength(body) which is a number (the sample works fine).
  • ServerResponse.getHeader() specifies to return a string.

Actually getHeader() returns what as passed in so it should be at least string | string[].
But as setHeader() and writeHead() actually allow any stringifyable type you get also such type back as the conversion to string happens when writing the outgoing stream not during storing the header.

Not sure here if this is worth a change; and if yes should it be in doc or code?

I would guess the same is applicable to ClientRequest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions