0

根据文档,默认情况下应发送 Date 响应标头。

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

卷曲上面的示例我得到:

C:\Users\Hans>curl localhost:1337 -i
HTTP/1.1 200 OK
Content-Type: text/plain
Connection: keep-alive
Transfer-Encoding: chunked

Hello World

没有日期标题。即使我设置了,response.sendDate = true我也没有得到 Date 标题。怎么了?

4

1 回答 1

0

从 0.8.1 升级到 0.8.2 现在可以使用了

C:\Users\Hans>curl localhost:1337 -i
HTTP/1.1 200 OK
Content-Type: text/plain
Date: Fri, 13 Jul 2012 10:52:59 GMT
Connection: keep-alive
Transfer-Encoding: chunked

Hello World
于 2012-07-13T10:54:12.977 回答