<div dir="ltr"><div>Hello,</div><div><br></div><div>I didn't receive any reply, is there something wrong with the patch ?</div><div><br></div><div>If more context is needed, I want to rewrite an url depending on the Content-Type header.<br></div><div><br></div><div>Regards.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 17 sept. 2020 à 10:39, Corentin REGAL <<a href="mailto:corentin.regal@gmail.com">corentin.regal@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span style="font-family:arial,sans-serif">Hello,</span></div><br><div>I fixed a bug when using map directive and rewrite.</div><div>Captured variables in the map directive override captures of the rewrite.<br></div><br><font size="4"><b>nginx.conf</b></font><br><span style="font-family:monospace">daemon off;<br>error_log  /var/log/nginx/error.log debug;<br>worker_processes  1;<br>events {<br>    worker_connections  1024;<br>}<br><br>http {<br>    include            mime.types;<br>    default_type       application/octet-stream;<br>    sendfile           on;<br>    keepalive_timeout  0;<br><br>    map $http_content_type $input_type {<br>        default  json;<br>        ~image/  image;<br>    }<br><br>    server {<br>        server_name localhost;<br>        listen 80;<br>        location / {<br>            rewrite "/(.+)" /$1_${input_type} redirect;<br>        }<br>    }<br></span><div><span style="font-family:monospace">}</span></div><div><span style="font-family:monospace"><br></span></div><div><font size="4"><span style="font-family:monospace"><b><font face="arial,sans-serif">before patch (/_image)<br></font></b></span></font></div><div><span style="font-family:monospace"><font face="arial,sans-serif">curl -v -H'Content-Type: image/png' localhost:80/predict</font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">...<br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">< Location: <a href="http://localhost/_image" target="_blank">http://localhost/_image</a></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">...<br></font></span></div><div><span style="font-family:monospace"><b><font face="arial,sans-serif"></font></b></span></div><div><span style="font-family:monospace"><b><font face="arial,sans-serif"><br></font></b></span></div><div><div><font size="4"><span style="font-family:monospace"><b><font face="arial,sans-serif">after patch (/predict_image)</font></b></span></font></div><div><span style="font-family:monospace"><font face="arial,sans-serif">curl -v -H'Content-Type: image/png' localhost:80/predict</font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">...<br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">< Location: <a href="http://localhost/predict_image" target="_blank">http://localhost/predict_image</a></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">...</font></span></div><span style="font-family:monospace"></span></div><div><span style="font-family:monospace"><br></span></div><div><font size="4"><span style="font-family:arial,sans-serif"><b>patch</b></span></font></div><div><span style="font-family:monospace"># HG changeset patch</span></div><div><span style="font-family:monospace"></span></div><span style="font-family:monospace"># User Corentin Regal <<a href="mailto:corentin.regal@gmail.com" target="_blank">corentin.regal@gmail.com</a>><br># Date 1600329166 0<br>#      Thu Sep 17 07:52:46 2020 +0000<br># Node ID a065d5f865e90a7426d37b30a9faa72e0966756f<br># Parent  052ecc68d35038b1b4adde12efe6249a92055f09<br>Fix ngx_http_map_find to not erase rewrite captures<br><br>diff -r 052ecc68d350 -r a065d5f865e9 src/http/ngx_http_variables.c<br>--- a/src/http/ngx_http_variables.c     Wed Sep 16 18:26:25 2020 +0300<br>+++ b/src/http/ngx_http_variables.c     Thu Sep 17 07:52:46 2020 +0000<br>@@ -2410,7 +2410,7 @@<br> <br>         for (i = 0; i < map->nregex; i++) {<br> <br>-            n = ngx_http_regex_exec(r, reg[i].regex, match);<br>+            n = ngx_regex_exec(reg[i].regex->regex, match, NULL, 0);<br> <br>             if (n == NGX_OK) {<br></span><div><span style="font-family:monospace">                 return reg[i].value;</span></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">It's my first time using Mercurial or a mailing list, I hope I did it right :)<br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">Regards,</font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif">Corentin</font><br></span></div></div>
</blockquote></div>