comparison src/http/modules/ngx_http_sub_filter_module.c @ 5710:9e9c1310d17c

Sub filter: fixed subrequests handling. 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.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 27 May 2014 16:37:35 +0400
parents 102d7117ffb8
children e491b26fa5a1
comparison
equal deleted inserted replaced
5709:44532046d9d7 5710:9e9c1310d17c
303 303
304 b->pos = ctx->copy_start; 304 b->pos = ctx->copy_start;
305 b->last = ctx->copy_end; 305 b->last = ctx->copy_end;
306 b->shadow = NULL; 306 b->shadow = NULL;
307 b->last_buf = 0; 307 b->last_buf = 0;
308 b->last_in_chain = 0;
308 b->recycled = 0; 309 b->recycled = 0;
309 310
310 if (b->in_file) { 311 if (b->in_file) {
311 b->file_last = b->file_pos + (b->last - ctx->buf->pos); 312 b->file_last = b->file_pos + (b->last - ctx->buf->pos);
312 b->file_pos += b->pos - ctx->buf->pos; 313 b->file_pos += b->pos - ctx->buf->pos;
372 ctx->once = slcf->once; 373 ctx->once = slcf->once;
373 374
374 continue; 375 continue;
375 } 376 }
376 377
377 if (ctx->buf->last_buf && ctx->looked.len) { 378 if (ctx->looked.len
379 && (ctx->buf->last_buf || ctx->buf->last_in_chain))
380 {
378 cl = ngx_chain_get_free_buf(r->pool, &ctx->free); 381 cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
379 if (cl == NULL) { 382 if (cl == NULL) {
380 return NGX_ERROR; 383 return NGX_ERROR;
381 } 384 }
382 385
392 ctx->last_out = &cl->next; 395 ctx->last_out = &cl->next;
393 396
394 ctx->looked.len = 0; 397 ctx->looked.len = 0;
395 } 398 }
396 399
397 if (ctx->buf->last_buf || ctx->buf->flush 400 if (ctx->buf->last_buf || ctx->buf->flush || ctx->buf->sync
398 || ngx_buf_in_memory(ctx->buf)) 401 || ngx_buf_in_memory(ctx->buf))
399 { 402 {
400 if (b == NULL) { 403 if (b == NULL) {
401 cl = ngx_chain_get_free_buf(r->pool, &ctx->free); 404 cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
402 if (cl == NULL) { 405 if (cl == NULL) {
412 *ctx->last_out = cl; 415 *ctx->last_out = cl;
413 ctx->last_out = &cl->next; 416 ctx->last_out = &cl->next;
414 } 417 }
415 418
416 b->last_buf = ctx->buf->last_buf; 419 b->last_buf = ctx->buf->last_buf;
420 b->last_in_chain = ctx->buf->last_in_chain;
417 b->flush = ctx->buf->flush; 421 b->flush = ctx->buf->flush;
418 b->shadow = ctx->buf; 422 b->shadow = ctx->buf;
419 423
420 b->recycled = ctx->buf->recycled; 424 b->recycled = ctx->buf->recycled;
421 } 425 }