node.js - Restify getting request.body when content-type is application/octet-stream -


does know why setting content-type application/octet-stream request body undefined in restify?

here code

var restify = require('restify'); var server = restify.createserver({});  server.use(restify.bodyparser({ }));  server.post('/test', function(req, res, next){     console.log(req.body); });  server.listen(8090, function() {}); 

http request

post /test  content-type: text/plain  hello 

console print: hello

post /test  content-type: image/png  hello 

console print: <buffer 68 65 6c 6c 6f>

post /test  content-type: application/octet-stream  hello 

console print: undefined

from can see in restify, due bodyparser expecting content-type: application/json extracted https://github.com/restify/node-restify/blob/master/lib/plugins/json_body_parser.js#l28

if (req.getcontenttype() !== 'application/json' || !req.body) {   next();   return; } 

so req.body never gets assigned...


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -