gecko-dev/dom/workers/test/serviceworkers/fetch/deliver-gzip.sjs
Nikhil Marathe fa2b7dfb6b Bug 1141332 - Disable content decoding and use decoded length on intercepted channels. r=mcmanus
--HG--
extra : transplant_source : %B9%A2%AB.%EA%A4%ABH%86%D0%F0%3F%DE%03%DF%7D%A9p%B2%D5
2015-03-17 08:48:32 -07:00

18 lines
817 B
JavaScript

function handleRequest(request, response) {
// The string "hello" repeated 10 times followed by newline. Compressed using gzip.
var bytes = [0x1f, 0x8b, 0x08, 0x08, 0x4d, 0xe2, 0xf9, 0x54, 0x00, 0x03, 0x68,
0x65, 0x6c, 0x6c, 0x6f, 0x00, 0xcb, 0x48, 0xcd, 0xc9, 0xc9, 0xcf,
0x20, 0x85, 0xe0, 0x02, 0x00, 0xf5, 0x4b, 0x38, 0xcf, 0x33, 0x00,
0x00, 0x00];
response.setHeader("Content-Encoding", "gzip", false);
response.setHeader("Content-Length", "" + bytes.length, false);
response.setHeader("Content-Type", "text/plain", false);
var bos = Components.classes["@mozilla.org/binaryoutputstream;1"]
.createInstance(Components.interfaces.nsIBinaryOutputStream);
bos.setOutputStream(response.bodyOutputStream);
bos.writeByteArray(bytes, bytes.length);
}