猿问

我状态成功 connection":"close", 这是什么原因

var http = require('http');
var querystring = require('querystring');


var postData = querystring.stringify({
   'content': '我的测试  啦啦啦啦',
   'mid': 8837
})

var options = {
   hostname: 'www.imooc.com',
   prot: 80,
   path: '/course/docomment',
   method: 'POST',
   headers: {
       'Accept': ' application / json, text / javascript, */*; q=0.01',
       'Accept-Encoding': 'gzip, deflate',
       'Accept-Language': 'zh-CN,zh;q=0.9',
       'Content-Length': postData.length,
       'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
       'Cookie': 'PHPSESSID=jm50e92te6ou8oactqrmu19h66; imooc_uuid=f150235b-37b6-44de-b942-f058be4d748f; imooc_isnew_ct=1509677550; loginstate=1; apsid=MyZDQyYzU4YjBjZWJhYTgyZDk5ZmNmMjhmY2Y0NjcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANDE3NTQ3MQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5MzExNjgzNDhAcXEuY29tAAAAAAAAAAAAAAAAAAAAAGViZTA0NWJjOTkyNmQxNDliY2M4MTFhOWZmZDE0NTc5zOX7Wczl%2B1k%3DZj; last_login_username=931168348%40qq.com; IMCDNS=0; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1510104277,1510104318,1510126222,1510192159; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1510193700; imooc_isnew=2; cvde=59fbd9ee4e6ca-380',
       'Host': 'www.imooc.com',
       'Origin': 'http://www.imooc.com',
       'Proxy-Connection': 'keep-alive',
       'Referer': 'http://www.imooc.com/video/8837',
       'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36',
       'X-Requested-With': 'XMLHttpRequest'
   }
}


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 () {
       console.log('评论完毕')
   })

})
req.on('error', function (e) {
   console.log('Error ' + e.message)
})
req.write(postData);
req.end()


status: 200

headers: {"server":"nginx","date":"Thu, 09 Nov 2017 02:57:37 GMT","content-type":"text/html; charset=utf-8","transfer-encoding":"chunked","

connection":"close","vary":"Accept-Encoding","expires":"Thu, 19 Nov 1981 08:52:00 GMT","cache-control":"no-store, no-cache, must-revalidate

, post-check=0, pre-check=0","pragma":"no-cache","content-encoding":"gzip"}

true

object

评论完毕


qq_從未拥冇談何矢佉_04175471
浏览 3015回答 0
0回答
随时随地看视频慕课网APP

相关分类

Node.js
我要回答