Innovenergy_trunk/frontend/node_modules/testcafe/lib/utils/http.js

31 lines
3.1 KiB
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.preventCaching = exports.respondWithJSON = exports.redirect = exports.respond500 = exports.respond404 = void 0;
function respond404(res) {
res.statusCode = 404;
res.end();
}
exports.respond404 = respond404;
function respond500(res, err) {
res.statusCode = 500;
res.end(err || '');
}
exports.respond500 = respond500;
function redirect(res, url) {
res.statusCode = 302;
res.setHeader('location', url);
res.end();
}
exports.redirect = redirect;
function respondWithJSON(res, data) {
preventCaching(res);
res.setHeader('content-type', 'application/json');
res.end(data ? JSON.stringify(data) : '');
}
exports.respondWithJSON = respondWithJSON;
function preventCaching(res) {
res.setHeader('cache-control', 'no-cache, no-store, must-revalidate');
res.setHeader('pragma', 'no-cache');
}
exports.preventCaching = preventCaching;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9odHRwLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLFNBQWdCLFVBQVUsQ0FBRSxHQUFHO0lBQzNCLEdBQUcsQ0FBQyxVQUFVLEdBQUcsR0FBRyxDQUFDO0lBQ3JCLEdBQUcsQ0FBQyxHQUFHLEVBQUUsQ0FBQztBQUNkLENBQUM7QUFIRCxnQ0FHQztBQUVELFNBQWdCLFVBQVUsQ0FBRSxHQUFHLEVBQUUsR0FBRztJQUNoQyxHQUFHLENBQUMsVUFBVSxHQUFHLEdBQUcsQ0FBQztJQUNyQixHQUFHLENBQUMsR0FBRyxDQUFDLEdBQUcsSUFBSSxFQUFFLENBQUMsQ0FBQztBQUN2QixDQUFDO0FBSEQsZ0NBR0M7QUFFRCxTQUFnQixRQUFRLENBQUUsR0FBRyxFQUFFLEdBQUc7SUFDOUIsR0FBRyxDQUFDLFVBQVUsR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