Introduces the _withCredentials flag

This introduces the _withCredentials flag and the
corresponding setter to the featureloader.

Co-authored-by: mstenta <mike@mstenta.net>
This commit is contained in:
Kai Volland
2019-09-24 10:31:49 +02:00
parent 4abb9c2fd0
commit 87e63ee4df

View File

@@ -4,6 +4,13 @@
import {VOID} from './functions.js';
import FormatType from './format/FormatType.js';
/**
*
* @type {boolean} withCredentials Compare https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/
* @private
*/
let withCredentials = false;
/**
* {@link module:ol/source/Vector} sources use a function of this type to
* load features.
@@ -62,6 +69,7 @@ export function loadFeaturesXhr(url, format, success, failure) {
if (format.getType() == FormatType.ARRAY_BUFFER) {
xhr.responseType = 'arraybuffer';
}
xhr.withCredentials = withCredentials;
/**
* @param {Event} event Event.
* @private
@@ -131,3 +139,14 @@ export function xhr(url, format) {
}
}, /* FIXME handle error */ VOID);
}
/**
* Setter for the withCredentials configuration for the XHR.
*
* @param {boolean} xhrWithCredentials The value of withCredentials to set.
* Compare https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/
* @api
*/
export function setWithCredentials(xhrWithCredentials) {
withCredentials = xhrWithCredentials;
}