Welcome! Log In Create A New Profile

Advanced

Re: nginx+lua reverse proxy empty body

agentzh
November 27, 2012 06:44PM
Hello!

On Tue, Nov 27, 2012 at 2:28 AM, Bart van Deenen wrote:
> The problem I have basically that the ngx.arg[1] is an empty string
> (sometimes, timing dependent?) on url's that are definitely not empty.
>

It is normal that ngx.arg[1] is an empty string in the body filters
when the upstream module generates "pure special bufs" like those with
only the "last_buf" flag set (i.e., the eof flag set on the Lua land).

It's normal that for a given response, the output body filter gets
called multiple times because that's exactly how streaming processing
works in Nginx (you surely do not want to buffer all the data at a
time for huge responses).

And the response body may be fed into your body filter in multiple
data chunks. You should always be prepared for that in your Lua code.

Please refer to the documentation for body_filter_by_lua for more information:

http://wiki.nginx.org/HttpLuaModule#body_filter_by_lua

BTW, doing simple regex match in body filters may not always work as
expected because the nginx upstream module may split the response body
into chunks in an arbitrary way (e.g., splitting in the middle of the
word "Speel", for example).

I've been working on the sregex C library that will support streaming
match just like Ragel:

https://github.com/agentzh/sregex

It's still in progress though but it'll soon be usable on the Lua land :)

Best regards,
-agentzh

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

nginx+lua reverse proxy empty body

Bart van Deenen November 27, 2012 05:30AM

Re: nginx+lua reverse proxy empty body

agentzh November 27, 2012 06:44PM

RE: nginx+lua reverse proxy empty body

Bart van Deenen November 28, 2012 10:30AM

Re: nginx+lua reverse proxy empty body

agentzh November 29, 2012 08:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 166
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