1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Bye bye syncRequest

This commit is contained in:
Dominik Schmidt
2015-11-19 05:36:05 +01:00
parent 1b4efa8f4a
commit 3db8e91b51

View File

@@ -335,34 +335,6 @@ Tomahawk.valueForSubNode = function (node, tag) {
return element.textContent; return element.textContent;
}; };
/**
* Do a synchronous HTTP(S) request. For further options see
* Tomahawk.asyncRequest
*/
Tomahawk.syncRequest = function (url, extraHeaders, options) {
// unpack options
var opt = options || {};
var method = opt.method || 'GET';
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open(method, url, false, opt.username, opt.password);
if (extraHeaders) {
for (var headerName in extraHeaders) {
xmlHttpRequest.setRequestHeader(headerName, extraHeaders[headerName]);
}
}
xmlHttpRequest.send(null);
if (httpSuccessStatuses.indexOf(xmlHttpRequest.status) != -1) {
return xmlHttpRequest.responseText;
} else {
Tomahawk.log("Failed to do GET request: to: " + url);
Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
if (opt.hasOwnProperty('errorHandler')) {
opt.errorHandler.call(window, xmlHttpRequest);
}
}
};
/** /**
* Internal counter used to identify retrievedMetadata call back from native * Internal counter used to identify retrievedMetadata call back from native
* code. * code.