POST请求和nginx

时间:2012-04-16 14:58:55

标签: sockets nginx http-post keep-alive

我正在尝试向localhost:80(nginx-server)发送大量的帖子请求。

我发送的标题是:

POST /LINK HTTP/1.1
User-Agent: User agent
Host: localhost
Accept: */*
Connection: Keep-Alive
Content-Type: application/octet-stream
Content-Length: 16

DATA 16 BYTES

伪代码是:

TCPSocket sock('localhost', 80);
for(;;) {
   sock.sendPost();
}
sock.close();

但服务器返回第一时间:

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 16 Apr 2012 14:54:26 GMT
Content-Type: application/json
Content-Length: 92
Connection: close

ANSWER 92 BYTES

因此服务器不能与周期中的所有其他后请求一起使用。

为什么Connection: Keep-Alive无效,服务器返回Connection: close

1 个答案:

答案 0 :(得分:0)

keepalive_timeoutkeepalive_requests设为proper values