Open lostintangent opened 8 years ago
Good catch @lostintangent. You didn't happen to be a tester in a previous life, did you?
The issue here is a difference in semantics. Calling res.cookie()
or res.links()
is effectively a wrapper around res.setHeader()
for the Set-Cookie
and Link
headers, respectively. Express does, in fact, "overwrite" the previous header value--it just does so by setting its new value to the old value plus the added value. (In the case of res.links()
, it concatenates each added value to the previous values with a delimiter whereas res.cookie()
just provides multiple values for the header.)
It may be difficult to differentiate, in general, between middleware "appending" a header vs. setting a header to multiple values, some of which happen to match earlier values. This is especially true if the appending is arbitrarily done via concatenation or via multiple values. We might add special rules to the Glimpse client for Set-Cookie
and Link
which look at previously-set header values to see if there is a "new" value (vs. a totally different set of values).
Update (4:01 PM 9/19/2016) - This same issue impacts the
res.links
method as well, and has the same odd display as theres.cookie
method.Repro steps:
res.cookie("foo", "bar")
)Expected: To see the cookie as being set from both middleware Actual: Glimpse shows the later middleware as having set the cookie twice, and it crosses out the cookie being set from the previous middleware. Since both cookies are being sent across the wire, I don't know if it makes sense to cross one of them out. And the fact that the later middleware is depicted as having set the cookie twice seems misleading.