Close the connection instead of the "keep-alive" setting

I am trying to disable a parameter keep-alivein a very simple application express. I tried the answer from someone who does the same in the old version :

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);
});

However Connection, still set to 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%

How can i change keep-aliveto close?

Version

node 0.10.8
express 4.1.1

+4
source share
1 answer

It works great for me. I am testing it on localhost of the same version.

$ curl -D - 127.0.0.1:3000
HTTP/1.1 200 OK
X-Powered-By: Express
Connection: close
Proof: close
Content-Type: text/html; charset=utf-8
Content-Length: 5
ETag: "907060870"
Date: Sun, 11 May 2014 08:52:32 GMT

hello%

I see what you can use nginxfor proxies. As below:

client--nginx proxy--real server

, keep-alive nginx.

+3

Source: https://habr.com/ru/post/1540089/


All Articles