bug657191.sjs 1.0 KB

12345678910111213141516171819202122232425262728
  1. function handleRequest(request, response)
  2. {
  3. var file = Components.classes["@mozilla.org/file/directory_service;1"]
  4. .getService(Components.interfaces.nsIProperties)
  5. .get("CurWorkD", Components.interfaces.nsIFile);
  6. file.append("tests");
  7. file.append("image");
  8. file.append("test");
  9. file.append("mochitest");
  10. file.append('lime100x100.svg');
  11. response.setStatusLine("1.1", 500, "Internal Server Error");
  12. response.setHeader("Content-Type", "image/svg+xml", false);
  13. var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1']
  14. .createInstance(Components.interfaces.nsIFileInputStream);
  15. fileStream.init(file, 1, 0, false);
  16. var binaryStream = Components.classes['@mozilla.org/binaryinputstream;1']
  17. .createInstance(Components.interfaces.nsIBinaryInputStream);
  18. binaryStream.setInputStream(fileStream);
  19. response.bodyOutputStream.writeFrom(binaryStream, binaryStream.available());
  20. binaryStream.close();
  21. fileStream.close();
  22. }