reverted support for get params in post
This commit is contained in:
parent
e114b4266d
commit
69b5d825e3
1
NEWS.md
1
NEWS.md
@ -5,7 +5,6 @@
|
|||||||
* Fix windowing with CTE
|
* Fix windowing with CTE
|
||||||
* Retain UTC offset in JSON date output
|
* Retain UTC offset in JSON date output
|
||||||
* Set max-age=0 in Cache-Control when using no-cache
|
* Set max-age=0 in Cache-Control when using no-cache
|
||||||
* Add support for GET params in POST requests
|
|
||||||
|
|
||||||
1.4.0
|
1.4.0
|
||||||
-----
|
-----
|
||||||
|
@ -103,19 +103,18 @@ function handleQuery(req, res) {
|
|||||||
|
|
||||||
// extract input
|
// extract input
|
||||||
var body = (req.body) ? req.body : {};
|
var body = (req.body) ? req.body : {};
|
||||||
_.extend(req.query, body);
|
var sql = req.query.q || body.q; // HTTP GET and POST store in different vars
|
||||||
var sql = req.query.q;
|
var api_key = req.query.api_key || body.api_key;
|
||||||
var api_key = req.query.api_key;
|
|
||||||
var database = req.query.database; // TODO: Deprecate
|
var database = req.query.database; // TODO: Deprecate
|
||||||
var limit = parseInt(req.query.rows_per_page);
|
var limit = parseInt(req.query.rows_per_page);
|
||||||
var offset = parseInt(req.query.page);
|
var offset = parseInt(req.query.page);
|
||||||
var requestedFormat = req.query.format;
|
var requestedFormat = req.query.format || body.format;
|
||||||
var format = _.isArray(requestedFormat) ? _.last(requestedFormat) : requestedFormat;
|
var format = _.isArray(requestedFormat) ? _.last(requestedFormat) : requestedFormat;
|
||||||
var requestedFilename = req.query.filename;
|
var requestedFilename = req.query.filename || body.filename
|
||||||
var filename = requestedFilename;
|
var filename = requestedFilename;
|
||||||
var requestedSkipfields = req.query.skipfields;
|
var requestedSkipfields = req.query.skipfields || body.skipfields;
|
||||||
var skipfields;
|
var skipfields;
|
||||||
var dp = req.query.dp; // decimal point digits (defaults to 6)
|
var dp = req.query.dp || body.dp; // decimal point digits (defaults to 6)
|
||||||
var gn = "the_geom"; // TODO: read from configuration file
|
var gn = "the_geom"; // TODO: read from configuration file
|
||||||
var user_id;
|
var user_id;
|
||||||
var tableCacheItem;
|
var tableCacheItem;
|
||||||
|
@ -980,44 +980,4 @@ test('GET /api/v1/sql with SQL parameter on SELECT only should return CORS heade
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("rows_per_page limit the number of results with get",
|
|
||||||
function(done){
|
|
||||||
assert.response(app, {
|
|
||||||
url: '/api/v1/sql?' + querystring.stringify({
|
|
||||||
q: 'selECT cartodb_id*3 FROM untitle_table_4 limit 10',
|
|
||||||
api_key: '1234',
|
|
||||||
rows_per_page: 2,
|
|
||||||
page: 0
|
|
||||||
}),
|
|
||||||
headers: {host: 'vizzuality.cartodb.com'},
|
|
||||||
method: 'GET'
|
|
||||||
},{ }, function(res) {
|
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
|
||||||
var parsed = JSON.parse(res.body);
|
|
||||||
assert.equal(parsed.rows.length, 2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("rows_per_page limit the number of results with post",
|
|
||||||
function(done){
|
|
||||||
assert.response(app, {
|
|
||||||
url: '/api/v1/sql',
|
|
||||||
data: querystring.stringify({
|
|
||||||
q: 'selECT cartodb_id*3 FROM untitle_table_4 limit 10',
|
|
||||||
api_key: '1234',
|
|
||||||
rows_per_page: 2,
|
|
||||||
page: 0
|
|
||||||
}),
|
|
||||||
headers: {host: 'vizzuality.cartodb.com', 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
||||||
method: 'POST'
|
|
||||||
},{ }, function(res) {
|
|
||||||
assert.equal(res.statusCode, 200, res.body);
|
|
||||||
var parsed = JSON.parse(res.body);
|
|
||||||
assert.equal(parsed.rows.length, 2);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user