-
Notifications
You must be signed in to change notification settings - Fork 300
Description
This is really no biggie since multiple Server-Timing headers are perfectly allowed.
But it could potentially save some bytes in the response.
Rationale
Adding server-timing headers is most commonly done at the code where you have some async code that you want to measure. The user/programmer could ofc use append instead of set already there, but it's easy to forget. Headers could also be added by some dependency, which might introduce multiple headers in the response.
As a very small improvement the mergeHeaders could ensure that all server-timing headers are combined into one.
Appending server-timing headers uses , to join multiple statements since ; is already used within a single value like this: db;desc="get users";dur=250;
The code in question
Lines 142 to 155 in f4dfd79
function mergeHeaders( base: HeadersInit, overrides: Headers, target = new Headers(base), ): Headers { for (const [name, value] of overrides) { if (name === "set-cookie") { target.append(name, value); } else { target.set(name, value); } } return target; }
I'd be happy to provide a PR if this is something that you might agree with 🙏