blob: 012f2b406e3af96f9d4d95d87464f036cc2f7d1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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("");
}
|