Mercurial > hg > nginx-vendor-current
comparison src/http/modules/ngx_http_ssi_filter_module.c @ 426:e7dbea1ee115 NGINX_0_7_25
nginx 0.7.25
*) Change: in subrequest processing.
*) Change: now POSTs without "Content-Length" header line are allowed.
*) Bugfix: now the "limit_req" and "limit_conn" directives log a
prohibition reason.
*) Bugfix: in the "delete" parameter of the "geo" directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 08 Dec 2008 00:00:00 +0300 |
parents | 05981f639d21 |
children | fd759445d8a8 |
comparison
equal
deleted
inserted
replaced
425:f64d9e30046c | 426:e7dbea1ee115 |
---|---|
373 ngx_int_t rc; | 373 ngx_int_t rc; |
374 ngx_buf_t *b; | 374 ngx_buf_t *b; |
375 ngx_uint_t i, index; | 375 ngx_uint_t i, index; |
376 ngx_chain_t *cl, **ll; | 376 ngx_chain_t *cl, **ll; |
377 ngx_table_elt_t *param; | 377 ngx_table_elt_t *param; |
378 ngx_http_request_t *pr; | |
379 ngx_http_ssi_ctx_t *ctx, *mctx; | 378 ngx_http_ssi_ctx_t *ctx, *mctx; |
380 ngx_http_ssi_block_t *bl; | 379 ngx_http_ssi_block_t *bl; |
381 ngx_http_ssi_param_t *prm; | 380 ngx_http_ssi_param_t *prm; |
382 ngx_http_ssi_command_t *cmd; | 381 ngx_http_ssi_command_t *cmd; |
383 ngx_http_ssi_loc_conf_t *slcf; | 382 ngx_http_ssi_loc_conf_t *slcf; |
401 if (ngx_chain_add_copy(r->pool, &ctx->in, in) == NGX_ERROR) { | 400 if (ngx_chain_add_copy(r->pool, &ctx->in, in) == NGX_ERROR) { |
402 return NGX_ERROR; | 401 return NGX_ERROR; |
403 } | 402 } |
404 } | 403 } |
405 | 404 |
405 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
406 "http ssi filter \"%V?%V\"", &r->uri, &r->args); | |
407 | |
406 if (ctx->wait) { | 408 if (ctx->wait) { |
407 if (r->connection->data != r) { | 409 |
408 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 410 if (r != r->connection->data) { |
409 "http ssi filter \"%V\" wait", &r->uri); | 411 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
412 "http ssi filter wait \"%V?%V\" non-active", | |
413 &ctx->wait->uri, &ctx->wait->args); | |
414 | |
410 return NGX_AGAIN; | 415 return NGX_AGAIN; |
411 } | 416 } |
412 | 417 |
413 for (pr = ctx->wait->parent; pr; pr = pr->parent) { | 418 if (ctx->wait->done) { |
414 if (pr == r) { | 419 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
415 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 420 "http ssi filter wait \"%V?%V\" done", |
416 "http ssi filter \"%V\" flush", &r->uri); | 421 &ctx->wait->uri, &ctx->wait->args); |
417 | 422 |
418 rc = ngx_http_next_body_filter(r, NULL); | |
419 | |
420 if (ctx->wait->done) { | |
421 ctx->wait = NULL; | |
422 } | |
423 | |
424 if (rc == NGX_ERROR || rc == NGX_AGAIN) { | |
425 return rc; | |
426 } | |
427 | |
428 break; | |
429 } | |
430 } | |
431 | |
432 if (ctx->wait == r) { | |
433 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
434 "http ssi filter \"%V\" continue", &r->uri); | |
435 ctx->wait = NULL; | 423 ctx->wait = NULL; |
424 | |
425 } else { | |
426 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
427 "http ssi filter wait \"%V?%V\"", | |
428 &ctx->wait->uri, &ctx->wait->args); | |
429 | |
430 return ngx_http_next_body_filter(r, NULL); | |
436 } | 431 } |
437 } | 432 } |
438 | 433 |
439 slcf = ngx_http_get_module_loc_conf(r, ngx_http_ssi_filter_module); | 434 slcf = ngx_http_get_module_loc_conf(r, ngx_http_ssi_filter_module); |
440 | |
441 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
442 "http ssi filter \"%V\"", &r->uri); | |
443 | 435 |
444 while (ctx->in || ctx->buf) { | 436 while (ctx->in || ctx->buf) { |
445 | 437 |
446 if (ctx->buf == NULL ){ | 438 if (ctx->buf == NULL ){ |
447 ctx->buf = ctx->in->buf; | 439 ctx->buf = ctx->in->buf; |
786 | 778 |
787 goto ssi_error; | 779 goto ssi_error; |
788 } | 780 } |
789 } | 781 } |
790 | 782 |
791 if (cmd->flush) { | 783 if (cmd->flush && ctx->out) { |
792 | 784 |
793 if (ctx->out) { | 785 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
794 rc = ngx_http_ssi_output(r, ctx); | 786 "ssi flush"); |
795 | 787 |
796 } else { | 788 if (ngx_http_ssi_output(r, ctx) == NGX_ERROR) { |
797 rc = ngx_http_next_body_filter(r, NULL); | |
798 } | |
799 | |
800 if (rc == NGX_ERROR) { | |
801 return NGX_ERROR; | 789 return NGX_ERROR; |
802 } | 790 } |
803 } | 791 } |
804 | 792 |
805 rc = cmd->handler(r, ctx, params); | 793 rc = cmd->handler(r, ctx, params); |
1999 } else { | 1987 } else { |
2000 psr->data = bl[i].bufs; | 1988 psr->data = bl[i].bufs; |
2001 } | 1989 } |
2002 } | 1990 } |
2003 | 1991 |
1992 if (wait) { | |
1993 flags |= NGX_HTTP_SUBREQUEST_WAITED; | |
1994 } | |
1995 | |
2004 if (set) { | 1996 if (set) { |
2005 key = ngx_hash_strlow(set->data, set->data, set->len); | 1997 key = ngx_hash_strlow(set->data, set->data, set->len); |
2006 | 1998 |
2007 psr = ngx_palloc(r->pool, sizeof(ngx_http_post_subrequest_t)); | 1999 psr = ngx_palloc(r->pool, sizeof(ngx_http_post_subrequest_t)); |
2008 if (psr == NULL) { | 2000 if (psr == NULL) { |
2031 var->key = key; | 2023 var->key = key; |
2032 var->value = ngx_http_ssi_null_string; | 2024 var->value = ngx_http_ssi_null_string; |
2033 psr->data = &var->value; | 2025 psr->data = &var->value; |
2034 } | 2026 } |
2035 | 2027 |
2036 flags |= NGX_HTTP_SUBREQUEST_IN_MEMORY; | 2028 flags |= NGX_HTTP_SUBREQUEST_IN_MEMORY|NGX_HTTP_SUBREQUEST_WAITED; |
2037 } | 2029 } |
2038 | 2030 |
2039 rc = ngx_http_subrequest(r, uri, &args, &sr, psr, flags); | 2031 if (ngx_http_subrequest(r, uri, &args, &sr, psr, flags) != NGX_OK) { |
2040 | |
2041 if (rc == NGX_DONE) { | |
2042 return NGX_DONE; | |
2043 } | |
2044 | |
2045 if (rc == NGX_ERROR) { | |
2046 return NGX_HTTP_SSI_ERROR; | 2032 return NGX_HTTP_SSI_ERROR; |
2047 } | 2033 } |
2048 | 2034 |
2049 if (wait == NULL && set == NULL) { | 2035 if (wait == NULL && set == NULL) { |
2050 return NGX_OK; | 2036 return NGX_OK; |
2051 } | 2037 } |
2052 | 2038 |
2053 if (rc == NGX_AGAIN) { | 2039 if (ctx->wait == NULL) { |
2054 if (ctx->wait == NULL) { | 2040 ctx->wait = sr; |
2055 ctx->wait = sr; | 2041 |
2056 | 2042 return NGX_AGAIN; |
2057 } else { | 2043 |
2058 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | 2044 } else { |
2059 "only one subrequest may be waited at the same time"); | 2045 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
2060 } | 2046 "only one subrequest may be waited at the same time"); |
2061 } | 2047 } |
2062 | 2048 |
2063 return rc; | 2049 return NGX_OK; |
2064 } | 2050 } |
2065 | 2051 |
2066 | 2052 |
2067 static ngx_int_t | 2053 static ngx_int_t |
2068 ngx_http_ssi_stub_output(ngx_http_request_t *r, void *data, ngx_int_t rc) | 2054 ngx_http_ssi_stub_output(ngx_http_request_t *r, void *data, ngx_int_t rc) |