Fix headers set to `undefined` in `init` hooks being sent as the string `"undefined"`
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Headers modified by `init` hooks skip the option merging that filters `undefined` values, and the `Headers` constructor turns `undefined` into the string `'undefined'`, so `options.headers.foo = undefined` in an `init` hook sent `foo: undefined` instead of removing the header. Plain header objects are now applied entry by entry so `undefined` deletes the header, matching the documented behavior for `.extend()`. The check for a user-provided `Content-Type` had the same problem: it built a `Headers` instance from the raw header object, so removing the header in an `init` hook counted as providing one and the JSON body was sent without `application/json`. The check now uses the same header merging as the request.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+98 added−2 removed
- tests:+83 added−1 removed
- other:+15 added−1 removed