comparison src/http/modules/ngx_http_sub_filter_module.c @ 5287:2dbc5e38b65d

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".
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 25 Jul 2013 14:54:48 +0400
parents 819c5b53d8b5
children 102d7117ffb8
comparison
equal deleted inserted replaced
5286:819c5b53d8b5 5287:2dbc5e38b65d
367 ctx->once = slcf->once; 367 ctx->once = slcf->once;
368 368
369 continue; 369 continue;
370 } 370 }
371 371
372 if (ctx->buf->last_buf && ctx->looked.len) {
373 cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
374 if (cl == NULL) {
375 return NGX_ERROR;
376 }
377
378 b = cl->buf;
379
380 ngx_memzero(b, sizeof(ngx_buf_t));
381
382 b->pos = ctx->looked.data;
383 b->last = b->pos + ctx->looked.len;
384 b->memory = 1;
385
386 *ctx->last_out = cl;
387 ctx->last_out = &cl->next;
388
389 ctx->looked.len = 0;
390 }
391
372 if (ctx->buf->last_buf || ctx->buf->flush 392 if (ctx->buf->last_buf || ctx->buf->flush
373 || ngx_buf_in_memory(ctx->buf)) 393 || ngx_buf_in_memory(ctx->buf))
374 { 394 {
375 if (b == NULL) { 395 if (b == NULL) {
376 cl = ngx_chain_get_free_buf(r->pool, &ctx->free); 396 cl = ngx_chain_get_free_buf(r->pool, &ctx->free);