[PATCH 3 of 5] SSI: response might be truncated after include with wait="yes"

Maxim Dounin mdounin at mdounin.ru
Fri Jan 15 14:49:30 MSK 2010


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1263229555 -10800
# Node ID 5cc739cb96a7c5742d3b96415cafa8ef44afd1a4
# Parent  186e9471419a07250d144e390b43cd1cf7dcd561
SSI: response might be truncated after include with wait="yes".

In 0.7.29+ this also affects include file="..." (as it has wait="yes"
implicitly in 0.7.29+).  The bug had appeared in 0.7.25.

Reported by:	Maxim Khitrov

diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c
--- a/src/http/modules/ngx_http_ssi_filter_module.c
+++ b/src/http/modules/ngx_http_ssi_filter_module.c
@@ -71,6 +71,8 @@ typedef enum {
 
 static ngx_int_t ngx_http_ssi_output(ngx_http_request_t *r,
     ngx_http_ssi_ctx_t *ctx);
+static void ngx_http_ssi_buffering(ngx_http_request_t *r,
+    ngx_http_ssi_ctx_t *ctx);
 static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r,
     ngx_http_ssi_ctx_t *ctx);
 static ngx_str_t *ngx_http_ssi_get_variable(ngx_http_request_t *r,
@@ -798,6 +800,7 @@ ngx_http_ssi_body_filter(ngx_http_reques
                 }
 
                 if (rc == NGX_DONE || rc == NGX_AGAIN || rc == NGX_ERROR) {
+                    ngx_http_ssi_buffering(r, ctx);
                     return rc;
                 }
             }
@@ -950,14 +953,21 @@ ngx_http_ssi_output(ngx_http_request_t *
         }
     }
 
+    ngx_http_ssi_buffering(r, ctx);
+
+    return rc;
+}
+
+
+static void
+ngx_http_ssi_buffering(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx)
+{
     if (ctx->in || ctx->buf) {
         r->buffered |= NGX_HTTP_SSI_BUFFERED;
 
     } else {
         r->buffered &= ~NGX_HTTP_SSI_BUFFERED;
     }
-
-    return rc;
 }
 
 



More information about the nginx-devel mailing list