Skip to content

Wrong header instance #416

Closed
Closed

Description

@jimmywarting

Found this minor issue while testing

Chrome

h = new Headers({'x-foo': 'x-bar'})
res = new Response('x', {headers: h})

console.log(h === res.headers) // false

Polyfill

h = new Headers({'x-foo': 'x-bar'})
res = new Response('x', {headers: h})

console.log(h === res.headers) // true

Maybe it should be simplified from:

this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers)

To just:

this.headers = new Headers(options.headers || {})

Activity

  1. jimmywarting commented on Oct 22, 2016

    @jimmywarting
    Author

    test:

      // #416
      test('creates a new instanceof headers when constructing', function() {
        var h = new Headers({'x-foo': 'x-bar'})
        var res = new Response('x', {headers: h})
    
        assert.equal(h === res.headers, false)
      })
  2. locked as resolved and limited conversation to collaborators on Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions