COMMIT_MESSAGE

 1[Qt] Redirection of HTTP POST (3xx) incorrectly includes original POST data
 2https://bugs.webkit.org/show_bug.cgi?id=60440
 3
 4Reviewed by NOBODY (OOPS!).
 5
 6Source/WebCore:
 7
 8 Makes sure that the HTTP headers Content-type and Content-length are not included in
 9 the requests that do not have any content.
 10
 11Tests: http/tests/navigation/post-301-response.html
 12 http/tests/navigation/post-302-response.html
 13 http/tests/navigation/post-303-response.html
 14 http/tests/navigation/post-307-response.html
 15
 16* platform/network/qt/QNetworkReplyHandler.cpp:
 17(WebCore::QNetworkReplyHandler::sendNetworkRequest):
 18
 19LayoutTests:
 20
 21These new tests check that no POST content is sent to the new URL after receiving http
 22status codes 301, 302 and 303, and checks that the POST content is sent to the new URL
 23after receiving a 307 http status code.
 24
 25* http/tests/navigation/post-301-response-expected.txt: Added.
 26* http/tests/navigation/post-301-response.html: Added.
 27* http/tests/navigation/post-302-response-expected.txt: Added.
 28* http/tests/navigation/post-302-response.html: Added.
 29* http/tests/navigation/post-303-response-expected.txt: Added.
 30* http/tests/navigation/post-303-response.html: Added.
 31* http/tests/navigation/post-307-response-expected.txt: Added.
 32* http/tests/navigation/post-307-response.html: Added.
 33* http/tests/navigation/resources/redirected-post-request-contents.php: Added.
 34* http/tests/navigation/resources/redirection-response.php: Added.

LayoutTests/ChangeLog

 12011-05-09 Luiz Agostini <luiz.agostini@openbossa.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 [Qt] Redirection of HTTP POST (3xx) incorrectly includes original POST data
 6 https://bugs.webkit.org/show_bug.cgi?id=60440
 7
 8 These new tests check that no POST content is sent to the new URL after receiving http
 9 status codes 301, 302 and 303, and checks that the POST content is sent to the new URL
 10 after receiving a 307 http status code.
 11
 12 * http/tests/navigation/post-301-response-expected.txt: Added.
 13 * http/tests/navigation/post-301-response.html: Added.
 14 * http/tests/navigation/post-302-response-expected.txt: Added.
 15 * http/tests/navigation/post-302-response.html: Added.
 16 * http/tests/navigation/post-303-response-expected.txt: Added.
 17 * http/tests/navigation/post-303-response.html: Added.
 18 * http/tests/navigation/post-307-response-expected.txt: Added.
 19 * http/tests/navigation/post-307-response.html: Added.
 20 * http/tests/navigation/resources/redirected-post-request-contents.php: Added.
 21 * http/tests/navigation/resources/redirection-response.php: Added.
 22
1232011-05-08 Jeremy Noble <jer.noble@apple.com>
224
325 Reviewed by Dan Bernstein.

LayoutTests/http/tests/navigation/post-301-response-expected.txt

 1headers CONTENT_TYPE and CONTENT_LENGTH should not be present.
 2headers CONTENT_TYPE and CONTENT_LENGTH are not present.
 3
 4
 5
 6no POST data should be present.
 7no POST data is present.
 8

LayoutTests/http/tests/navigation/post-301-response.html

 1<html>
 2<head>
 3<script>
 4var doTest = function () {
 5 if (window.layoutTestController) {
 6 window.layoutTestController.dumpAsText();
 7 window.layoutTestController.waitUntilDone();
 8 }
 9 document.getElementById("form1").submit();
 10};
 11</script>
 12</head>
 13<body onload="doTest()">
 14<form id="form1" action="resources/redirection-response.php?status=301&target=redirected-post-request-contents.php?content=false" method="post">
 15<input type="text" name="text1" value="some text"><br>
 16</form>
 17</body>
 18</html>

LayoutTests/http/tests/navigation/post-302-response-expected.txt

 1headers CONTENT_TYPE and CONTENT_LENGTH should not be present.
 2headers CONTENT_TYPE and CONTENT_LENGTH are not present.
 3
 4
 5
 6no POST data should be present.
 7no POST data is present.
 8

LayoutTests/http/tests/navigation/post-302-response.html

 1<html>
 2<head>
 3<script>
 4var doTest = function () {
 5 if (window.layoutTestController) {
 6 window.layoutTestController.dumpAsText();
 7 window.layoutTestController.waitUntilDone();
 8 }
 9 document.getElementById("form1").submit();
 10};
 11</script>
 12</head>
 13<body onload="doTest()">
 14<form id="form1" action="resources/redirection-response.php?status=302&target=redirected-post-request-contents.php?content=false" method="post">
 15<input type="text" name="text1" value="some text"><br>
 16</form>
 17</body>
 18</html>

LayoutTests/http/tests/navigation/post-303-response-expected.txt

 1headers CONTENT_TYPE and CONTENT_LENGTH should not be present.
 2headers CONTENT_TYPE and CONTENT_LENGTH are not present.
 3
 4
 5
 6no POST data should be present.
 7no POST data is present.
 8

LayoutTests/http/tests/navigation/post-303-response.html

 1<html>
 2<head>
 3<script>
 4var doTest = function () {
 5 if (window.layoutTestController) {
 6 window.layoutTestController.dumpAsText();
 7 window.layoutTestController.waitUntilDone();
 8 }
 9 document.getElementById("form1").submit();
 10};
 11</script>
 12</head>
 13<body onload="doTest()">
 14<form id="form1" action="resources/redirection-response.php?status=303&target=redirected-post-request-contents.php?content=false" method="post">
 15<input type="text" name="text1" value="some text"><br>
 16</form>
 17</body>
 18</html>

LayoutTests/http/tests/navigation/post-307-response-expected.txt

 1headers CONTENT_TYPE and CONTENT_LENGTH should be present.
 2CONTENT_TYPE is present. its value is: application/x-www-form-urlencoded
 3CONTENT_LENGTH is present. its value is: 15
 4
 5
 6
 7POST data should be present.
 8POST data is present.
 9

LayoutTests/http/tests/navigation/post-307-response.html

 1<html>
 2<head>
 3<script>
 4var doTest = function () {
 5 if (window.layoutTestController) {
 6 window.layoutTestController.dumpAsText();
 7 window.layoutTestController.waitUntilDone();
 8 }
 9 document.getElementById("form1").submit();
 10};
 11</script>
 12</head>
 13<body onload="doTest()">
 14<form id="form1" action="resources/redirection-response.php?status=307&target=redirected-post-request-contents.php?content=true" method="post">
 15<input type="text" name="text1" value="some text"><br>
 16</form>
 17</body>
 18</html>

LayoutTests/http/tests/navigation/resources/redirected-post-request-contents.php

 1<?php
 2function checkHeader($header) {
 3 if (array_key_exists($header, $_SERVER)) {
 4 echo $header . " is present. its value is: " . $_SERVER[$header] . "<br>";
 5 return true;
 6 }
 7 return false;
 8}
 9
 10if ($_GET["content"] == "true") {
 11 echo "headers CONTENT_TYPE and CONTENT_LENGTH should be present.<br>";
 12} else {
 13 echo "headers CONTENT_TYPE and CONTENT_LENGTH should not be present.<br>";
 14}
 15
 16$content_type = checkHeader("CONTENT_TYPE");
 17$content_length = checkHeader("CONTENT_LENGTH");
 18
 19if (!$content_type && !$content_length) {
 20 echo "headers CONTENT_TYPE and CONTENT_LENGTH are not present.<br>";
 21}
 22
 23echo "<br><br><br>";
 24
 25if ($_GET["content"] == "true") {
 26 echo "POST data should be present.<br>";
 27} else {
 28 echo "no POST data should be present.<br>";
 29}
 30
 31if (sizeof($_POST) > 0 || sizeof($_FILES) > 0) {
 32 echo "POST data is present.<br>";
 33} else {
 34 echo "no POST data is present.<br>";
 35}
 36
 37echo "<script>if (window.layoutTestController) layoutTestController.notifyDone();</script>"
 38?>

LayoutTests/http/tests/navigation/resources/redirection-response.php

 1<?php
 2$status_code = $_GET['status'];
 3
 4$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/" . $_GET['target'];
 5
 6switch ($status_code) {
 7 case 301:
 8 header("HTTP/1.1 301 Moved Permanently");
 9 header("Location: http://" . $_SERVER['HTTP_HOST'] . $uri);
 10 break;
 11 case 302:
 12 header("HTTP/1.1 302 Found");
 13 header("Location: http://" . $_SERVER['HTTP_HOST'] . $uri);
 14 break;
 15 case 303:
 16 header("HTTP/1.1 303 See Other");
 17 header("Location: http://" . $_SERVER['HTTP_HOST'] . $uri);
 18 break;
 19 case 307:
 20 header("HTTP/1.1 307 Temporary Redirect");
 21 header("Location: http://" . $_SERVER['HTTP_HOST'] . $uri);
 22 break;
 23 default:
 24 header("HTTP/1.1 404 Not Found");
 25 echo "Unexpected status code ($status_code) received.";
 26}
 27?>

Source/WebCore/ChangeLog

 12011-05-09 Luiz Agostini <luiz.agostini@openbossa.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 [Qt] Redirection of HTTP POST (3xx) incorrectly includes original POST data
 6 https://bugs.webkit.org/show_bug.cgi?id=60440
 7
 8 Makes sure that the HTTP headers Content-type and Content-length are not included in
 9 the requests that do not have any content.
 10
 11 Tests: http/tests/navigation/post-301-response.html
 12 http/tests/navigation/post-302-response.html
 13 http/tests/navigation/post-303-response.html
 14 http/tests/navigation/post-307-response.html
 15
 16 * platform/network/qt/QNetworkReplyHandler.cpp:
 17 (WebCore::QNetworkReplyHandler::sendNetworkRequest):
 18
1192011-05-08 Jeremy Noble <jer.noble@apple.com>
220
321 Reviewed by Dan Bernstein.

Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp

@@QNetworkReply* QNetworkReplyHandler::sendNetworkRequest(QNetworkAccessManager* m
615615 && (!url.toLocalFile().isEmpty() || url.scheme() == QLatin1String("data")))
616616 m_method = QNetworkAccessManager::GetOperation;
617617
 618 if (m_method != QNetworkAccessManager::PostOperation && m_method != QNetworkAccessManager::PutOperation) {
 619 m_request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant());
 620 m_request.setHeader(QNetworkRequest::ContentLengthHeader, QVariant());
 621 }
 622
618623 switch (m_method) {
619624 case QNetworkAccessManager::GetOperation:
620625 return manager->get(m_request);