Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] NGX_HTTP_SYNC flag in ngx_http_send_special

Maxim Dounin
May 06, 2012 02:42PM
Hello!

On Fri, May 04, 2012 at 07:52:33PM +0200, Manlio Perillo wrote:

> Patch is attached, against mercurial mirror changeset 47cb3497fbab.
>
>
> Use case:
>
> I'm updating my ngx_http_wsgi_module.
>
> In one of my test application, I return a chunk-encoded response.
> The problem is that after last buffer is sent, I raise an exception,
> causing Nginx to abort the request handling.
>
> This, in turn, cause an incorrect chunk encoding (Python httplib fails
> to read the response).
>
> Calling
> ngx_http_send_special(r, NGX_HTTP_FLUSH)
> after last buffer does not help, however I found that using my patch,
> calling
> ngx_http_send_special(r, NGX_HTTP_FLUSH | NGX_HTTP_SYNC)
> do help; now the response is correctly chunk encoded.
>
> Please note that I tested my patch using 0.7.59, since
> ngx_http_wsgi_module has some issues on recent Nginx versions (that I'm
> going to fix).

Just ngx_http_send_special(r, NGX_HTTP_FLUSH) should be enough to
flush internal buffers, but please not that it doesn't mean that
response is actually sent - there still may be buffering on socket
level etc. If you abort request handling (not sure how you do it)
- it may result in incomplete response sent.

Not sure about 0.7.59, it's really old, but if you'll still see
the problem with 1.2.0 - please report more details, we probably
want to fix this properly.

> Also note that I can not use NGX_HTTP_LAST (due to how
> ngx_http_wsgi_module is implemented), and I'm not sure if is it correct
> to set sync = 1 for a buffer that is not the last one.

Setting sync = 1 on intermediate buffers is ok, but it shouldn't
be needed to explicitly sent such buffers.

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] NGX_HTTP_SYNC flag in ngx_http_send_special

Manlio Perillo 1284 May 04, 2012 02:52PM

Re: [PATCH] NGX_HTTP_SYNC flag in ngx_http_send_special

Maxim Dounin 473 May 06, 2012 02:42PM

Re: [PATCH] NGX_HTTP_SYNC flag in ngx_http_send_special

Manlio Perillo 627 May 06, 2012 03:24PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 134
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready