Commit d6d5fa0f authored by Matthew Taylor's avatar Matthew Taylor

Make `X-Requested-With` overridable

thanks @rschamp!
parent 4dc85b1b
...@@ -22,6 +22,12 @@ module.exports = function (opts, callback) { ...@@ -22,6 +22,12 @@ module.exports = function (opts, callback) {
useCsrf: false useCsrf: false
}); });
if (opts.host === '') {
defaults(opts.headers, {
'X-Requested-With': 'XMLHttpRequest'
});
}
opts.uri = opts.host + opts.uri; opts.uri = opts.host + opts.uri;
if (opts.params) { if (opts.params) {
...@@ -49,8 +55,6 @@ module.exports = function (opts, callback) { ...@@ -49,8 +55,6 @@ module.exports = function (opts, callback) {
opts.uri = parts[0] + '?' + qs; opts.uri = parts[0] + '?' + qs;
} }
} else {
opts['X-Requested-With'] = 'XMLHttpRequest';
} }
xhr(opts, function (err, res, body) { xhr(opts, function (err, res, body) {
if (err) log.error(err); if (err) log.error(err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment