1 var responseServerTiming = [
2 { metric: "metric1", duration: "123.4", description: "description1" },
3 { metric: "metric2", duration: "456.78", description: "description2" },
5 var trailerServerTiming = [
6 { metric: "metric3", duration: "789.11", description: "description3" },
7 { metric: "metric4", duration: "1112.13", description: "description4" },
10 function createServerTimingHeader(headerData) {
12 for (var i = 0; i < headerData.length; i++) {
15 headerData[i].metric +
18 headerData[i].duration +
21 headerData[i].description +
27 function handleRequest(request, response) {
28 var body = "c\r\ndata reached\r\n3\r\nhej\r\n0\r\n";
30 response.seizePower();
31 response.write("HTTP/1.1 200 OK\r\n");
32 response.write("Content-Type: text/plain\r\n");
33 response.write(createServerTimingHeader(responseServerTiming));
35 response.write("Transfer-Encoding: chunked\r\n");
36 response.write("\r\n");
38 response.write(createServerTimingHeader(trailerServerTiming));
39 response.write("\r\n");