You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
I would expect to get an array of strings in the route handler as well.
Fastify does nothing to the incoming headers - unless you set a json schema as validator.
Headers are parsed by Node.js itself and when it gets an incoming request with multiple header's value:
You need to write an hook to run custom logic agains incoming headers.
Another solution can be to set a json schema with some plugins (not checked but I'm quite sure it exists)
Thanks for the explanation. I was following the type definition of RawRequest['headers'] and according to that header values could be arrays. So I’ve implement logic to handle those arrays. Now I want to write a unit test to test that logic using light-my-request. However it seems like it is not possible to create such header values. Is the type definition incorrect?
Prerequisites
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
gives me the following request headers in the route handler:
Expected Behavior
I would expect to get an array of strings in the route handler as well.
The text was updated successfully, but these errors were encountered: