Bug 598304 - XHR rewrites non-POST methods upon 301/302 redirects. r=bz

This commit is contained in:
Julian Reschke 2012-02-10 14:12:51 +01:00
parent 491cc37a78
commit c5add5d09a
2 changed files with 13 additions and 14 deletions

View File

@ -1552,14 +1552,13 @@ bool
HttpBaseChannel::ShouldRewriteRedirectToGET(PRUint32 httpStatus,
nsHttpAtom method)
{
// always rewrite for 301 and 302, but see bug 598304
// and RFC 2616, Section 8.3.
// for 301 and 302, only rewrite POST
if (httpStatus == 301 || httpStatus == 302)
return true;
return method == nsHttp::Post;
// always rewrite for 303
// rewrite for 303 unless it was HEAD
if (httpStatus == 303)
return true;
return method != nsHttp::Head;
// otherwise, such as for 307, do not rewrite
return false;

View File

@ -75,23 +75,23 @@ function run_test() {
// same-origin variant
var tests = [
// 301: rewrite just POST
[301, "DELETE", "GET", 200], // but see bug 598304
[301, "DELETE", null, 301],
[301, "GET", "GET", 200],
[301, "HEAD", "GET", 200], // but see bug 598304
[301, "HEAD", "HEAD", 200],
[301, "POST", "GET", 200],
[301, "PUT", "GET", 200], // but see bug 598304
[301, "PROPFIND", "GET", 200], // but see bug 598304
[301, "PUT", null, 301],
[301, "PROPFIND", "PROPFIND", 200],
// 302: see 301
[302, "DELETE", "GET", 200], // but see bug 598304
[302, "DELETE", null, 302],
[302, "GET", "GET", 200],
[302, "HEAD", "GET", 200], // but see bug 598304
[302, "HEAD", "HEAD", 200],
[302, "POST", "GET", 200],
[302, "PUT", "GET", 200], // but see bug 598304
[302, "PROPFIND", "GET", 200], // but see bug 598304
[302, "PUT", null, 302],
[302, "PROPFIND", "PROPFIND", 200],
// 303: rewrite to GET except HEAD
[303, "DELETE", "GET", 200],
[303, "GET", "GET", 200],
[303, "HEAD", "GET", 200],
[303, "HEAD", "HEAD", 200],
[303, "POST", "GET", 200],
[303, "PUT", "GET", 200],
[303, "PROPFIND", "GET", 200],