openresty / echo-nginx-module

An Nginx module for bringing the power of "echo", "sleep", "time" and more to Nginx's config file
http://wiki.nginx.org/NginxHttpEchoModule
BSD 2-Clause "Simplified" License
1.17k stars 255 forks source link

`-n` option will bypass all the strings following an empty varaiable #33

Closed aCayF closed 10 years ago

aCayF commented 10 years ago

conf snippet as follows:

    location /echo {
        set $empty "";
        echo -n $empty hello world;
    }

a test case which expected an empty response body passed, i reviewed the code, and found the related code snippet:

    if (opts && opts->nelts > 0) {
        opt = opts->elts;
        if (opt[0].len == 1 && opt[0].data[0] == 'n') {
            goto done;
        }
    }

    if (cl && cl->buf == NULL) {
        cl = cl->next;
    }

is switching these two block codes a possible solution for the reported problem?

agentzh commented 10 years ago

@aCayF Already fixed in master. Thank you for the test case and suggested fix!

aCayF commented 10 years ago

i think with this path, it is impossible for the second condition in the related code to happen, so could we just omit it ?