Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | // Delay before responding to an HTTP call attempting to read |
michael@0 | 5 | // an addon update RDF file |
michael@0 | 6 | |
michael@0 | 7 | function handleRequest(req, resp) { |
michael@0 | 8 | resp.processAsync(); |
michael@0 | 9 | resp.setHeader("Cache-Control", "no-cache, no-store", false); |
michael@0 | 10 | resp.setHeader("Content-Type", "text/xml;charset=utf-8", false); |
michael@0 | 11 | |
michael@0 | 12 | let file = null; |
michael@0 | 13 | getObjectState("SERVER_ROOT", function(serverRoot) |
michael@0 | 14 | { |
michael@0 | 15 | file = serverRoot.getFile("browser/toolkit/mozapps/extensions/test/browser/browser_bug557956.rdf"); |
michael@0 | 16 | }); |
michael@0 | 17 | dump("*** cancelCompatCheck.sjs: " + file.path + "\n"); |
michael@0 | 18 | let fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]. |
michael@0 | 19 | createInstance(Components.interfaces.nsIFileInputStream); |
michael@0 | 20 | fstream.init(file, -1, 0, 0); |
michael@0 | 21 | let cstream = null; |
michael@0 | 22 | cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]. |
michael@0 | 23 | createInstance(Components.interfaces.nsIConverterInputStream); |
michael@0 | 24 | cstream.init(fstream, "UTF-8", 0, 0); |
michael@0 | 25 | |
michael@0 | 26 | // The delay can be passed on the query string |
michael@0 | 27 | let delay = req.queryString + 0; |
michael@0 | 28 | |
michael@0 | 29 | timer = Components.classes["@mozilla.org/timer;1"]. |
michael@0 | 30 | createInstance(Components.interfaces.nsITimer); |
michael@0 | 31 | timer.init(function sendFile() { |
michael@0 | 32 | dump("cancelCompatCheck: starting to send file\n"); |
michael@0 | 33 | let (str = {}) { |
michael@0 | 34 | let read = 0; |
michael@0 | 35 | do { |
michael@0 | 36 | // read as much as we can and put it in str.value |
michael@0 | 37 | read = cstream.readString(0xffffffff, str); |
michael@0 | 38 | resp.write(str.value); |
michael@0 | 39 | } while (read != 0); |
michael@0 | 40 | } |
michael@0 | 41 | cstream.close(); |
michael@0 | 42 | resp.finish(); |
michael@0 | 43 | }, delay, Components.interfaces.nsITimer.TYPE_ONE_SHOT); |
michael@0 | 44 | } |