Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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 | } |