我试图keep-alive
在一个非常简单的express
应用程序中禁用该设置.我尝试了在旧版本中做同样事情的人给出的答案:
var express = require('express'); var app = express(); app.get('/', function(req, res) { res.set('Connection', 'close'); // attempting to override default (keep-alive) res.set('Proof', 'close'); // just to show that this should modify the header value res.send('hello'); }); var server = app.listen(3000, function() { console.log('Listening on port %d', server.address().port); });
但是,Connection
仍然设置为keep-alive
:
$ curl -D - http://my-test-site.com HTTP/1.1 200 OK Server: nginx/1.4.7 Date: Sun, 11 May 2014 08:07:51 GMT Content-Type: text/html; charset=utf-8 Content-Length: 5 Connection: keep-alive X-Powered-By: Express Proof: close ETag: "907060870" hello%
我怎样才能换keep-alive
到close
?
节点0.10.8
表示4.1.1