Skip to content

Change Headers multiple value handling for spec compatibility - #429

Merged
mislav merged 2 commits into
JakeChampion:masterfrom
mislav:headers-spec-compat
Nov 14, 2016
Merged

mislav merged 2 commits into
JakeChampion:masterfrom
mislav:headers-spec-compat

Conversation

@mislav

@mislav mislav commented Nov 10, 2016 •

Copy link
Copy Markdown
Contributor

Consider this Headers object:

var h = new Headers()
h.append('accept', 'text/html')
h.append('accept', 'text/plain')
h.append('content-type', 'application/json')

Before:

  • h.get('accept') returned text/html
  • h.getAll('accept') returned an array of values
  • h.forEach (and other iterables) did distinct iterations for each value of the same header

Now:

  • h.get('accept') returns text/html,text/plain
  • h.getAll() is no more
  • h.forEach (and other iterables) now only do one iteration for each headers name, regardless of multiple values

This is in accordance with Section 3.1.2 of the spec, "combine" concept. whatwg/fetch@42464c8

The updated tests currently break in Chrome and Firefox when exercising the native implementation because their implementation is outdated. The implementation in Edge is more correct, but the tests still fail there because its implementation combines values with , (notice the space) rather than ,.

Consider this Headers object:

    var h = new Headers()
    h.append('accept', 'text/html')
    h.append('accept', 'text/plain')
    h.append('content-type', 'application/json')

Before:

- `h.get('accept')` returned `text/html`
- `h.getAll('accept')` returned an array of values
- `h.forEach` (and other iterables) did distinct iterations for each
  value of the same header

Now:

- `h.get('accept')` returns `text/html,text/plain`
- `h.getAll()` is no more
- `h.forEach` (and other iterables) now only do one iteration for each
  headers name, regardless of multiple values

This is in accordance with Section 3.1.2 of the spec, "combine" concept.

The updated tests currently break in Chrome and Firefox when exercising
the native implementation because their implementation is outdated. The
implementation in Edge is more correct, but the tests still fail there
because its implementation combines values with `, ` (notice the space)
rather than `,`.
@mislav
mislav merged commit fc226e8 into JakeChampion:master Nov 14, 2016
@mislav
mislav deleted the headers-spec-compat branch November 14, 2016 19:41
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant