"use strict"; function handleRequest(request, response) { Cu.importGlobalProperties(["URLSearchParams"]); let qs = new URLSearchParams(request.queryString); let asset = qs.get("as"); let hinted = qs.get("hinted") !== "0"; let httpCode = qs.get("code"); let csp = qs.get("csp"); let csp_in_early_hint = qs.get("csp_in_early_hint"); let host = qs.get("host"); // eslint-disable-next-line mozilla/use-services let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( Ci.nsIUUIDGenerator ); let uuid = uuidGenerator.generateUUID().toString(); let url = `early_hint_pixel.sjs?as=${asset}&uuid=${uuid}`; if (host) { url = host + url; } // write to raw socket response.seizePower(); if (hinted) { response.write("HTTP/1.1 103 Early Hint\r\n"); if (csp_in_early_hint) { response.write( `Content-Security-Policy: ${csp_in_early_hint.replaceAll('"', "")}\r\n` ); } response.write(`Link: <${url}>; rel=preload; as=${asset}\r\n`); response.write("\r\n"); } let body = ""; if (asset === "image") { body = `
`; } else if (asset === "style") { body = `