node-restify icon indicating copy to clipboard operation
node-restify copied to clipboard

Using pre.pause() causes multipart body processing to fail

Open shusak opened this issue 4 years ago • 0 comments

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'

shusak avatar Jul 15 '20 22:07 shusak