<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">AFAIK you do not control the order of filters, and when you are building a filter, you deal with data on-the-fly, which means your filter might be invoked with a partial response coming from other filters.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Moreover, the module needs to 'win' its selection on a specific event.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">I suggest you read some available literature (ex: <a href="http://www.evanmiller.org/nginx-modules-guide.html">http://www.evanmiller.org/nginx-modules-guide.html</a>, specifically <a href="http://www.evanmiller.org/nginx-modules-guide.html#filters-body">http://www.evanmiller.org/nginx-modules-guide.html#filters-body</a> which seems to implement something close to what you wish).<br></div><div class="gmail_extra"><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">There is most probably more competent people to that matter who would give you better docs, but this is a head start I guess.</div><div><div class="gmail_signature" data-smartmail="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Tue, Jul 5, 2016 at 6:06 AM, Raghavan, Gopal <span dir="ltr"><<a href="mailto:gopal.raghavan@here.com" target="_blank">gopal.raghavan@here.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="white" link="#0563C1" vlink="#954F72" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Hi,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I have the following three directives:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">location = /hello {</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> hello_world;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> hola_mundo on;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> bonjour_monde on;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">hello_world is an nginx handler module that provides content “hello world”</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">hola_mundo and bonjour_monde are filters that add to the chain strings “hola mundo” and “bonjour monde” respectively.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Here is the output:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">curl "<a href="http://localhost:8090/hello" target="_blank">http://localhost:8090/hello</a>"</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">hello worldhola mundobonjour monde</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Switching the filter directives in location block has no impact on output string.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">For eg: </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">location = /hello {</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> hello_world;</span><u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in"><span style="font-size:11.0pt">bonjour_monde on;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> hola_mundo on;</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">}</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Here is the output:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">curl "<a href="http://localhost:8090/hello" target="_blank">http://localhost:8090/hello</a>"</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">hello worldhola mundobonjour monde</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">How do I control the order of execution of filters?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I already looked at objs/ngx_modules.c and auto/modules. My custom handlers and filters are not listed there.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">One thing that I observed is that the order of listing the load_module modules/*.so in conf/nginx.conf does impact the order of execution of the filters.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Is there any other trick to adjust the execution order within the location block?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">--</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Gopal</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<br>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br></div></div>