# HG changeset patch # User Igor Sysoev # Date 1275904459 0 # Node ID 17995396463d230198c66e7c780aebb4cf86e97a # Parent 667c22171519481fad76ad10007fa5f7b96a3cde merge r3454, r3455, r3486, r3496, r3519, r3523: SSI fixes: *) use content type of the parent request in SSI stub block output instead of default one *) SSI %s timefmt has no timezone offset *) change ngx_http_ssi_filter and ngx_http_charset_filter order *) do not store an encoded variable value as a new cached variable value *) fix SSI include stub for valid empty responses *) allow to use $uid_got in SSI and perl module diff --git a/auto/modules b/auto/modules --- a/auto/modules +++ b/auto/modules @@ -101,8 +101,8 @@ fi # ngx_http_range_header_filter # ngx_http_gzip_filter # ngx_http_postpone_filter +# ngx_http_ssi_filter # ngx_http_charset_filter -# ngx_http_ssi_filter # ngx_http_xslt_filter # ngx_http_image_filter_filter # ngx_http_sub_filter @@ -130,12 +130,6 @@ if [ $HTTP_POSTPONE = YES ]; then HTTP_SRCS="$HTTP_SRCS $HTTP_POSTPONE_FILTER_SRCS" fi -if [ $HTTP_CHARSET = YES ]; then - have=NGX_HTTP_CHARSET . auto/have - HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_CHARSET_FILTER_MODULE" - HTTP_SRCS="$HTTP_SRCS $HTTP_CHARSET_SRCS" -fi - if [ $HTTP_SSI = YES ]; then have=NGX_HTTP_SSI . auto/have HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_SSI_FILTER_MODULE" @@ -143,6 +137,12 @@ if [ $HTTP_SSI = YES ]; then HTTP_SRCS="$HTTP_SRCS $HTTP_SSI_SRCS" fi +if [ $HTTP_CHARSET = YES ]; then + have=NGX_HTTP_CHARSET . auto/have + HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_CHARSET_FILTER_MODULE" + HTTP_SRCS="$HTTP_SRCS $HTTP_CHARSET_SRCS" +fi + if [ $HTTP_XSLT = YES ]; then USE_LIBXSLT=YES HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_XSLT_FILTER_MODULE" 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 @@ -2061,9 +2061,9 @@ ngx_http_ssi_stub_output(ngx_http_reques out = data; if (!r->header_sent) { - if (ngx_http_set_content_type(r) != NGX_OK) { - return NGX_ERROR; - } + r->headers_out.content_type_len = + r->parent->headers_out.content_type_len; + r->headers_out.content_type = r->parent->headers_out.content_type; if (ngx_http_send_header(r) == NGX_ERROR) { return NGX_ERROR; @@ -2161,11 +2161,10 @@ ngx_http_ssi_echo(ngx_http_request_t *r, } } + p = value->data; + switch (ctx->encoding) { - case NGX_HTTP_SSI_NO_ENCODING: - break; - case NGX_HTTP_SSI_URL_ENCODING: len = 2 * ngx_escape_uri(NULL, value->data, value->len, NGX_ESCAPE_HTML); @@ -2177,11 +2176,9 @@ ngx_http_ssi_echo(ngx_http_request_t *r, } (void) ngx_escape_uri(p, value->data, value->len, NGX_ESCAPE_HTML); - - value->len += len; - value->data = p; } + len += value->len; break; case NGX_HTTP_SSI_ENTITY_ENCODING: @@ -2194,11 +2191,13 @@ ngx_http_ssi_echo(ngx_http_request_t *r, } (void) ngx_escape_html(p, value->data, value->len); - - value->len += len; - value->data = p; } + len += value->len; + break; + + default: /* NGX_HTTP_SSI_NO_ENCODING */ + len = value->len; break; } @@ -2213,8 +2212,8 @@ ngx_http_ssi_echo(ngx_http_request_t *r, } b->memory = 1; - b->pos = value->data; - b->last = value->data + value->len; + b->pos = p; + b->last = p + len; cl->buf = b; cl->next = NULL; @@ -2614,8 +2613,7 @@ ngx_http_ssi_date_gmt_local_variable(ngx return NGX_ERROR; } - v->len = ngx_sprintf(v->data, "%T", tp->sec + (gmt ? 0 : tp->gmtoff)) - - v->data; + v->len = ngx_sprintf(v->data, "%T", tp->sec) - v->data; return NGX_OK; } diff --git a/src/http/modules/ngx_http_userid_filter_module.c b/src/http/modules/ngx_http_userid_filter_module.c --- a/src/http/modules/ngx_http_userid_filter_module.c +++ b/src/http/modules/ngx_http_userid_filter_module.c @@ -545,7 +545,7 @@ ngx_http_userid_add_variables(ngx_conf_t { ngx_http_variable_t *var; - var = ngx_http_add_variable(cf, &ngx_http_userid_got, NGX_HTTP_VAR_NOHASH); + var = ngx_http_add_variable(cf, &ngx_http_userid_got, 0); if (var == NULL) { return NGX_ERROR; } diff --git a/src/http/ngx_http_copy_filter_module.c b/src/http/ngx_http_copy_filter_module.c --- a/src/http/ngx_http_copy_filter_module.c +++ b/src/http/ngx_http_copy_filter_module.c @@ -104,7 +104,9 @@ ngx_http_copy_filter(ngx_http_request_t ctx->output_filter = (ngx_output_chain_filter_pt) ngx_http_next_filter; ctx->filter_ctx = r; - r->request_output = 1; + if (in && in->buf && ngx_buf_size(in->buf)) { + r->request_output = 1; + } } rc = ngx_output_chain(ctx, in);