зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1004104 - Disable caching when running netmonitor tests to hopefully fix some timeouts, r=dcamp
This commit is contained in:
Родитель
ac0a685723
Коммит
848356e329
|
@ -39,8 +39,9 @@ function test() {
|
|||
'-H "Connection: keep-alive"'
|
||||
].join(" ");
|
||||
|
||||
const EXPECTED_RESULT = Services.appinfo.OS == "WINNT" ?
|
||||
EXPECTED_WIN_RESULT : EXPECTED_POSIX_RESULT;
|
||||
const EXPECTED_RESULT = Services.appinfo.OS == "WINNT"
|
||||
? EXPECTED_WIN_RESULT
|
||||
: EXPECTED_POSIX_RESULT;
|
||||
|
||||
let { NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
|
|
@ -31,7 +31,7 @@ function test() {
|
|||
waitFor(aMonitor.panelWin, RESPONSE_BODY_DISPLAYED).then(() =>
|
||||
NetMonitorView.editor("#response-content-textarea")
|
||||
).then((aEditor) => {
|
||||
is(aEditor.getText().indexOf("\u044F"), 302, // я
|
||||
is(aEditor.getText().indexOf("\u044F"), 486, // я
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
|
|
@ -86,10 +86,8 @@ function test() {
|
|||
|
||||
ok(requestItem.attachment.requestHeaders,
|
||||
"There should be a requestHeaders attachment available.");
|
||||
ok(requestItem.attachment.requestHeaders.headers.length >= 6,
|
||||
is(requestItem.attachment.requestHeaders.headers.length, 8,
|
||||
"The requestHeaders attachment has an incorrect |headers| property.");
|
||||
// Can't test for an exact total number of headers, because it seems to
|
||||
// vary across pgo/non-pgo builds.
|
||||
isnot(requestItem.attachment.requestHeaders.headersSize, 0,
|
||||
"The requestHeaders attachment has an incorrect |headersSize| property.");
|
||||
// Can't test for the exact request headers size because the value may
|
||||
|
@ -118,9 +116,9 @@ function test() {
|
|||
|
||||
ok(requestItem.attachment.responseHeaders,
|
||||
"There should be a responseHeaders attachment available.");
|
||||
is(requestItem.attachment.responseHeaders.headers.length, 6,
|
||||
is(requestItem.attachment.responseHeaders.headers.length, 9,
|
||||
"The responseHeaders attachment has an incorrect |headers| property.");
|
||||
is(requestItem.attachment.responseHeaders.headersSize, 173,
|
||||
is(requestItem.attachment.responseHeaders.headersSize, 255,
|
||||
"The responseHeaders attachment has an incorrect |headersSize| property.");
|
||||
|
||||
verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS);
|
||||
|
@ -146,7 +144,7 @@ function test() {
|
|||
"The status attachment has an incorrect value.");
|
||||
is(requestItem.attachment.statusText, "Och Aye",
|
||||
"The statusText attachment has an incorrect value.");
|
||||
is(requestItem.attachment.headersSize, 173,
|
||||
is(requestItem.attachment.headersSize, 255,
|
||||
"The headersSize attachment has an incorrect value.");
|
||||
|
||||
verifyRequestItemTarget(requestItem, "GET", SIMPLE_SJS, {
|
||||
|
|
|
@ -63,10 +63,8 @@ function test() {
|
|||
|
||||
is(tabpanel.querySelectorAll(".variables-view-scope").length, 2,
|
||||
"There should be 2 header scopes displayed in this tabpanel.");
|
||||
ok(tabpanel.querySelectorAll(".variable-or-property").length >= 12,
|
||||
"There should be at least 12 header values displayed in this tabpanel.");
|
||||
// Can't test for an exact total number of headers, because it seems to
|
||||
// vary across pgo/non-pgo builds.
|
||||
is(tabpanel.querySelectorAll(".variable-or-property").length, 17,
|
||||
"There should be 17 header values displayed in this tabpanel.");
|
||||
|
||||
is(tabpanel.querySelectorAll(".variables-view-empty-notice").length, 0,
|
||||
"The empty notice should not be displayed in this tabpanel.");
|
||||
|
@ -76,7 +74,7 @@ function test() {
|
|||
|
||||
is(responseScope.querySelector(".name").getAttribute("value"),
|
||||
L10N.getStr("responseHeaders") + " (" +
|
||||
L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(173/1024, 3)) + ")",
|
||||
L10N.getFormatStr("networkMenu.sizeKB", L10N.numberWithDecimals(255/1024, 3)) + ")",
|
||||
"The response headers scope doesn't have the correct title.");
|
||||
|
||||
ok(requestScope.querySelector(".name").getAttribute("value").contains(
|
||||
|
@ -87,20 +85,24 @@ function test() {
|
|||
// sure it's smaller than 1 MB though, so it starts with a 0.
|
||||
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
"Connection", "The first response header name was incorrect.");
|
||||
"Cache-Control", "The first response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"close\"", "The first response header value was incorrect.");
|
||||
"\"no-cache, no-store, must-revalidate\"", "The first response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[1].getAttribute("value"),
|
||||
"Content-Length", "The second response header name was incorrect.");
|
||||
"Connection", "The second response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[1].getAttribute("value"),
|
||||
"\"12\"", "The second response header value was incorrect.");
|
||||
"\"close\"", "The second response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[2].getAttribute("value"),
|
||||
"Content-Type", "The third response header name was incorrect.");
|
||||
"Content-Length", "The third response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[2].getAttribute("value"),
|
||||
"\"text/plain; charset=utf-8\"", "The third response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[5].getAttribute("value"),
|
||||
"\"12\"", "The third response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[3].getAttribute("value"),
|
||||
"Content-Type", "The fourth response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[3].getAttribute("value"),
|
||||
"\"text/plain; charset=utf-8\"", "The fourth response header value was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .name")[8].getAttribute("value"),
|
||||
"foo-bar", "The last response header name was incorrect.");
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[5].getAttribute("value"),
|
||||
is(responseScope.querySelectorAll(".variables-view-variable .value")[8].getAttribute("value"),
|
||||
"\"baz\"", "The last response header value was incorrect.");
|
||||
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[0].getAttribute("value"),
|
||||
|
@ -108,21 +110,17 @@ function test() {
|
|||
is(requestScope.querySelectorAll(".variables-view-variable .value")[0].getAttribute("value"),
|
||||
"\"example.com\"", "The first request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[5].getAttribute("value"),
|
||||
"Connection", "The penultimate request header name was incorrect.");
|
||||
"Connection", "The ante-penultimate request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[5].getAttribute("value"),
|
||||
"\"keep-alive\"", "The penultimate request header value was incorrect.");
|
||||
|
||||
let lastReqHeaderName = requestScope.querySelectorAll(".variables-view-variable .name")[6];
|
||||
let lastReqHeaderValue = requestScope.querySelectorAll(".variables-view-variable .value")[6];
|
||||
if (lastReqHeaderName && lastReqHeaderValue) {
|
||||
is(lastReqHeaderName.getAttribute("value"),
|
||||
"Cache-Control", "The last request header name was incorrect.");
|
||||
is(lastReqHeaderValue.getAttribute("value"),
|
||||
"\"max-age=0\"", "The last request header value was incorrect.");
|
||||
} else {
|
||||
info("The number of request headers was 6 instead of 7. Technically, " +
|
||||
"not a failure in this particular test, but needs investigation.");
|
||||
}
|
||||
"\"keep-alive\"", "The ante-penultimate request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[6].getAttribute("value"),
|
||||
"Pragma", "The penultimate request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[6].getAttribute("value"),
|
||||
"\"no-cache\"", "The penultimate request header value was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .name")[7].getAttribute("value"),
|
||||
"Cache-Control", "The last request header name was incorrect.");
|
||||
is(requestScope.querySelectorAll(".variables-view-variable .value")[7].getAttribute("value"),
|
||||
"\"no-cache\"", "The last request header value was incorrect.");
|
||||
}
|
||||
|
||||
function testCookiesTab() {
|
||||
|
|
|
@ -97,24 +97,49 @@ function removeTab(aTab, aWindow) {
|
|||
targetBrowser.removeTab(aTab);
|
||||
}
|
||||
|
||||
function waitForNavigation(aTarget) {
|
||||
let deferred = promise.defer();
|
||||
aTarget.once("will-navigate", () => {
|
||||
aTarget.once("navigate", () => {
|
||||
deferred.resolve();
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function reconfigureTab(aTarget, aOptions) {
|
||||
let deferred = promise.defer();
|
||||
aTarget.activeTab.reconfigure(aOptions, deferred.resolve);
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
function toggleCache(aTarget, aEnabled) {
|
||||
let options = { cacheEnabled: aEnabled, performReload: true };
|
||||
let navigationFinished = waitForNavigation(aTarget);
|
||||
return reconfigureTab(aTarget, options).then(() => navigationFinished);
|
||||
}
|
||||
|
||||
function initNetMonitor(aUrl, aWindow) {
|
||||
info("Initializing a network monitor pane.");
|
||||
|
||||
return addTab(aUrl).then((aTab) => {
|
||||
return Task.spawn(function*() {
|
||||
let tab = yield addTab(aUrl);
|
||||
info("Net tab added successfully: " + aUrl);
|
||||
|
||||
let deferred = promise.defer();
|
||||
let debuggee = aTab.linkedBrowser.contentWindow.wrappedJSObject;
|
||||
let target = TargetFactory.forTab(aTab);
|
||||
let debuggee = tab.linkedBrowser.contentWindow.wrappedJSObject;
|
||||
let target = TargetFactory.forTab(tab);
|
||||
|
||||
gDevTools.showToolbox(target, "netmonitor").then((aToolbox) => {
|
||||
info("Netork monitor pane shown successfully.");
|
||||
yield target.makeRemote();
|
||||
info("Target remoted.");
|
||||
|
||||
let monitor = aToolbox.getCurrentPanel();
|
||||
deferred.resolve([aTab, debuggee, monitor]);
|
||||
});
|
||||
yield toggleCache(target, false);
|
||||
info("Network cache disabled");
|
||||
|
||||
return deferred.promise;
|
||||
let toolbox = yield gDevTools.showToolbox(target, "netmonitor");
|
||||
info("Netork monitor pane shown successfully.");
|
||||
|
||||
let monitor = toolbox.getCurrentPanel();
|
||||
return [tab, debuggee, monitor];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
<style>
|
||||
input {
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
@ -25,8 +28,7 @@
|
|||
}
|
||||
|
||||
(function performRequests() {
|
||||
get("request_0", function() {
|
||||
});
|
||||
get("request_0", function() {});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
@ -30,7 +33,7 @@
|
|||
get("sjs_content-type-test-server.sjs?sts=304&fmt=audio");
|
||||
get("sjs_content-type-test-server.sjs?sts=304&fmt=video");
|
||||
get("sjs_content-type-test-server.sjs?sts=304&fmt=flash");
|
||||
get("test-image.png");
|
||||
get("test-image.png?v=" + Math.random());
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -13,8 +13,11 @@ function handleRequest(request, response) {
|
|||
let cachedCount = 0;
|
||||
let cacheExpire = 60; // seconds
|
||||
|
||||
function maybeMakeCached() {
|
||||
function setCacheHeaders() {
|
||||
if (status != 304) {
|
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Expires", "0");
|
||||
return;
|
||||
}
|
||||
// Spice things up a little!
|
||||
|
@ -31,7 +34,7 @@ function handleRequest(request, response) {
|
|||
case "txt": {
|
||||
response.setStatusLine(request.httpVersion, status, "DA DA DA");
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("Братан, ты вообще качаешься?");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -39,7 +42,7 @@ function handleRequest(request, response) {
|
|||
case "xml": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/xml; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("<label value='greeting'>Hello XML!</label>");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -48,7 +51,7 @@ function handleRequest(request, response) {
|
|||
let content = params.filter((s) => s.contains("res="))[0].split("=")[1];
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/html; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write(content || "<p>Hello HTML!</p>");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -57,7 +60,7 @@ function handleRequest(request, response) {
|
|||
let str = new Array(102400 /* 100 KB in bytes */).join(".");
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/html; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("<p>" + str + "</p>");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -65,7 +68,7 @@ function handleRequest(request, response) {
|
|||
case "css": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/css; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("body:pre { content: 'Hello CSS!' }");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -73,7 +76,7 @@ function handleRequest(request, response) {
|
|||
case "js": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "application/javascript; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("function() { return 'Hello JS!'; }");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -81,7 +84,7 @@ function handleRequest(request, response) {
|
|||
case "json": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "application/json; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("{ \"greeting\": \"Hello JSON!\" }");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -90,7 +93,7 @@ function handleRequest(request, response) {
|
|||
let fun = params.filter((s) => s.contains("jsonp="))[0].split("=")[1];
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/json; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write(fun + "({ \"greeting\": \"Hello JSONP!\" })");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -99,7 +102,7 @@ function handleRequest(request, response) {
|
|||
let fun = params.filter((s) => s.contains("jsonp="))[0].split("=")[1];
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/json; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write(" " + fun + " ( { \"greeting\": \"Hello weird JSONP!\" } ) ; ");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -108,7 +111,7 @@ function handleRequest(request, response) {
|
|||
let str = "{ \"greeting\": \"Hello long string JSON!\" },";
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/json; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("[" + new Array(2048).join(str).slice(0, -1) + "]");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -116,7 +119,7 @@ function handleRequest(request, response) {
|
|||
case "json-malformed": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/json; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("{ \"greeting\": \"Hello malformed JSON!\" },");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -124,7 +127,7 @@ function handleRequest(request, response) {
|
|||
case "json-text-mime": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("{ \"greeting\": \"Hello third-party JSON!\" }");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -132,7 +135,7 @@ function handleRequest(request, response) {
|
|||
case "json-custom-mime": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "text/x-bigcorp-json; charset=utf-8", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.write("{ \"greeting\": \"Hello oddly-named JSON!\" }");
|
||||
response.finish();
|
||||
break;
|
||||
|
@ -140,41 +143,42 @@ function handleRequest(request, response) {
|
|||
case "font": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "font/woff", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.finish();
|
||||
break;
|
||||
}
|
||||
case "image": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "image/png", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.finish();
|
||||
break;
|
||||
}
|
||||
case "audio": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "audio/ogg", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.finish();
|
||||
break;
|
||||
}
|
||||
case "video": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "video/webm", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.finish();
|
||||
break;
|
||||
}
|
||||
case "flash": {
|
||||
response.setStatusLine(request.httpVersion, status, "OK");
|
||||
response.setHeader("Content-Type", "application/x-shockwave-flash", false);
|
||||
maybeMakeCached();
|
||||
setCacheHeaders();
|
||||
response.finish();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
response.setStatusLine(request.httpVersion, 404, "Not Found");
|
||||
response.setHeader("Content-Type", "text/html; charset=utf-8", false);
|
||||
setCacheHeaders();
|
||||
response.write("<blink>Not Found</blink>");
|
||||
response.finish();
|
||||
break;
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
|
||||
function handleRequest(request, response) {
|
||||
response.setStatusLine(request.httpVersion, 200, "Och Aye");
|
||||
|
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Expires", "0");
|
||||
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
|
||||
response.setHeader("Foo-Bar", "baz", false);
|
||||
response.write("Hello world!");
|
||||
|
|
|
@ -11,6 +11,11 @@ function handleRequest(request, response) {
|
|||
|
||||
Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer).initWithCallback(() => {
|
||||
response.setStatusLine(request.httpVersion, index == 1 ? 101 : index * 100, "Meh");
|
||||
|
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Expires", "0");
|
||||
|
||||
response.setHeader("Content-Type", "text/" + index, false);
|
||||
response.write(new Array(index * 10).join(index)); // + 0.01 KB
|
||||
response.finish();
|
||||
|
|
|
@ -27,6 +27,11 @@ function handleRequest(request, response) {
|
|||
response.setStatusLine(request.httpVersion, 501, "Not Implemented");
|
||||
break;
|
||||
}
|
||||
|
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Expires", "0");
|
||||
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8", false);
|
||||
response.write("Hello status code " + status + "!");
|
||||
response.finish();
|
||||
|
|
Загрузка…
Ссылка в новой задаче