浏览器请求的'/'的时候,假如服务器重定向到'/test',这个时候请求'/test'的headers里面会有referer吗?为什么?怎样可以让浏览器带上?
var express = require('express')
, http = require('http')
, path = require('path');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 8888);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', function(req, res, next) {
res.redirect('/test');
});
app.get('/test', function(req, res, next) {
res.send(req.headers);
});
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
返回:
{
host: "localhost:8888",
connection: "keep-alive",
user-agent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4",
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
accept-encoding: "gzip,deflate,sdch",
accept-language: "en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4",
accept-charset: "UTF-8,*;q=0.5",
cookie: "nd_secret=44f180cce9c8e88023d056a4b6a06a116d81dbf0de5c95349100946a3d6fbc294826df4b1bc4b5ba30927fb7002bd427; connect.sid=s%3A0ajlt%2FaQVFfX%2Fn%2F7Bi%2Ffa%2B9z.3z9KvkiqVTozWD%2BMIm8XOOwzoINHTATA0pH7sYOeM7o"
}