The XHRLoader will now return a fake XHR result object containing the decoded base64 data if a base64 file is detected, skipping the creation of a real XML Http Request object.

This commit is contained in:
Richard Davey 2024-02-01 19:22:54 +00:00
parent aa0d60786f
commit 324dcfba97

View file

@ -17,12 +17,25 @@ var MergeXHRSettings = require('./MergeXHRSettings');
* @param {Phaser.Loader.File} file - The File to download.
* @param {Phaser.Types.Loader.XHRSettingsObject} globalXHRSettings - The global XHRSettings object.
*
* @return {XMLHttpRequest} The XHR object.
* @return {XMLHttpRequest} The XHR object, or a FakeXHR Object in the base of base64 data.
*/
var XHRLoader = function (file, globalXHRSettings)
{
var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings);
if (file.base64)
{
var base64Data = file.url.split(';base64,').pop() || file.url.split(',').pop();
var fakeXHR = {
responseText: atob(base64Data)
};
file.onBase64Load(fakeXHR);
return;
}
var xhr = new XMLHttpRequest();
xhr.open('GET', file.src, config.async, config.user, config.password);