Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.2.1
-
None
-
Qt 5.2.1 on Linux Mint 16
Description
Doing an XMLHttpRequest to an URL which responds with a 301 Moved Permanently redirect, causes the responseText to be populated with both the content of the redirect page as well as the final result.
import QtQuick 2.2 Item { Component.onCompleted: { var ajax = new XMLHttpRequest ajax.open("get", "http://path/to/the/script/below") ajax.onreadystatechange = function() { if (ajax.readyState === XMLHttpRequest.DONE) { console.log(ajax.responseText) } } ajax.send() } }
Place this on a server and use it in the ajax.open function:
<?php if ($_GET["test"] == "yes") { echo "But this text should"; } else { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $_SERVER["PHP_SELF"] . "?test=yes"); echo "This should not be part of the responseText"; } ?>
The result will be This should not be part of the responseTextBut this text should instead of But this text should.