【发布时间】:2017-11-22 08:10:36
【问题描述】:
我有这个 nodejs 代码:
var http = require('http');
var options ={
host: 'www.facebook.com',
port: 80,
path: '/',
method: 'GET'
};
console.log("Going to make request...");
var req = http.get(options, function(response){
console.log(response.statusCode);
response.pipe(process.stdout);
});
通过返回 html,它第一次运行良好。当我将“主机:”从 facebook.com 更改为 google.com 时,出现 302 错误。为什么我必须重定向它?第一个获取请求是否以某种方式缓存?
【问题讨论】:
-
请看this
标签: javascript node.js http webserver get-request