Give our requests the popular but non-standard X-Requested-With
header (r=crschmidt, closes #3491).
This commit is contained in:
@@ -122,6 +122,25 @@ OpenLayers.Request = {
|
||||
{proxy: OpenLayers.ProxyHost}
|
||||
);
|
||||
config = OpenLayers.Util.applyDefaults(config, defaultConfig);
|
||||
|
||||
// Always set the "X-Requested-With" header to signal that this request
|
||||
// was issued through the XHR-object. Since header keys are case
|
||||
// insensitive and we want to allow overriding of the "X-Requested-With"
|
||||
// header through the user we cannot use applyDefaults, but have to
|
||||
// check manually whether we were called with a "X-Requested-With"
|
||||
// header.
|
||||
var customRequestedWithHeader = false;
|
||||
for(headerKey in config.headers) {
|
||||
if (config.headers.hasOwnProperty( headerKey )) {
|
||||
if (headerKey.toLowerCase() === 'x-requested-with') {
|
||||
customRequestedWithHeader = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (customRequestedWithHeader === false) {
|
||||
// we did not have a custom "X-Requested-With" header
|
||||
config.headers['X-Requested-With'] = 'XMLHttpRequest';
|
||||
}
|
||||
|
||||
// create request, open, and set headers
|
||||
var request = new OpenLayers.Request.XMLHttpRequest();
|
||||
|
||||
Reference in New Issue
Block a user