Skip to content

Commit

Permalink
Merge pull request #18 from kapouer/forbiddenHeaders
Browse files Browse the repository at this point in the history
Per specs, forbid some request headers to be set
  • Loading branch information
ykzts committed Oct 16, 2014
2 parents e23b639 + 7f73611 commit 6be96e0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/xmlhttprequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

var HTTP_STATUS_CODES = require('http').STATUS_CODES;

var forbiddenRequestHeaders = new RegExp('^(' + ["Accept-Charset", "Accept-Encoding", "Access-Control-Request-Headers", "Access-Control-Request-Method", "Connection", "Content-Length", "Cookie", "Cookie2", "Date", "DNT", "Expect", "Host", "Keep-Alive", "Origin", "Referer", "TE", "Trailer", "Transfer-Encoding", "Upgrade", "User-Agent", "Via", "Sec-.*", "Proxy-.*"].join('|') + ')$');

var Event = require('./event');
var ProgressEvent = require('./progressevent');
var XMLHttpRequestEventTarget = require('./xmlhttprequesteventtarget');
Expand Down Expand Up @@ -439,6 +441,7 @@
if (this.readyState === XMLHttpRequest.UNSENT) {
throw new Error(''); // todo
}
if (forbiddenRequestHeaders.test(header)) return;
this._properties.requestHeaders[header] = value;
};
})(XMLHttpRequest.prototype);
Expand Down

0 comments on commit 6be96e0

Please sign in to comment.