Skip to content

Multi-value request headers are serialized to comma-separated string #264

Open
@lo1tuma

Description

@lo1tuma

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.23.2

Plugin version

No response

Node.js version

20.x

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

13.0

Description

The .inject() method allows to inject request headers which values can be a string or an array of strings. When an array is used, it gets serialized to an comma-separated string.

Steps to Reproduce

await fastifyInstance.inject({ method: 'get', url: '/', headers: { foo: 'bar', baz: ['first', 'second'] } });

gives me the following request headers in the route handler:

{
  baz: 'first,second',
   foo: 'bar',
  host: 'localhost:80',
   'user-agent': 'lightMyRequest'
}

Expected Behavior

I would expect to get an array of strings in the route handler as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions