Possible bug in output chains

Hi.

When doing some tests with mod_wsgi I have found a possible problem with
nginx output chains.

I write two separate buffers, of size <~ 1024 bytes, and a final
ngx_http_send_special(NGX_HTTP_LAST).

The problem is that nginx sends to the client the content of the last
buffer only, two times.

If the buffer is large enough, or if gzip filter is enable, the output
is correct.

I don’t know if this is a bug in mod_wsgi.

Thanks Manlio P.

Manlio P. ha scritto:

buffer only, two times.

I have tested this case with a buffer size of 16 bytes.

I have attached the output produced by nginx (and received by wget).

And here is an strace:

writev(7, [{“HTTP/1.1 200 OK\r\nDate: Tue, 09 Oct 2007 10:51:08
GMT\r\nContent-Type: text/plain\r\nTransfer-Encoding:
chunked\r\nConnection: keep-alive\r\nServer: Test-read\r\nX-Powered-By:
Python\r\nDate: \r\n\r\n”, 183}, {“10\r\n”, 4},
{"\0\0\0\0\34\265\f\10)\0\0\0\t\0\0\0", 16}, {"\r\n", 2}, {“10\r\n”, 4},
{"\0\0\0\0\34\265\f\10)\0\0\0\t\0\0\0", 16}, {"\r\n", 2}, {“0\r\n\r\n”,
5}], 8) = 232

writev(7, [{“HTTP/1.1 500 Internal Server Error\r\nDate: Tue, 09 Oct
2007 10:51:08 GMT\r\nContent-Type: text/html\r\nContent-Length:
193\r\nTransfer-Encoding: chunked\r\nConnection: close\r\nServer:
Test-read\r\nX-Powered-By: Python\r\nDate: \r\n\r\n”, 217}, {“c1\r\n”,
4}, {"\r\n500 Internal Server
Error\r\n<body bgcolor=“white”>\r\n

500
Internal Server Error

\r\n", 140},
{“
nginx/0.5.31\r\n\r\n\r\n”, 53},
{"\r\n0\r\n\r\n", 7}], 5) = 421

nginx sends the headers two times…

Regards Manlio P.

Manlio P. ha scritto:

If the buffer is large enough, or if gzip filter is enable, the output
is correct.

I don’t know if this is a bug in mod_wsgi.

Some more info: if I call finalize_request with an error, after having
sent the second buffer, then nginx sends incorrect trailing body to the
client.

I have tested this case with a buffer size of 16 bytes.

I have attached the output produced by nginx (and received by wget).

P.S.: for some reason the Date header is sent two times, I have to
investigate this.

Regards Manlio P.