mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 23:57:34 +02:00
Remove follow redirects hack
If we really reach a 302 code in (a)syncRequest this is due not being given a Location header by the server. This is not an expected behaviour but an actual error state.
This commit is contained in:
@@ -268,15 +268,6 @@ Tomahawk.syncRequest = function (url, extraHeaders, options) {
|
|||||||
xmlHttpRequest.send(null);
|
xmlHttpRequest.send(null);
|
||||||
if (xmlHttpRequest.status == 200) {
|
if (xmlHttpRequest.status == 200) {
|
||||||
return xmlHttpRequest.responseText;
|
return xmlHttpRequest.responseText;
|
||||||
} else if (xmlHttpRequest.status == 302) {
|
|
||||||
// You know that XMLHttpRequest always follows redirects?
|
|
||||||
// Guess what: It does not always.
|
|
||||||
//
|
|
||||||
// Known:
|
|
||||||
// * If you are redirect to a different domain in QtWebkit on MacOS,
|
|
||||||
// you will have to deal with 302.
|
|
||||||
Tomahawk.syncRequest(xmlHttpRequest.getResponseHeader('Location'),
|
|
||||||
extraHeaders, options);
|
|
||||||
} else {
|
} else {
|
||||||
Tomahawk.log("Failed to do GET request: to: " + url);
|
Tomahawk.log("Failed to do GET request: to: " + url);
|
||||||
Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
|
Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
|
||||||
@@ -309,15 +300,6 @@ Tomahawk.asyncRequest = function (url, callback, extraHeaders, options) {
|
|||||||
xmlHttpRequest.onreadystatechange = function () {
|
xmlHttpRequest.onreadystatechange = function () {
|
||||||
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
|
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
|
||||||
callback.call(window, xmlHttpRequest);
|
callback.call(window, xmlHttpRequest);
|
||||||
} else if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 302) {
|
|
||||||
// You know that XMLHttpRequest always follows redirects?
|
|
||||||
// Guess what: It does not always.
|
|
||||||
//
|
|
||||||
// Known:
|
|
||||||
// * If you are redirect to a different domain in QtWebkit on MacOS,
|
|
||||||
// you will have to deal with 302.
|
|
||||||
Tomahawk.asyncRequest(xmlHttpRequest.getResponseHeader('Location'),
|
|
||||||
callback, extraHeaders, options);
|
|
||||||
} else if (xmlHttpRequest.readyState === 4) {
|
} else if (xmlHttpRequest.readyState === 4) {
|
||||||
Tomahawk.log("Failed to do " + method + " request: to: " + url);
|
Tomahawk.log("Failed to do " + method + " request: to: " + url);
|
||||||
Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
|
Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
|
||||||
|
Reference in New Issue
Block a user