合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
``` let http = require('http'); let server = http.createServer(function(req,res){ console.log('ok'); let contentType = req.headers['content-type']; let buffers = []; req.on('data',function(chunk){ buffers.push(chunk); }) req.on('end',function(){ // console.log(JSON.parse(Buffer.concat(buffers).toString()).name); let content = Buffer.concat(buffers).toString(); if(contentType === 'application/json'){ console.log(JSON.parse(content).name); }else if(contentType === 'application/x-www-form-urlencoded'){ let queryString = require('querystring'); console.log(queryString.parse(content).name); } }) res.end(); }); server.listen(4000); ```