mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-13 04:21:51 +02:00
Follow all the redirects
This commit is contained in:
parent
a26893339b
commit
c0b6785bde
@ -268,6 +268,15 @@ Tomahawk.syncRequest = function (url, extraHeaders, options) {
|
||||
xmlHttpRequest.send(null);
|
||||
if (xmlHttpRequest.status == 200) {
|
||||
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 {
|
||||
Tomahawk.log("Failed to do GET request: to: " + url);
|
||||
Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
|
||||
@ -300,6 +309,15 @@ Tomahawk.asyncRequest = function (url, callback, extraHeaders, options) {
|
||||
xmlHttpRequest.onreadystatechange = function () {
|
||||
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
|
||||
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) {
|
||||
Tomahawk.log("Failed to do " + method + " request: to: " + url);
|
||||
Tomahawk.log("Status Code was: " + xmlHttpRequest.status);
|
||||
|
Loading…
x
Reference in New Issue
Block a user