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