sinonjs / nise

Fake XHR and fake server
Other
109 stars 47 forks source link

Error when setting unsafe headers #177

Open jeremymeng opened 3 years ago

jeremymeng commented 3 years ago

We have code that works in live mode using xhr, but fails using mock.

https://github.com/sinonjs/nise/blob/805200b70084b1c19569ad0c04158da7bf5eed0c/lib/fake-xhr/index.js#L590

according to the spec, setting/deleting a forbidden header should be a no-op

Otherwise, if this’s guard is "request" and name is a forbidden header name, return.

image

mroderick commented 3 years ago

according to the spec, setting/deleting a forbidden header should be a no-op

That's the spec for fetch. This library does not deal with fetch.

What is expected to happend for XHR?

fatso83 commented 3 years ago

@mroderick The spec for XHR says pretty much the same thing.

  1. If this’s state is not opened, then throw an "InvalidStateError" DOMException.

  2. If this’s send() flag is set, then throw an "InvalidStateError" DOMException.

  3. Normalize value.

  4. If name is not a name or value is not a value, then throw a "SyntaxError" DOMException.

    An empty byte sequence represents an empty header value.

  5. If name is a forbidden header name, then return.

  6. Combine name/value in this’s author request headers.

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.