Use GET method for redirect in QDeclarativeXMLHttpRequest.
authorFriedemann Kleint <Friedemann.Kleint@digia.com>
Thu, 18 Jul 2013 08:29:17 +0000 (10:29 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 22 Jul 2013 09:24:02 +0000 (11:24 +0200)
Initial-patch-by: Marek WiÄ™ckowski <wiecko@fuw.edu.pl>

Task-number: QTBUG-32332
Change-Id: I5514d97ef8574f8e7eef8fcca39bed4cd7e917ad
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>

src/qml/qml/qqmlxmlhttprequest.cpp

index 4fa9869..f13b240 100644 (file)
@@ -1339,6 +1339,11 @@ void QQmlXMLHttpRequest::finished()
         if (redirect.isValid()) {
             QUrl url = m_network->url().resolved(redirect.toUrl());
             if (url.scheme() != QLatin1String("file")) {
+                // See http://www.ietf.org/rfc/rfc2616.txt, section 10.3.4 "303 See Other":
+                // Result of 303 redirection should be a new "GET" request.
+                const QVariant code = m_network->attribute(QNetworkRequest::HttpStatusCodeAttribute);
+                if (code.isValid() && code.toInt() == 303 && m_method != QLatin1String("GET"))
+                    m_method = QStringLiteral("GET");
                 destroyNetwork();
                 requestFromUrl(url);
                 return;