Repository navigation
Follow spec on Headers to throw TypeError, add tests for Headers - #85
Conversation
|
Chrome and Firefox nightlies currently accept non-String keys and values: h = new Headers()
h.append(12, 42)
// => undefined
h.has(12)
// => true@annevk Is this correct behavior, or should a |
|
The spec says to convert to string, not to throw. |
|
Ah interesting, these body tests maybe wrong too https://github.com/github/fetch/blob/c3fc0d43a058944988eebb61b67c8a6549efcc9b/test/test.js#L385-L401 |
|
Yes, they definitely are. |
|
According to this it should throw TypeError https://fetch.spec.whatwg.org/#headers-class |
|
Which step? |
|
Example: To append a name/value (name/value) pair to a Headers object (headers), run these steps: It's listed under each method definition. |
|
Right, so you should be testing whether they match https://tools.ietf.org/html/rfc2616#section-4.2, not doing a type-test. They're already converted to strings since the method signature contains ByteString/DOMString/USVString (depending on the method). |
|
It's not clear to me what it should match based on the RFC, any ideas? Or is this check not really necessary? |
|
@dgraham that might not necessarily be a bug if both methods stringify. If the value of "12" is not a string you found a bug. |
|
@MattKing17 you quoted
The "name" link says
The "field-name" link links to the RFC which defines |
|
Thanks @domenic, that makes sense now. Updated the PR with field name checks to match the RFC, and removed string type checking and put in |
|
Let me know if there's anything else that this PR needs, more than happy to make necessary changes. |
|
@MattKing17 looks good. I'll get to testing and merging today. Thanks so much! β€οΈ |
Follow spec on Headers to throw TypeError, add tests for Headers

No description provided.