diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2013-07-25 14:54:48 +0400 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2013-07-25 14:54:48 +0400 |
commit | ce7a5a05375dbf452a2cbe136c922f7718c15d5c (patch) | |
tree | 53f2cac2330cdaaec962eff3785cf9bc82ee2810 /src | |
parent | 68fab7c8c4722e86dc171f99ce795976574d4348 (diff) | |
download | nginx-ce7a5a05375dbf452a2cbe136c922f7718c15d5c.tar.gz nginx-ce7a5a05375dbf452a2cbe136c922f7718c15d5c.zip |
Sub filter: fixed incomplete last buffer on partial match.
If a pattern was partially matched at a response end, partially matched
string wasn't send. E.g., a response "fo" was truncated to an empty response
if partially mathed by a pattern "foo".
Diffstat (limited to 'src')
-rw-r--r-- | src/http/modules/ngx_http_sub_filter_module.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_sub_filter_module.c b/src/http/modules/ngx_http_sub_filter_module.c index 3d32b0fbc..fcf6274cb 100644 --- a/src/http/modules/ngx_http_sub_filter_module.c +++ b/src/http/modules/ngx_http_sub_filter_module.c @@ -369,6 +369,26 @@ ngx_http_sub_body_filter(ngx_http_request_t *r, ngx_chain_t *in) continue; } + if (ctx->buf->last_buf && ctx->looked.len) { + cl = ngx_chain_get_free_buf(r->pool, &ctx->free); + if (cl == NULL) { + return NGX_ERROR; + } + + b = cl->buf; + + ngx_memzero(b, sizeof(ngx_buf_t)); + + b->pos = ctx->looked.data; + b->last = b->pos + ctx->looked.len; + b->memory = 1; + + *ctx->last_out = cl; + ctx->last_out = &cl->next; + + ctx->looked.len = 0; + } + if (ctx->buf->last_buf || ctx->buf->flush || ngx_buf_in_memory(ctx->buf)) { |