<div dir="ltr"><div>You can either use separated variables between the main request and subrequests by creating new ones for subrequest after calling ngx_http_subrequest, or mark variable "$proxy_internal_body_length" as no_cacheable.<br>
</div><div><br></div><div style>See <a href="http://mailman.nginx.org/pipermail/nginx-devel/2013-May/003669.html">http://mailman.nginx.org/pipermail/nginx-devel/2013-May/003669.html</a> for more details.</div><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/5/2 Marat Dakota <span dir="ltr"><<a href="mailto:dakota@brokenpipe.ru" target="_blank">dakota@brokenpipe.ru</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">Hi.<div><br></div><div>My module makes a few subrequests with body (I populate sr->request_body and set Content-Length in sr-headers_in).</div><div><br></div><div>These subrequests are landing to a locations that look like:</div>

<div><div><br></div><div>    location /backend {</div><div>        internal;</div><div>        rewrite /backend(.+) $1 break;</div><div>        proxy_pass <a href="http://mybackend" target="_blank">http://mybackend</a>;<br>
</div><div>
    }</div><div><br></div><div><div>    location /backend2 {</div><div>        internal;</div><div>        rewrite /backend2(.+) $1 break;</div><div>        proxy_pass <a href="http://mybackend2" target="_blank">http://mybackend2</a>;<br>

</div><div>    }</div></div><div><br></div><div>The problem is that proxy_pass takes Content-Length from the first subrequest and uses it for the second subrequest. So, when the first subrequest is longer than the second one, the second one never ends, and when the first one is shorter, the second backend (mybackend2) receives incomplete body.</div>

<div><br></div><div>I've spent quite a time tracing the problem and for the moment I've figured out that Content-Length comes from these lines in ngx_http_proxy_module.c:</div><div><br></div><div>
<div>        while (*(uintptr_t *) e.ip) {</div><div>            code = *(ngx_http_script_code_pt *) e.ip;</div><div>            code((ngx_http_script_engine_t *) &e);</div><div>        }</div><div><br></div><div>
I haven't managed to go deeper at the moment.</div><div><br></div><div>So, question is — am I doing something wrong or is it a bug?</div><div><br></div><div>Thanks.</div><div><br></div><div>
--</div><div>Marat</div></div></div></div>
<br>_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br></blockquote></div><br></div></div>