Drop cache headers from error responses.
Closes #107 (github), #resolve CDB-1423 (JIRA)
This commit is contained in:
parent
ae82d0ab47
commit
2690ef3f05
4
NEWS.md
4
NEWS.md
@ -1,6 +1,10 @@
|
|||||||
1.6.1 -- 2014-01-DD
|
1.6.1 -- 2014-01-DD
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* Drop cache headers from error responses (#107)
|
||||||
|
|
||||||
1.6.0 -- 2014-01-10
|
1.6.0 -- 2014-01-10
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
@ -42,6 +42,16 @@ var CartodbWindshaft = function(serverOptions) {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override sendError to drop added cache headers (if any)
|
||||||
|
// 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'];
|
||||||
|
ws_sendError.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to allow access to the layer to be used in the maps infowindow popup.
|
* Helper to allow access to the layer to be used in the maps infowindow popup.
|
||||||
*/
|
*/
|
||||||
|
@ -125,6 +125,7 @@ suite('server', function() {
|
|||||||
assert.equal(res.statusCode, 400, res.body);
|
assert.equal(res.statusCode, 400, res.body);
|
||||||
assert.deepEqual(JSON.parse(res.body),
|
assert.deepEqual(JSON.parse(res.body),
|
||||||
{error: 'Sorry, you are unauthorized (permission denied)'});
|
{error: 'Sorry, you are unauthorized (permission denied)'});
|
||||||
|
assert.ok(!res.headers.hasOwnProperty('cache-control'));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -142,6 +143,7 @@ suite('server', function() {
|
|||||||
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
||||||
assert.deepEqual(JSON.parse(res.body),
|
assert.deepEqual(JSON.parse(res.body),
|
||||||
{error:"missing unknown_user's database_name in redis (try CARTODB/script/restore_redis)"});
|
{error:"missing unknown_user's database_name in redis (try CARTODB/script/restore_redis)"});
|
||||||
|
assert.ok(!res.headers.hasOwnProperty('cache-control'));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -212,9 +214,12 @@ suite('server', function() {
|
|||||||
url: '/tiles/my_table/style',
|
url: '/tiles/my_table/style',
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},{
|
},{
|
||||||
status: 400,
|
|
||||||
body: '{"error":"must send style information"}'
|
body: '{"error":"must send style information"}'
|
||||||
}, function() { done(); });
|
}, function(res) {
|
||||||
|
assert.equal(res.statusCode, 400);
|
||||||
|
assert.ok(!res.headers.hasOwnProperty('cache-control'));
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("post'ing bad style returns 400 with error", function(done){
|
test("post'ing bad style returns 400 with error", function(done){
|
||||||
@ -766,6 +771,8 @@ suite('server', function() {
|
|||||||
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 400, res.statusCode + ': ' + res.body);
|
||||||
assert.deepEqual(JSON.parse(res.body),
|
assert.deepEqual(JSON.parse(res.body),
|
||||||
{error:"missing unknown_user's database_name in redis (try CARTODB/script/restore_redis)"});
|
{error:"missing unknown_user's database_name in redis (try CARTODB/script/restore_redis)"});
|
||||||
|
assert.ok(!res.headers.hasOwnProperty('cache-control'),
|
||||||
|
"Unexpected Cache-Control: " + res.headers['cache-control']);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -786,6 +793,9 @@ suite('server', function() {
|
|||||||
}, function(res) {
|
}, function(res) {
|
||||||
// 401 Unauthorized
|
// 401 Unauthorized
|
||||||
assert.equal(res.statusCode, 401, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 401, res.statusCode + ': ' + res.body);
|
||||||
|
// Failed in 1.6.0 of https://github.com/CartoDB/Windshaft-cartodb/issues/107
|
||||||
|
assert.ok(!res.headers.hasOwnProperty('cache-control'),
|
||||||
|
"Unexpected Cache-Control: " + res.headers['cache-control']);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1179,6 +1189,7 @@ suite('server', function() {
|
|||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
},{}, function(res) {
|
},{}, function(res) {
|
||||||
assert.equal(res.statusCode, 404, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 404, res.statusCode + ': ' + res.body);
|
||||||
|
assert.ok(!res.headers.hasOwnProperty('cache-control'));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1210,6 +1221,7 @@ suite('server', function() {
|
|||||||
},{}, function(res) {
|
},{}, function(res) {
|
||||||
// FIXME: should be 401 instead
|
// FIXME: should be 401 instead
|
||||||
assert.equal(res.statusCode, 500, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 500, res.statusCode + ': ' + res.body);
|
||||||
|
assert.ok(!res.headers.hasOwnProperty('cache-control'));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1262,6 +1274,7 @@ suite('server', function() {
|
|||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
},{}, function(res) {
|
},{}, function(res) {
|
||||||
assert.equal(res.statusCode, 404, res.statusCode + ': ' + res.body);
|
assert.equal(res.statusCode, 404, res.statusCode + ': ' + res.body);
|
||||||
|
assert.ok(!res.headers.hasOwnProperty('cache-control'));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user