]> git.kaiwu.me - nginx.git/commitdiff
Sub filter: fixed subrequests handling.
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 27 May 2014 12:37:35 +0000 (16:37 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 27 May 2014 12:37:35 +0000 (16:37 +0400)
In particular, properly output partial match at the end of a subrequest
response (much like we do at the end of a response), and reset/set the
last_in_chain flag as appropriate.

Reported by KAWAHARA Masashi.

src/http/modules/ngx_http_sub_filter_module.c

index a4d666bed2b1e00fb09fbf968ad4a852ee5f32f0..3ba59d627309da8c43b32438ee3b23e00928faa0 100644 (file)
@@ -305,6 +305,7 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
                 b->last = ctx->copy_end;
                 b->shadow = NULL;
                 b->last_buf = 0;
+                b->last_in_chain = 0;
                 b->recycled = 0;
 
                 if (b->in_file) {
@@ -374,7 +375,9 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
             continue;
         }
 
-        if (ctx->buf->last_buf && ctx->looked.len) {
+        if (ctx->looked.len
+            && (ctx->buf->last_buf || ctx->buf->last_in_chain))
+        {
             cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
             if (cl == NULL) {
                 return NGX_ERROR;
@@ -394,7 +397,7 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
             ctx->looked.len = 0;
         }
 
-        if (ctx->buf->last_buf || ctx->buf->flush
+        if (ctx->buf->last_buf || ctx->buf->flush || ctx->buf->sync
             || ngx_buf_in_memory(ctx->buf))
         {
             if (b == NULL) {
@@ -414,6 +417,7 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
             }
 
             b->last_buf = ctx->buf->last_buf;
+            b->last_in_chain = ctx->buf->last_in_chain;
             b->flush = ctx->buf->flush;
             b->shadow = ctx->buf;