第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

nodejs http.request中的res.on沒有執(zhí)行

nodejs http.request中的res.on沒有執(zhí)行

按照課程上面進(jìn)行測試,雖然評論成功了,但是沒有打印出?res.on('data',function(chunk){? ? ? ? console.log(Buffer.isBuffer(chunk));? ? ? ? console.log(typeof chunk);? ? });這個(gè)事件中的數(shù)據(jù),請問是什么原因呢?源代碼:var http =require('http');var querystring =require('querystring');var postData = querystring.stringify({? ? content:'不錯(cuò)不錯(cuò)不錯(cuò)',? ? cross_post:1,? ? belongId:2862414});var options ={? ? hostname: 'v.yinyuetai.com',? ? port:80,? ? path:'/video/2862414',? ? method:'POST',? ? headers:{? ? ? ? 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',? ? ? ? 'Accept-Encoding':'gzip, deflate',? ? ? ? 'Accept-Language':'zh-CN,zh;q=0.8',? ? ? ? 'Cache-Control':'max-age=0',? ? ? ? 'Connection':'keep-alive',? ? ? ? 'Content-Length':postData.length,? ? ? ? 'Content-Type':'application/x-www-form-urlencoded',? ? ? ? 'Host':'comment.yinyuetai.com',? ? ? ? 'Origin':'http://v.yinyuetai.com',? ? ? ? 'Referer':'http://v.yinyuetai.com/video/2862414',? ? ? ? 'Upgrade-Insecure-Requests':1,? ? ? ? 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'? ? }}var req =http.request(options,function(res){? ? console.log('status: '+res.statusCode);? ? console.log('headers: '+JSON.stringify(res.headers));? ?? ? res.on('data',function(chunk){? ? ? ? console.log(Buffer.isBuffer(chunk));? ? ? ? console.log(typeof chunk);? ? ? ??? ? });? ? res.on('end',function(e){? ? ? ? console.log('評論完畢!');? ? })});req.on('error',function(e){? ? console.log('Error: '+e.message);});req.write(postData);req.end();
查看完整描述

1 回答

?
六邊圓

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊

你把把全部的代碼粘一下, 也就50左右行代碼,我運(yùn)行的時(shí)候沒出錯(cuò)啊

查看完整回答
反對 回復(fù) 2017-05-18
  • 點(diǎn)點(diǎn)星光fighting
  • 六邊圓
    六邊圓
    看了,主要代碼就是http.request ...這一塊,沒有錯(cuò),可能是你測試的這個(gè)網(wǎng)站的數(shù)據(jù)有問題,建議你測試一下imooc,現(xiàn)在評論不會(huì)生效,但是代碼可以跑通,測一次也不會(huì)封你號,這個(gè)案例主要是說明http的request請求的,你了解了返回的chunk的數(shù)據(jù)塊是Object,是Buffer類型即可
  • 1 回答
  • 0 關(guān)注
  • 6558 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號