From d6fe5339cf6e43ff9f79afe26e52d8a299c4e834 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 13 Jan 2014 18:56:09 +0100 Subject: [PATCH] Do not choke on headers cleanup when response headers are not set Raise a WARNING instead. See #107 (github) and CDB-1438 (JIRA) --- lib/cartodb/cartodb_windshaft.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index cc3151d0..d18cf4e3 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -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); };