dom/xhr/tests/responseIdentical.sjs
author Jan de Mooij <jdemooij@mozilla.com>
Wed, 13 Feb 2019 06:41:44 +0000
changeset 516733 8c306186cbd7672259b3a730471cfcbe44a9b0d0
parent 342795 55a63a62c0dd798ba7ea9c5ab08d49a48588a0d4
permissions -rw-r--r--
Bug 1526588 - Fix some issues with js::GetFirstGlobalInCompartment and XPCWrappedNativeScope::UpdateWeakPointersInAllScopesAfterGC. r=bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D19493

const CC = Components.Constructor;
const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
                             "nsIBinaryInputStream",
                             "setInputStream");

// Simply sending back the same data that is received
function handleRequest(request, response)
{
  var body = "";
  var bodyStream = new BinaryInputStream(request.bodyInputStream);
  var bytes = [], avail = 0;
  while ((avail = bodyStream.available()) > 0)
    body += String.fromCharCode.apply(String, bodyStream.readByteArray(avail));

  response.setHeader("Content-Type", "application/octet-stream", false);
  response.write(body);
}