-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
URI Fragments Cached After 301 Redirect
https://bugs.webkit.org/show_bug.cgi?id=255924 rdar://problem/108535944 Reviewed by Youenn Fablet. We end up reusing the fragments when performing a redirect and as such end up serving old parameters. For now we will just disable caching redirects with fragments. This is a temporary fix; a more proper solution of handling fragment caching in the future is required. * LayoutTests/http/tests/links/redirect-301-clear-memory-cache-expected.txt: Added. * LayoutTests/http/tests/links/redirect-301-clear-memory-cache.html: Added. * LayoutTests/http/tests/links/redirect-301-no-inital-fragments-expected.txt: Added. * LayoutTests/http/tests/links/redirect-301-no-inital-fragments.html: Added. * LayoutTests/http/tests/links/redirect-301-with-fragments-expected.txt: Added. * LayoutTests/http/tests/links/redirect-301-with-fragments.html: Added. * LayoutTests/http/tests/links/resources/redirect-helper.pl: Added. * LayoutTests/http/tests/links/resources/redirect-target.html: Added. * Source/WebCore/loader/cache/CachedResource.cpp: (WebCore::CachedResource::redirectReceived): * Source/WebCore/loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::determineRevalidationPolicy const): * Source/WebCore/loader/cache/CachedResourceRequest.h: (WebCore::CachedResourceRequest::hasFragmentIdentifier const): * Source/WebKit/NetworkProcess/cache/NetworkCache.cpp: (WebKit::NetworkCache::makeUseDecision): (WebKit::NetworkCache::makeStoreDecision): * Source/WebKit/NetworkProcess/cache/NetworkCache.h: Canonical link: https://commits.webkit.org/265906@main
- Loading branch information
Showing
13 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
LayoutTests/http/tests/links/redirect-301-clear-memory-cache-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
PASS: document.getElementById("first_load").contentWindow.location.hash should be #key=foo and is. PASS: document.getElementById("second_load").contentWindow.location.hash should be #key=bar and is. |
44 changes: 44 additions & 0 deletions
44
LayoutTests/http/tests/links/redirect-301-clear-memory-cache.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<html> | ||
<head> | ||
<title>301 Redirect</title> | ||
|
||
<iframe id="first_load" width="200" height="200" src="resources/redirect-helper.pl?301#key=foo"></iframe> | ||
<iframe id="second_load" width="200" height="200"></iframe> | ||
<div id="console"></div> | ||
|
||
<script> | ||
function shouldBe(a, b) | ||
{ | ||
var log = (s) => { document.getElementById("console").appendChild(document.createTextNode(s + "\n")); } | ||
|
||
var evalA = eval(a); | ||
if (evalA == b) | ||
log("PASS: " + a + " should be " + b + " and is.\n", "green"); | ||
else { | ||
log("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red"); | ||
} | ||
} | ||
|
||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
document.getElementById('first_load').onload = function() { | ||
shouldBe('document.getElementById("first_load").contentWindow.location.hash', "#key=foo"); | ||
|
||
// Clear memory cache | ||
internals.clearMemoryCache(); | ||
|
||
document.getElementById('second_load').src = "resources/redirect-helper.pl?301#key=bar" | ||
|
||
document.getElementById('second_load').onload = function() { | ||
shouldBe('document.getElementById("second_load").contentWindow.location.hash', "#key=bar"); | ||
|
||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.notifyDone(); | ||
} | ||
} | ||
} | ||
</script> | ||
</html> |
2 changes: 2 additions & 0 deletions
2
LayoutTests/http/tests/links/redirect-301-no-inital-fragments-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
PASS: document.getElementById("first_load").contentWindow.location.hash should be and is. PASS: document.getElementById("second_load").contentWindow.location.hash should be #key=bar and is. |
41 changes: 41 additions & 0 deletions
41
LayoutTests/http/tests/links/redirect-301-no-inital-fragments.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
<head> | ||
<title>301 Redirect</title> | ||
|
||
<iframe id="first_load" width="200" height="200" src="resources/redirect-helper.pl?301"></iframe> | ||
<iframe id="second_load" width="200" height="200"></iframe> | ||
<div id="console"></div> | ||
|
||
<script> | ||
function shouldBe(a, b) | ||
{ | ||
var log = (s) => { document.getElementById("console").appendChild(document.createTextNode(s + "\n")); } | ||
|
||
var evalA = eval(a); | ||
if (evalA == b) | ||
log("PASS: " + a + " should be " + b + " and is.\n", "green"); | ||
else { | ||
log("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red"); | ||
} | ||
} | ||
|
||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
document.getElementById('first_load').onload = function() { | ||
shouldBe('document.getElementById("first_load").contentWindow.location.hash', ""); | ||
|
||
document.getElementById('second_load').src = "resources/redirect-helper.pl?301#key=bar" | ||
|
||
document.getElementById('second_load').onload = function() { | ||
shouldBe('document.getElementById("second_load").contentWindow.location.hash', "#key=bar"); | ||
|
||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.notifyDone(); | ||
} | ||
} | ||
} | ||
</script> | ||
</html> |
2 changes: 2 additions & 0 deletions
2
LayoutTests/http/tests/links/redirect-301-with-fragments-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
PASS: document.getElementById("first_load").contentWindow.location.hash should be #key=foo and is. PASS: document.getElementById("second_load").contentWindow.location.hash should be #key=bar and is. |
41 changes: 41 additions & 0 deletions
41
LayoutTests/http/tests/links/redirect-301-with-fragments.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
<head> | ||
<title>301 Redirect</title> | ||
|
||
<iframe id="first_load" width="200" height="200" src="resources/redirect-helper.pl?301#key=foo"></iframe> | ||
<iframe id="second_load" width="200" height="200"></iframe> | ||
<div id="console"></div> | ||
|
||
<script> | ||
function shouldBe(a, b) | ||
{ | ||
var log = (s) => { document.getElementById("console").appendChild(document.createTextNode(s + "\n")); } | ||
|
||
var evalA = eval(a); | ||
if (evalA == b) | ||
log("PASS: " + a + " should be " + b + " and is.\n", "green"); | ||
else { | ||
log("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red"); | ||
} | ||
} | ||
|
||
if (window.testRunner) { | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
document.getElementById('first_load').onload = function() { | ||
shouldBe('document.getElementById("first_load").contentWindow.location.hash', "#key=foo"); | ||
|
||
document.getElementById('second_load').src = "resources/redirect-helper.pl?301#key=bar" | ||
|
||
document.getElementById('second_load').onload = function() { | ||
shouldBe('document.getElementById("second_load").contentWindow.location.hash', "#key=bar"); | ||
|
||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.notifyDone(); | ||
} | ||
} | ||
} | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/perl | ||
# Script to generate a 30x HTTP redirect (determined by the query parameter) | ||
|
||
$REDIRECT_CODE = $ENV{'QUERY_STRING'} || '301'; | ||
|
||
$STATUS_TEXTS = { | ||
'301' => 'Moved Permanently', | ||
'302' => 'Moved Temporarily', | ||
'303' => 'See Other', | ||
'307' => 'Moved Temporarily' | ||
}; | ||
|
||
print "Status: $REDIRECT_CODE $STATUS_TEXTS{$REDIRECT_CODE}\r\n"; | ||
print "Location: redirect-target.html\r\n"; | ||
print "Content-type: text/html\r\n"; | ||
print "\r\n"; | ||
|
||
print <<HERE_DOC_END | ||
<html> | ||
<head> | ||
<title>$REDIRECT_CODE Redirect</title> | ||
<body>This page is a $REDIRECT_CODE redirect.</body> | ||
</html> | ||
HERE_DOC_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<head> | ||
<title>Redirect Target</title> | ||
<body> | ||
<p>This page is the target of a redirect.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters