two responses returned for single POST request

Eden Li eden at mojiti.com
Fri Jan 23 07:04:53 MSK 2009


Hi all,

I'm seeing nginx return 2 response bodies for a single POST request
with a body.  Using netcat, I only see one response returned on the
command line, but running ngrep I can see two actually on the wire.
When this request is nested in a string of requests on a persistent
connection, the repeated response is mixed up with the subsequent
request.

I have tested this against both nginx 0.6.34 and 0.7.31.  The problem
exists in both versions.

A sample request/response is listed here:

POST /redirect HTTP/1.1
Host: 10.16.3.24:8008
Accept-Encoding: identity
Content-Length: 1
(1 space content)

HTTP/1.1 302 Moved Temporarily
Server: nginx/0.6.34
Date: Fri, 23 Jan 2009 03:54:58 GMT
Content-Type: text/html
Content-Length: 161
Connection: keep-alive
Location: http://www.test.com/
(302 body here)

I compiled nginx --with-debug and activated debug_http logging, here
it is for this request:

2009/01/22 19:58:22 [debug] 8168#0: *9 http process request line
2009/01/22 19:58:22 [debug] 8168#0: *9 http request line: "POST
/redirect HTTP/1.1"
2009/01/22 19:58:22 [debug] 8168#0: *9 http uri: "/redirect"
2009/01/22 19:58:22 [debug] 8168#0: *9 http args: ""
2009/01/22 19:58:22 [debug] 8168#0: *9 http exten: ""
2009/01/22 19:58:22 [debug] 8168#0: *9 http process request header line
2009/01/22 19:58:22 [debug] 8168#0: *9 http header: "Host: 10.16.3.24:8008"
2009/01/22 19:58:22 [debug] 8168#0: *9 http header: "Accept-Encoding: identity"
2009/01/22 19:58:22 [debug] 8168#0: *9 http header: "Content-Length: 1"
2009/01/22 19:58:22 [debug] 8168#0: *9 http header done
2009/01/22 19:58:22 [debug] 8168#0: *9 generic phase: 0
2009/01/22 19:58:22 [debug] 8168#0: *9 find location for "/redirect"
2009/01/22 19:58:22 [debug] 8168#0: *9 find location: "/redirect"
2009/01/22 19:58:22 [debug] 8168#0: *9 using configuration "/redirect"
2009/01/22 19:58:22 [debug] 8168#0: *9 http cl:1 max:1048576
2009/01/22 19:58:22 [debug] 8168#0: *9 generic phase: 2
2009/01/22 19:58:22 [debug] 8168#0: *9 http script regex: ".*"
2009/01/22 19:58:22 [debug] 8168#0: *9 http script copy: "http://www.test.com/"
2009/01/22 19:58:22 [debug] 8168#0: *9 http script regex end
2009/01/22 19:58:22 [debug] 8168#0: *9 http finalize request: 302, "/redirect?"
2009/01/22 19:58:22 [debug] 8168#0: *9 http special response: 302, "/redirect"
2009/01/22 19:58:22 [debug] 8168#0: *9 http set discard body
2009/01/22 19:58:22 [debug] 8168#0: *9 HTTP/1.1 302 Moved Temporarily
Server: nginx/0.6.34
Date: Fri, 23 Jan 2009 03:58:22 GMT
Content-Type: text/html
Content-Length: 161
Connection: keep-alive
Location: http://www.test.com/


2009/01/22 19:58:22 [debug] 8168#0: *9 http write filter: l:0 f:0 s:195
2009/01/22 19:58:22 [debug] 8168#0: *9 http output filter "/redirect?"
2009/01/22 19:58:22 [debug] 8168#0: *9 copy filter: "/redirect?"
2009/01/22 19:58:22 [debug] 8168#0: *9 http postpone filter
"/redirect?" 000000000BC91E18
2009/01/22 19:58:22 [debug] 8168#0: *9 http postpone filter out "/redirect?"
2009/01/22 19:58:22 [debug] 8168#0: *9 http write filter: l:1 f:0 s:356
2009/01/22 19:58:22 [debug] 8168#0: *9 http write filter limit 0
2009/01/22 19:58:22 [debug] 8168#0: *9 http write filter 0000000000000000
2009/01/22 19:58:22 [debug] 8168#0: *9 copy filter: 0 "/redirect?"
2009/01/22 19:58:22 [debug] 8168#0: *9 http finalize request: 0, "/redirect?"
2009/01/22 19:58:22 [debug] 8168#0: *9 set http keepalive handler
2009/01/22 19:58:22 [debug] 8168#0: *9 http close request
2009/01/22 19:58:22 [debug] 8168#0: *9 http log handler
2009/01/22 19:58:22 [debug] 8168#0: *9 pipelined request
2009/01/22 19:58:22 [debug] 8168#0: *9 http process request line
2009/01/22 19:58:22 [info] 8168#0: *9 client closed prematurely
connection while reading client pipelined request line, client:
10.0.18.195, server: hstg-sweb01
2009/01/22 19:58:22 [debug] 8168#0: *9 http finalize request: 400, "?"
2009/01/22 19:58:22 [debug] 8168#0: *9 http close request
2009/01/22 19:58:22 [debug] 8168#0: *9 http log handler
2009/01/22 19:58:22 [debug] 8168#0: *9 close http connection: 27

The nginx config for this setup is:

daemon off;
error_log /tmp/error.log debug_http;
events { worker_connections 1024; }

http {
  server {
    listen 8008;
    root /tmp/http;

    location /redirect {
      rewrite .* http://www.test.com/ redirect;
    }
  }
}





More information about the nginx mailing list