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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

點點星光fighting 2017-05-18 16:38:31
按照課程上面進行測試,雖然評論成功了,但是沒有打印出?res.on('data',function(chunk){? ? ? ? console.log(Buffer.isBuffer(chunk));? ? ? ? console.log(typeof chunk);? ? });這個事件中的數(shù)據(jù),請問是什么原因呢?源代碼:var http =require('http');var querystring =require('querystring');var postData = querystring.stringify({? ? content:'不錯不錯不錯',? ? 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貢獻2條經(jīng)驗 獲得超0個贊

你把把全部的代碼粘一下, 也就50左右行代碼,我運行的時候沒出錯啊

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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

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