agentzh agentzh at
Wed Dec 23 07:06:29 MSK 2009

On Wed, Dec 23, 2009 at 5:01 AM, dylanz <nginx-forum at> wrote:
> Hey agentzh!
> I noticed that "echo" isn't outputting on non-async events, for example:
> echo "before";
> set $memcached_key $uri;
> memcached_pass;
> echo "after";

Just as Marcus has said, it makes little sense to specify two content
handlers in the same location (here, ngx_echo's handler and
ngx_memcached's). Or you can use the filter directives of the ngx_echo
module, just as what I demonstrated earlier:

   location /foo {
       echo_before_body "before";
       set $memcached_key $uri;
       echo_after_body "after";

> That results in the contents of the memcached_pass, but doesn't include the echo output.

Because ngx_memcached wins in the tie :D ngx_echo sets the content
handler for that location first, and then ngx_memcached overrides it
with its own ;)

> I tried throwing in some echo_flush commands to see if that would help, but it didn't.
> However, it does work if I use the after/before echo commands, for example:
> echo_before_body "before";
> set $memcached_key $uri;
> memcached_pass;
> echo_after_body "after";

Sure, because here you use ngx_echo's output filter and it always works ;)

> I added the -n flag option to echo.c, and it works when I'm not doing doing that proxy pass,

What do you mean by "when I'm not doing doing that proxy pass"?

> for example, this:
> echo -n "hello"
> echo -n "there"
> echo "world"
> ... produces "hello there world", all on one line.
> Is that known behaviour?

Sure. And I'd like the -n option gets parsed before variable
interpolation happens. For example

   set $foo '-n hello';
   echo $foo;

will output "-n hello\n", not "hello" :)

> If so, I'll work around it.  Otherwise, if it's not, let me know and
> I can see what I can do about fixing it :)

It's very nice of you to contribute to the ngx_echo module :)


More information about the nginx mailing list