Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | var manifest = |
michael@0 | 2 | "CACHE MANIFEST\n" + |
michael@0 | 3 | "obsolete.html\n"; |
michael@0 | 4 | |
michael@0 | 5 | function handleRequest(request, response) |
michael@0 | 6 | { |
michael@0 | 7 | var match = request.queryString.match(/^state=(.*)$/); |
michael@0 | 8 | if (match) |
michael@0 | 9 | { |
michael@0 | 10 | response.setStatusLine(request.httpVersion, 204, "No content"); |
michael@0 | 11 | response.setHeader("Cache-Control", "no-cache"); |
michael@0 | 12 | setState("offline.obsoletingManifest", match[1]); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | if (request.queryString == "") |
michael@0 | 16 | { |
michael@0 | 17 | switch (getState("offline.obsoletingManifest")) |
michael@0 | 18 | { |
michael@0 | 19 | case "": // The default value |
michael@0 | 20 | response.setStatusLine(request.httpVersion, 404, "Not found"); |
michael@0 | 21 | response.setHeader("Cache-Control", "no-cache"); |
michael@0 | 22 | break; |
michael@0 | 23 | case "manifestPresent": |
michael@0 | 24 | response.setStatusLine(request.httpVersion, 200, "Ok"); |
michael@0 | 25 | response.setHeader("Content-Type", "text/cache-manifest"); |
michael@0 | 26 | response.setHeader("Cache-Control", "no-cache"); |
michael@0 | 27 | response.write(manifest); |
michael@0 | 28 | break; |
michael@0 | 29 | } |
michael@0 | 30 | } |
michael@0 | 31 | } |