Skip to content

Commit

Permalink
core: allow URL parameters and POST bodies to co-exist
Browse files Browse the repository at this point in the history
Node 8.14.0 prohibits HTTP headers that exceed 8kB.  This patch
allows for the parameters within the body of an HTTP POST request
to be used in addition to those within the URL (and will override
them).

Alternatively for POST we could ignore URL parameters completely,
but the relevant backend tests would need to be rewritten so as
not to use `endPoint('funcName')` which generates a URL that
pre-includes the API key as a request parameter.
  • Loading branch information
raybellis committed Mar 1, 2019
1 parent b34fc2d commit 882b934
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/node/hooks/express/apicalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//This is a api POST call, collect all post informations and pass it to the apiHandler
args.app.post('/api/:version/:func', function(req, res) {
new formidable.IncomingForm().parse(req, function (err, fields, files) {
apiCaller(req, res, fields)
apiCaller(req, res, Object.assign(req.query, fields))
});
});

Expand Down
6 changes: 4 additions & 2 deletions tests/backend/specs/api/pad.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ describe('createPad', function(){

describe('setText', function(){
it('Sets text on a pad Id', function(done) {
api.get(endPoint('setText')+"&padID="+testPadId+"&text="+text)
api.post(endPoint('setText')+"&padID="+testPadId)
.send({text: text})
.expect(function(res){
if(res.body.code !== 0) throw new Error("Pad Set Text failed")
})
Expand All @@ -410,7 +411,8 @@ describe('getText', function(){

describe('setText', function(){
it('Sets text on a pad Id including an explicit newline', function(done) {
api.get(endPoint('setText')+"&padID="+testPadId+"&text="+text+'%0A')
api.post(endPoint('setText')+"&padID="+testPadId)
.send({text: text+'\n'})
.expect(function(res){
if(res.body.code !== 0) throw new Error("Pad Set Text failed")
})
Expand Down

0 comments on commit 882b934

Please sign in to comment.