<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="en-IL" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Thanks<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">nginx <nginx-bounces@nginx.org> on behalf of Maxim Dounin <mdounin@mdounin.ru><br>
<b>Date: </b>Wednesday, 21 June 2023 at 19:01<br>
<b>To: </b>Yuval Abadi via nginx <nginx@nginx.org><br>
<b>Subject: </b>Re: nginx_http_write_filter_module.c<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">EXTERNAL MAIL: nginx-bounces@nginx.org<br>
<br>
Hello!<br>
<br>
On Wed, Jun 21, 2023 at 11:36:54AM +0000, Yuval Abadi via nginx wrote:<br>
<br>
> Nginx 1.23.2<br>
> <br>
> The cpi ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)<br>
> <br>
> Loop over the request out buffers and in chain<br>
> <br>
> If calculate size of combined buffer to write.<br>
> <br>
> I add body replacement on chain.<br>
> It have value, but ngx_buf_size(cl->buf);<br>
> Return it have 0. Size.<br>
> <br>
> (l->buf->last - cl->buf->pos) give the correct size<br>
> <br>
> So the buffer not written.<br>
> <br>
> Only the header part send back to client<br>
> <br>
> Any idea?<br>
> <br>
> 2023/06/21 10:45:31 [debug] 22962#22962: *3 write old buf t:1 f:0 00005600970D81E0, pos 00005600970D81E0, size: 179 file: 0, size: 0<br>
> 2023/06/21 10:45:31 [debug] 22962#22962: *3 write new buf t:0 f:0 00005600970D8098, pos 00005600970D8098, size: 247 file: 0, size: 0<br>
> 2023/06/21 10:45:31 [debug] 22962#22962: *3 http write filter: l:1 f:0 s:179<br>
> 2023/06/21 10:45:31 [debug] 22962#22962: *3 http write filter limit 2097152<br>
> 2023/06/21 10:45:31 [debug] 22962#22962: *3 writev: 179 of 179<br>
<br>
Note the "t:0" part in the relevant debug log line: it suggests <br>
that the cl->buf->temporary flag is not set.<br>
<br>
If the cl->buf->memory flag isn't set as well, this basically <br>
means that buffer does not reference any memory at all (even if <br>
cl->buf->post / cl->buf->last pointers are set). For such a <br>
buffer ngx_buf_size() will return the file size. And, since the <br>
buffer does not reference file data as well (note "f:0"), it is <br>
expected to be 0 (and it is, as per "file: 0, size: 0").<br>
<br>
So it looks like the behaviour you observe is the result of <br>
forgotten cl->buf->memory (or cl->buf->temporary) flag. Check <br>
your code to see if the buffer flags are set correctly, it looks <br>
like they aren't.<br>
<br>
See<br>
<br>
<a href="http://nginx.org/en/docs/dev/development_guide.html#buffer">https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnginx.org%2Fen%2Fdocs%2Fdev%2Fdevelopment_guide.html%23buffer&data=05%7C01%7Cy.abadi%40f5.com%7C93490412a0ae47a77b2808db7270cf46%7Cdd3dfd2f6a3b40d19be0bf8327d81c50%7C0%7C0%7C638229601077880722%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=lfQi%2FWoc7nk3Zr8R6I1X9DAE%2BZ36sfkMT6%2Fnw7YFgR8%3D&reserved=0</a><br>
<br>
for basic information about memory buffers and some basic <br>
examples. For additional information, check nginx code.<br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/">https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmdounin.ru%2F&data=05%7C01%7Cy.abadi%40f5.com%7C93490412a0ae47a77b2808db7270cf46%7Cdd3dfd2f6a3b40d19be0bf8327d81c50%7C0%7C0%7C638229601077880722%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rrIFE5kKXycRGSmQ64bP%2BwDfaqpEVKZfndVRYmgxNyE%3D&reserved=0</a><br>
_______________________________________________<br>
nginx mailing list<br>
nginx@nginx.org<br>
<a href="https://mailman.nginx.org/mailman/listinfo/nginx">https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.nginx.org%2Fmailman%2Flistinfo%2Fnginx&data=05%7C01%7Cy.abadi%40f5.com%7C93490412a0ae47a77b2808db7270cf46%7Cdd3dfd2f6a3b40d19be0bf8327d81c50%7C0%7C0%7C638229601077880722%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=R77KnZSvlfE6Uy7%2BHMZ5FwuvhKWrNJboV3tkV%2Frm2wc%3D&reserved=0</a><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>