jameslnewell / xhr-mock

Utility for mocking XMLHttpRequest.
196 stars 48 forks source link

Request headers are not reset between .open() calls #116

Open public opened 1 year ago

public commented 1 year ago

In a real XHR, if you do something like

xhr.open(...);
xhr.setRequestHeader('foo', 'bar');
xhr.open(...);
xhr.send();

The request will not be sent with a foo header because the second open() call resets them.

It seems like the code in MockXMLHttpRequest is intending to do this but the implementation of req.headers() doesn't seem to be capable of actually removing existing headers this way.