nise icon indicating copy to clipboard operation
nise copied to clipboard

Error when setting unsafe headers

Open jeremymeng opened this issue 4 years ago • 3 comments

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

jeremymeng avatar Feb 25 '21 21:02 jeremymeng

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?

mroderick avatar Feb 26 '21 08:02 mroderick

@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.

fatso83 avatar Feb 26 '21 12:02 fatso83

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.

stale[bot] avatar Dec 27 '23 10:12 stale[bot]