From 898f717254ef25c59e305add0188d83f19751e4e Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 20 Mar 2014 17:10:39 +0100 Subject: [PATCH 1/3] Prepare for 1.10.1 --- NEWS.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 11e44046..96ed3ea0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +1.10.1 -- 2014-MM-DD +------------------- + 1.10.0 -- 2014-03-20 ------------------- diff --git a/package.json b/package.json index 150a86d6..56e5fad8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "windshaft-cartodb", - "version": "1.10.0", + "version": "1.10.1", "description": "A map tile server for CartoDB", "keywords": [ "cartodb" From 9e495b42ee18a23a0f38c09bc5abfb5d5ca7b76f Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 21 Mar 2014 13:58:20 +0100 Subject: [PATCH 2/3] Do not cache non-success jsonp responses Closes #186 Includes testcase --- NEWS.md | 4 ++++ lib/cartodb/cartodb_windshaft.js | 19 ++++++++++++++++--- test/acceptance/server.js | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 96ed3ea0..b7ec587e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ 1.10.1 -- 2014-MM-DD ------------------- +Bug fixes: + + - Do not cache non-success jsonp responses (#186) + 1.10.0 -- 2014-03-20 ------------------- diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index f3ec9587..23878a7f 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -76,9 +76,14 @@ var CartodbWindshaft = function(serverOptions) { var that = this; var thatArgs = arguments; var statusCode; - if ( args.length > 2 ) statusCode = args[2]; - else { - statusCode = args[1] || 200; + if ( res._windshaftStatusCode ) { + // Added by our override of sendError + statusCode = res._windshaftStatusCode; + } else { + if ( args.length > 2 ) statusCode = args[2]; + else { + statusCode = args[1] || 200; + } } var req = res.req; Step ( @@ -117,6 +122,14 @@ var CartodbWindshaft = function(serverOptions) { ); }; + var ws_sendError = ws.sendError; + ws.sendError = function() { + var res = arguments[0]; + var statusCode = arguments[2]; + res._windshaftStatusCode = statusCode; + ws_sendError.apply(this, arguments); + }; + /** * Helper to allow access to the layer to be used in the maps infowindow popup. */ diff --git a/test/acceptance/server.js b/test/acceptance/server.js index 0392083a..2066d6de 100644 --- a/test/acceptance/server.js +++ b/test/acceptance/server.js @@ -620,6 +620,24 @@ suite('server', function() { }); }); + // See http://github.com/CartoDB/Windshaft-cartodb/issues/186 + test("get'ing the grid of a private table should fail when unauthenticated (jsonp)", + function(done) { + assert.response(server, { + headers: {host: 'localhost'}, + url: '/tiles/test_table_private_1/6/31/24.grid.json?callback=x', + method: 'GET' + },{}, function(res) { + // It's forbidden, but jsonp calls for status = 200 + assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); + // Still, we do NOT want to add caching headers here + // See https://github.com/CartoDB/Windshaft-cartodb/issues/186 + assert.ok(!res.headers.hasOwnProperty('cache-control'), + "Unexpected Cache-Control: " + res.headers['cache-control']); + done(); + }); + }); + // See http://github.com/Vizzuality/Windshaft-cartodb/issues/55 test("get'ing grid of private table should fail on unknown username", function(done) { From 1bf7bf66b386f790ceb5299569d097a8bd104952 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 21 Mar 2014 15:16:19 +0100 Subject: [PATCH 3/3] Release 1.10.1 --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index b7ec587e..babceb78 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -1.10.1 -- 2014-MM-DD +1.10.1 -- 2014-03-21 ------------------- Bug fixes: