node-restify
node-restify copied to clipboard
Using pre.pause() causes multipart body processing to fail
If I am using pre.pause() to deal with the similar issues reported in:
https://github.com/restify/node-restify/issues/287 https://github.com/restify/node-restify/issues/409
it appears that having that work-around causes the multipart body processing to fail.
Restify never calls my route function and eventually times out returning a 444 error.
Simple Server code:
const restify = require('restify');
const server = restify.createServer({
name: 'myServer',
});
// *********************************
// comment out following to fix
server.pre(restify.pre.pause());
// *********************************
server.use(restify.plugins.bodyParser({
mapParams: true,
mapFiles: true,
keepExtensions: true,
uploadDir: '/tmp/',
}));
server.use(restify.plugins.queryParser({ mapParams: true }));
server.post("/upload", function (request, response, next) {
response.send("steve");
next();
});
server.listen(8372, () => console.log('Server started on port 8372'));
calling with a file and data:
curl --request POST 'http://localhost:8372/api/upload' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@/Users/steve/Downloads/myfile.jpg' \
--form 'data=mine'