Bug 1443942 - Make redirect SJS' serve with headers to prevent Necko caching. r=jya

Try to prevent Necko from caching the results of our SJS media responses, as
some of the test that use it rely on the server being hit and serving a
redirect. Sometimes the tests which rely on hitting a redirect in an SJS
where timing out without this, as Necko would cache the response and not
hit the server, and so not hit the redirect.

Also include a noise parameter to increase the likelihood that the URL is
unique, to further reduce the chance that Necko caches the result.

MozReview-Commit-ID: 3cLEiDoh4HG

--HG--
extra : rebase_source : 24c152d46540866f14211fae30f1e59c5d23b6d4
This commit is contained in:
Chris Pearce 2018-03-28 16:55:46 +13:00
Родитель 99ff9f62be
Коммит 5913d0470e
3 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -63,6 +63,7 @@ function handleRequest(request, response)
response.setHeader("Content-Length", contentLength, false);
response.setHeader("Content-Type", type, false);
response.setHeader("Accept-Ranges", "bytes", false);
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.write(byterange, byterange.length);
bis.close();
}

Просмотреть файл

@ -64,6 +64,7 @@ function handleRequest(request, response)
response.setHeader("Content-Length", contentLength, false);
response.setHeader("Content-Type", type, false);
response.setHeader("Accept-Ranges", "bytes", false);
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
if (redirected && useCors) {
response.setHeader("Access-Control-Allow-Origin", "*");
}

Просмотреть файл

@ -41,9 +41,11 @@
removeNodeAndSource(element);
}, false);
var noise = Math.floor(Math.random() * 100000000);
element.src = "midflight-redirect.sjs?resource=" + test.name
+ (useCors ? "&cors" : "")
+ "&type=" + test.type;
+ "&type=" + test.type
+ "&noise=" + noise;
element.preload = "metadata";
document.body.appendChild(element);
element.load()