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 | function parseQuery(request, key) { |
michael@0 | 2 | var params = request.queryString.split('&'); |
michael@0 | 3 | for (var j = 0; j < params.length; ++j) { |
michael@0 | 4 | var p = params[j]; |
michael@0 | 5 | if (p == key) |
michael@0 | 6 | return true; |
michael@0 | 7 | if (p.indexOf(key + "=") == 0) |
michael@0 | 8 | return p.substring(key.length + 1); |
michael@0 | 9 | if (p.indexOf("=") < 0 && key == "") |
michael@0 | 10 | return p; |
michael@0 | 11 | } |
michael@0 | 12 | return false; |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | // Return file content for the first request with a given key. |
michael@0 | 16 | // All subsequent requests return a redirect to a different-origin resource. |
michael@0 | 17 | function handleRequest(request, response) |
michael@0 | 18 | { |
michael@0 | 19 | var domain = parseQuery(request, "domain"); |
michael@0 | 20 | var file = parseQuery(request, "file"); |
michael@0 | 21 | var allowed = parseQuery(request, "allowed"); |
michael@0 | 22 | |
michael@0 | 23 | response.setStatusLine(request.httpVersion, 303, "See Other"); |
michael@0 | 24 | response.setHeader("Location", "http://" + domain + "/tests/content/media/test/" + (allowed ? "allowed.sjs?" : "") + file); |
michael@0 | 25 | response.setHeader("Content-Type", "text/html"); |
michael@0 | 26 | } |