3 const key = "blocked-response";
4 function setResponse(response) {
5 setObjectState(key, response);
8 function getResponse() {
10 getObjectState(key, v => {
16 function handleRequest(request, response) {
17 const { queryString } = request;
19 // The default end point will return a blocked response.
20 // The response object will be stored and will be released
21 // when "?unblock" is called.
22 response.processAsync();
23 response.setHeader("Content-Type", "text/plain", false);
24 response.write("Begin...\n");
25 setResponse(response);
26 } else if (queryString == "unblock") {
27 // unblock the pending response
28 getResponse().finish();
31 // and return synchronously.
32 response.setHeader("Content-Type", "text/plain");