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
EDIT: Please let me know what the expected behavior is and I will be happy to submit a PR. I'm assuming we should either handle this error, or accept an array for 'content-type'.
The text was updated successfully, but these errors were encountered:
oztune
changed the title
res.set() throws unexpected error when content-type is an array
res.set() throws unexpected error when content-type is an array
May 9, 2017
Hi @oztune I would say that accepting an array doesn't even make sense, and since this code has been there for all of 4.x, providing an array would have always been an error. I think that this is a good change, in that we should add a guard that throws a better error message when a non-string is provided for content-type.
My reasoning is that it's easier to loosen a restriction than to add it back later, so if there ever is some demand for an array, we can easily add that, but I can't think of any reason an array would make sense in this header, unless you know.
@dougwilson I agree, I'll make a PR that throws a more sensible error. My use-case was that I'm proxying a node-fetch response over to an express response, and a very special API error was causing this odd failure.
When I run this code:
The following error is thrown:
It seems to stem from the following line which assumes that the value of
content-type
will always be a string:https://github.com/expressjs/express/blob/master/lib/response.js#L721
Is this a bug or a feature?
EDIT: Please let me know what the expected behavior is and I will be happy to submit a PR. I'm assuming we should either handle this error, or accept an array for 'content-type'.
The text was updated successfully, but these errors were encountered: