michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function handleRequest(request, response) { michael@0: response.setHeader("Cache-Control", "no-cache", false); michael@0: michael@0: let loadedStateKey = "sandbox_content_loaded"; michael@0: switch(request.queryString) { michael@0: case "reset": { michael@0: setState(loadedStateKey, ""); michael@0: response.write("reset"); michael@0: break; michael@0: } michael@0: case "get_loaded": { michael@0: response.setHeader("Content-Type", "text/plain", false); michael@0: let loaded = getState(loadedStateKey); michael@0: if (loaded) michael@0: response.write(loaded); michael@0: else michael@0: response.write("NOTHING"); michael@0: break; michael@0: } michael@0: default: { michael@0: let contentType = decodeURIComponent(request.queryString); michael@0: // set the Content-Type equal to the query string michael@0: response.setHeader("Content-Type", contentType, false); michael@0: // If any content is loaded, append it's content type in state michael@0: let loaded = getState(loadedStateKey); michael@0: if (loaded) michael@0: loaded += ","; michael@0: setState(loadedStateKey, loaded + contentType); michael@0: break; michael@0: } michael@0: } michael@0: }