status是304
测试的结果是304,304表示请求的资源并没有被修改,为什么status会是304呢,求告知
测试的结果是304,304表示请求的资源并没有被修改,为什么status会是304呢,求告知
2017-08-04
var http = require('http')
//可以把一个对象序列化
var querystring = require('querystring')
var postData = querystring.stringify({
'content': '我是大帅哥',
'mid': 8837
})
var options = {
hostname: 'www.imooc.com',
port: 80,
path: '/course',
method: 'POST',
headers: {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.8',
'Connection': 'keep-alive',
'Content-Length': postData.length,
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie': 'imooc_uuid=14593c67-5528-4593-a479-a2c4de67756a; imooc_isnew_ct=1499050220; loginstate=1; apsid=djZWFmZTc5MzZmZDdiZGUzMTNmNDNiYmNkYjAxOWIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMzAwMzEzNQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGEyMjczNTBjNmVlM2I1ZTA2MWExNDE4MmU2MDdiMjNjVvZlWVb2ZVk%3DZT; UM_distinctid=15d8c689b2314e-0d586e60dce58-333f5902-15f900-15d8c689b246cb; CNZZDATA1261110065=2018965245-1501296147-null%7C1501296147; PHPSESSID=hag17mgpq28mku2095bj1rq291; IMCDNS=0; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1501400028,1501486187,1501746416,1501835083; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1501836604; imooc_isnew=2; cvde=59842f4b50417-20',
'Host': 'www.imooc.com',
'Origin': 'http://www.imooc.com',
'Referer': 'http://www.imooc.com/video/8837',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 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()
这是代码
举报