summaryrefslogtreecommitdiffstats
path: root/toolkit/components/normandy/test/unit/echo_server.sjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /toolkit/components/normandy/test/unit/echo_server.sjs
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/normandy/test/unit/echo_server.sjs')
-rw-r--r--toolkit/components/normandy/test/unit/echo_server.sjs21
1 files changed, 21 insertions, 0 deletions
diff --git a/toolkit/components/normandy/test/unit/echo_server.sjs b/toolkit/components/normandy/test/unit/echo_server.sjs
new file mode 100644
index 0000000000..012f2b406e
--- /dev/null
+++ b/toolkit/components/normandy/test/unit/echo_server.sjs
@@ -0,0 +1,21 @@
+/**
+ * Reads an HTTP status code and response body from the querystring and sends
+ * back a matching response.
+ */
+function handleRequest(request, response) {
+ // Allow cross-origin, so you can XHR to it!
+ response.setHeader("Access-Control-Allow-Origin", "*", false);
+ // Avoid confusing cache behaviors
+ response.setHeader("Cache-Control", "no-cache", false);
+
+ const params = request.queryString.split("&");
+ for (const param of params) {
+ const [key, value] = param.split("=");
+ if (key === "status") {
+ response.setStatusLine(null, value);
+ } else if (key === "body") {
+ response.write(value);
+ }
+ }
+ response.write("");
+}