From 69b5d825e3d14bde7d4292d12d503bea23a97238 Mon Sep 17 00:00:00 2001 From: javi Date: Thu, 4 Jul 2013 16:23:48 +0200 Subject: [PATCH] reverted support for get params in post --- NEWS.md | 1 - app/controllers/app.js | 13 ++++++------ test/acceptance/app.test.js | 40 ------------------------------------- 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/NEWS.md b/NEWS.md index b8b4ec0a..68244475 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,6 @@ * Fix windowing with CTE * Retain UTC offset in JSON date output * Set max-age=0 in Cache-Control when using no-cache -* Add support for GET params in POST requests 1.4.0 ----- diff --git a/app/controllers/app.js b/app/controllers/app.js index 9af4e088..cd438aa1 100755 --- a/app/controllers/app.js +++ b/app/controllers/app.js @@ -103,19 +103,18 @@ function handleQuery(req, res) { // extract input var body = (req.body) ? req.body : {}; - _.extend(req.query, body); - var sql = req.query.q; - var api_key = req.query.api_key; + var sql = req.query.q || body.q; // HTTP GET and POST store in different vars + var api_key = req.query.api_key || body.api_key; var database = req.query.database; // TODO: Deprecate var limit = parseInt(req.query.rows_per_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 requestedFilename = req.query.filename; + var requestedFilename = req.query.filename || body.filename var filename = requestedFilename; - var requestedSkipfields = req.query.skipfields; + var requestedSkipfields = req.query.skipfields || body.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 user_id; var tableCacheItem; diff --git a/test/acceptance/app.test.js b/test/acceptance/app.test.js index f7c44f6a..0b7e5cbc 100644 --- a/test/acceptance/app.test.js +++ b/test/acceptance/app.test.js @@ -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(); - }); -}); - });