nodejs接收post數(shù)據(jù)時(shí),在request監(jiān)聽data事件時(shí)回調(diào)函數(shù)的參數(shù)(chunk)是buffer,但是用+連接后怎么會(huì)成為字符串?//main.jshttp.createServer(function(req,res){ if(req.method=='POST'){ var all = '' req.on('data',function(chunk){ console.log(chunk) all+=chunk console.log('all:',all) }) req.on('end',function(){ res.end(all.toUpperCase()) }) }else{ res.end() }}).listen(port)我使用 curl -d "user=Summer&passwd=12345678" "http://127.0.0.1:3000" 進(jìn)行模擬請(qǐng)求時(shí),命令行結(jié)果如下<Buffer 75 73 65 72 3d 53 75 6d 6d 65 72 26 70 61 73 73 77 64 3d 31 32 33 34 3536 37 38>all: user=Summer&passwd=12345678
nodejs中buffer用+連接會(huì)強(qiáng)制轉(zhuǎn)換成字符串?
慕哥9229398
2019-02-08 15:19:39