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 handleRequest(request, response) { |
michael@0 | 2 | let invalidHeaders = ["Cookie"]; |
michael@0 | 3 | let headers = {}; |
michael@0 | 4 | |
michael@0 | 5 | if (request.queryString == "expectAuth=true") { |
michael@0 | 6 | if (request.hasHeader("Authorization")) { |
michael@0 | 7 | headers["authorization"] = request.getHeader("Authorization"); |
michael@0 | 8 | } else { |
michael@0 | 9 | response.setStatusLine(null, 401, "Authentication required"); |
michael@0 | 10 | response.setHeader("WWW-Authenticate", "basic realm=\"testrealm\"", true); |
michael@0 | 11 | } |
michael@0 | 12 | } else { |
michael@0 | 13 | invalidHeaders.push("Authorization"); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | for each (let header in invalidHeaders) { |
michael@0 | 17 | if (request.hasHeader(header)) { |
michael@0 | 18 | response.setStatusLine(null, 500, "Server Error"); |
michael@0 | 19 | headers[header.toLowerCase()] = request.getHeader(header); |
michael@0 | 20 | } |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | response.write(JSON.stringify(headers)); |
michael@0 | 24 | } |