Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | function handleRequest(request, response) |
michael@0 | 2 | { |
michael@0 | 3 | var file = Components.classes["@mozilla.org/file/directory_service;1"] |
michael@0 | 4 | .getService(Components.interfaces.nsIProperties) |
michael@0 | 5 | .get("CurWorkD", Components.interfaces.nsIFile); |
michael@0 | 6 | |
michael@0 | 7 | file.append("tests"); |
michael@0 | 8 | file.append("image"); |
michael@0 | 9 | file.append("test"); |
michael@0 | 10 | file.append("mochitest"); |
michael@0 | 11 | file.append('lime100x100.svg'); |
michael@0 | 12 | |
michael@0 | 13 | response.setStatusLine("1.1", 500, "Internal Server Error"); |
michael@0 | 14 | response.setHeader("Content-Type", "image/svg+xml", false); |
michael@0 | 15 | |
michael@0 | 16 | var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1'] |
michael@0 | 17 | .createInstance(Components.interfaces.nsIFileInputStream); |
michael@0 | 18 | fileStream.init(file, 1, 0, false); |
michael@0 | 19 | var binaryStream = Components.classes['@mozilla.org/binaryinputstream;1'] |
michael@0 | 20 | .createInstance(Components.interfaces.nsIBinaryInputStream); |
michael@0 | 21 | binaryStream.setInputStream(fileStream); |
michael@0 | 22 | |
michael@0 | 23 | response.bodyOutputStream.writeFrom(binaryStream, binaryStream.available()); |
michael@0 | 24 | |
michael@0 | 25 | binaryStream.close(); |
michael@0 | 26 | fileStream.close(); |
michael@0 | 27 | } |