michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Delay before responding to an HTTP call attempting to read michael@0: // an addon update RDF file michael@0: michael@0: function handleRequest(req, resp) { michael@0: resp.processAsync(); michael@0: resp.setHeader("Cache-Control", "no-cache, no-store", false); michael@0: resp.setHeader("Content-Type", "text/xml;charset=utf-8", false); michael@0: michael@0: let file = null; michael@0: getObjectState("SERVER_ROOT", function(serverRoot) michael@0: { michael@0: file = serverRoot.getFile("browser/toolkit/mozapps/extensions/test/browser/browser_bug557956.rdf"); michael@0: }); michael@0: dump("*** cancelCompatCheck.sjs: " + file.path + "\n"); michael@0: let fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]. michael@0: createInstance(Components.interfaces.nsIFileInputStream); michael@0: fstream.init(file, -1, 0, 0); michael@0: let cstream = null; michael@0: cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]. michael@0: createInstance(Components.interfaces.nsIConverterInputStream); michael@0: cstream.init(fstream, "UTF-8", 0, 0); michael@0: michael@0: // The delay can be passed on the query string michael@0: let delay = req.queryString + 0; michael@0: michael@0: timer = Components.classes["@mozilla.org/timer;1"]. michael@0: createInstance(Components.interfaces.nsITimer); michael@0: timer.init(function sendFile() { michael@0: dump("cancelCompatCheck: starting to send file\n"); michael@0: let (str = {}) { michael@0: let read = 0; michael@0: do { michael@0: // read as much as we can and put it in str.value michael@0: read = cstream.readString(0xffffffff, str); michael@0: resp.write(str.value); michael@0: } while (read != 0); michael@0: } michael@0: cstream.close(); michael@0: resp.finish(); michael@0: }, delay, Components.interfaces.nsITimer.TYPE_ONE_SHOT); michael@0: }