Do not choke on headers cleanup when response headers are not set

Raise a WARNING instead.
See #107 (github) and CDB-1438 (JIRA)
This commit is contained in:
Sandro Santilli
2014-01-13 18:56:09 +01:00
parent 2690ef3f05
commit d6fe5339cf

View File

@@ -46,9 +46,13 @@ var CartodbWindshaft = function(serverOptions) {
// See http://github.com/CartoDB/Windshaft-cartodb/issues/107
var ws_sendError = ws.sendError;
ws.sendError = function(res) {
delete res._headers['cache-control'];
delete res._headers['last-modified'];
delete res._headers['x-cache-channel'];
if ( res._headers ) {
delete res._headers['cache-control'];
delete res._headers['last-modified'];
delete res._headers['x-cache-channel'];
} else {
console.log("WARNING: response has no _headers: "); console.dir(res);
}
ws_sendError.apply(this, arguments);
};