# HG changeset patch # User Igor Sysoev # Date 1109690436 0 # Node ID d7c90bb5ce83dab08715e98f9c7b81c7df4b37be # Parent 7ce7b31c3c83936d3a729e443d5b8a4328239f56 nginx-0.1.23-RELEASE import *) Feature: the ngx_http_ssi_filter_module and the ssi, ssi_silent_errors, and ssi_min_file_chunk directives. The 'echo var="HTTP_..." default=""' and 'echo var="REMOTE_ADDR"' commands are supported. *) Feature: the %request_time log parameter. *) Feature: if the request has no the "Host" header line, then the "proxy_preserve_host" directive set this header line to the first server name of the "server_name" directive. *) Bugfix: nginx could not be built on platforms different from i386, amd64, sparc, and ppc; the bug had appeared in 0.1.22. *) Bugfix: the ngx_http_autoindex_module now shows the information not about the symlink, but about file or directory it points to. *) Bugfix: the %apache_length parameter logged the negative length of the response header if the no response was transferred to a client. diff --git a/auto/cc/gcc b/auto/cc/gcc --- a/auto/cc/gcc +++ b/auto/cc/gcc @@ -3,7 +3,7 @@ # gcc 2.7.2.3, 2.8.1, 2.95.4, -# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4, 3.4.2 +# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4.0, 3.4.2 # Solaris 7's /usr/ccs/bin/as does not support "-pipe" diff --git a/auto/options b/auto/options --- a/auto/options +++ b/auto/options @@ -48,7 +48,7 @@ NGX_HTTP_FASTCGI_TEMP_PATH= HTTP_CHARSET=YES HTTP_GZIP=YES HTTP_SSL=NO -HTTP_SSI=NO +HTTP_SSI=YES HTTP_ACCESS=YES HTTP_USERID=YES HTTP_AUTOINDEX=YES diff --git a/docs/xml/nginx/changes.xml b/docs/xml/nginx/changes.xml --- a/docs/xml/nginx/changes.xml +++ b/docs/xml/nginx/changes.xml @@ -9,6 +9,81 @@ nginx changelog + + + + +модуль ngx_http_ssi_filter_module и +директивы ssi, ssi_silent_errors и ssi_min_file_chunk. +Поддерживаются команды 'echo var="HTTP_..." default=""' и +'echo var="REMOTE_ADDR"'. + + +the ngx_http_ssi_filter_module and +the ssi, ssi_silent_errors, and ssi_min_file_chunk directives. +The 'echo var="HTTP_..." default=""' and 'echo var="REMOTE_ADDR"' commands +are supported. + + + + + +параметр лога %request_time. + + +the %request_time log parameter. + + + + + +если запрос пришёл без строки заголовка "Host", то директива +proxy_preserve_host устанавливает в качестве этого заголовка первое имя +сервера из директивы server_name. + + +if the request has no the "Host" header line, then the proxy_preserve_host +directive set this header line to the first server name of the server_name +directive. + + + + + +nginx не собирался на платформах, отличных от i386, amd64, sparc и ppc; +ошибка появилась в 0.1.22. + + +nginx could not be built on platforms different from i386, amd64, sparc и ppc; +bug appeared in 0.1.22. + + + + + +модуль ngx_http_autoindex_module теперь показывает информацию не о +символическом линке, а о файле или каталоге, на который он указывает. + + +the ngx_http_autoindex_module now shows the information not about the symlink, +but about file or directory it points to. + + + + + +если клиенту ничего не передавалось, то параметр %apache_length +записывал в лог отрицательную длину заголовка ответа. + + +the %apache_length parameter logged the negative length +of the response header if the no response was transferred to a client. + + + + + + @@ -19,7 +94,7 @@ the ngx_http_stub_status_module showed incorrect handled connections -statictics if the proxing or FastCGI server were used. +statistics if the proxing or FastCGI server were used. @@ -29,7 +104,7 @@ statictics if the proxing or FastCGI ser ошибка появилась в 0.1.21. -the installation pathes were incorrectly quoted on Linux and Solaris; +the installation paths were incorrectly quoted on Linux and Solaris; bug appeared in 0.1.21. @@ -46,7 +121,7 @@ bug appeared in 0.1.21. рабочих процессов на SMP машине. -the ngx_http_stub_status_module showed incorrect statictics +the ngx_http_stub_status_module showed incorrect statistics if "rtsig" method was used or if several worker process ran on SMP. @@ -82,7 +157,7 @@ nginx could not be built on NetBSD 2.0. the new "script_filename" and "remote_port" parameters -ofthe fastcgi_params directive. +of the fastcgi_params directive. @@ -91,7 +166,7 @@ ofthe fastcgi_params directive. неправильно обрабатывался поток stderr от FastCGI-сервера. -the FastCGI stderr stream was handled incorreсtly. +the FastCGI stderr stream was handled incorrectly. @@ -420,7 +495,7 @@ segmentation fault. выделенных частей не совпадает с числом подстановок. -the correct handling of the regular exporession, that +the correct handling of the regular expression, that has different number of the captures and substitutions. @@ -432,7 +507,7 @@ location, который передаётся FastCGI-серверу, может быть задан the location, that is passed to the FastCGI server, can be -regualar expression. +regular expression. @@ -480,9 +555,9 @@ bug appeared in 0.1.14. то происходил segmentation fault. -the same pathes in autoconfiguration paramters +the same paths in autoconfiguration parameters --http-client-body-temp-path=PATH and --http-proxy-temp-path=PATH, -or --http-client-body-temp-path=PATH nad --http-fastcgi-temp-path=PATH +or --http-client-body-temp-path=PATH and --http-fastcgi-temp-path=PATH caused segmentation fault. @@ -783,7 +858,7 @@ method was used. автоматическое определение групп nobody и nogroup. -the autodetection of the nobody and nogroup groups. +the autodetection of the "nobody" and "nogroup" groups. @@ -960,7 +1035,7 @@ bug appeared in 0.1.5. использовалась конфигурация не из того location. -some location directive combiations with the regular expressions caused +some location directive combinations with the regular expressions caused the wrong configuration choose. diff --git a/src/core/nginx.h b/src/core/nginx.h --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.1.22" +#define NGINX_VER "nginx/0.1.23" #define NGINX_VAR "NGINX" #define NGX_NEWPID_EXT ".newbin" diff --git a/src/event/ngx_event_acceptex.c b/src/event/ngx_event_acceptex.c --- a/src/event/ngx_event_acceptex.c +++ b/src/event/ngx_event_acceptex.c @@ -7,7 +7,6 @@ #include #include #include -#include void ngx_event_acceptex(ngx_event_t *rev) diff --git a/src/http/modules/ngx_http_autoindex_handler.c b/src/http/modules/ngx_http_autoindex_handler.c --- a/src/http/modules/ngx_http_autoindex_handler.c +++ b/src/http/modules/ngx_http_autoindex_handler.c @@ -241,7 +241,7 @@ static ngx_int_t ngx_http_autoindex_hand if (len == 2 && ngx_de_name(&dir)[0] == '.' - && ngx_de_name(&dir)[0] == '.') + && ngx_de_name(&dir)[1] == '.') { continue; } @@ -263,9 +263,20 @@ static ngx_int_t ngx_http_autoindex_hand ngx_cpystrn(last, ngx_de_name(&dir), len + 1); if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) { - ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, - ngx_de_info_n " \"%s\" failed", fname.data); - return ngx_http_autoindex_error(r, &dir, dname.data); + err = ngx_errno; + + if (err != NGX_ENOENT) { + ngx_log_error(NGX_LOG_CRIT, r->connection->log, err, + ngx_de_info_n " \"%s\" failed", fname.data); + return ngx_http_autoindex_error(r, &dir, dname.data); + } + + if (ngx_de_link_info(fname.data, &dir) == NGX_FILE_ERROR) { + ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, + ngx_de_link_info_n " \"%s\" failed", + fname.data); + return ngx_http_autoindex_error(r, &dir, dname.data); + } } } diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -76,23 +76,23 @@ typedef struct { static ngx_int_t ngx_http_gzip_proxied(ngx_http_request_t *r, - ngx_http_gzip_conf_t *conf); + ngx_http_gzip_conf_t *conf); static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, - u_int size); + u_int size); static void ngx_http_gzip_filter_free(void *opaque, void *address); static void ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx); static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, - ngx_http_log_op_t *op); + ngx_http_log_op_t *op); static ngx_int_t ngx_http_gzip_add_log_formats(ngx_conf_t *cf); static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle); static void *ngx_http_gzip_create_conf(ngx_conf_t *cf); static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, - void *parent, void *child); + void *parent, void *child); static char *ngx_http_gzip_set_types(ngx_conf_t *cf, ngx_command_t *cmd, - void *conf); + void *conf); static char *ngx_http_gzip_set_window(ngx_conf_t *cf, void *post, void *data); static char *ngx_http_gzip_set_hash(ngx_conf_t *cf, void *post, void *data); @@ -261,7 +261,8 @@ static ngx_http_output_header_filter_pt static ngx_http_output_body_filter_pt ngx_http_next_body_filter; -static ngx_int_t ngx_http_gzip_header_filter(ngx_http_request_t *r) +static ngx_int_t +ngx_http_gzip_header_filter(ngx_http_request_t *r) { ngx_uint_t i, found; ngx_http_gzip_ctx_t *ctx; @@ -357,8 +358,8 @@ static ngx_int_t ngx_http_gzip_header_fi } -static ngx_int_t ngx_http_gzip_proxied(ngx_http_request_t *r, - ngx_http_gzip_conf_t *conf) +static ngx_int_t +ngx_http_gzip_proxied(ngx_http_request_t *r, ngx_http_gzip_conf_t *conf) { time_t date, expires; @@ -437,8 +438,8 @@ static ngx_int_t ngx_http_gzip_proxied(n } -static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r, - ngx_chain_t *in) +static ngx_int_t +ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in) { int rc, wbits, memlevel; ngx_int_t last; @@ -825,7 +826,8 @@ static ngx_int_t ngx_http_gzip_body_filt } -static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size) +static void * +ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size) { ngx_http_gzip_ctx_t *ctx = opaque; @@ -866,7 +868,8 @@ static void *ngx_http_gzip_filter_alloc( } -static void ngx_http_gzip_filter_free(void *opaque, void *address) +static void +ngx_http_gzip_filter_free(void *opaque, void *address) { #if 0 ngx_http_gzip_ctx_t *ctx = opaque; @@ -877,8 +880,9 @@ static void ngx_http_gzip_filter_free(vo } -static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, - ngx_http_log_op_t *op) +static u_char * +ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf, + ngx_http_log_op_t *op) { ngx_uint_t zint, zfrac; ngx_http_gzip_ctx_t *ctx; @@ -909,7 +913,8 @@ static u_char *ngx_http_gzip_log_ratio(n } -static void ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx) +static void +ngx_http_gzip_error(ngx_http_gzip_ctx_t *ctx) { deflateEnd(&ctx->zstream); @@ -926,7 +931,8 @@ static void ngx_http_gzip_error(ngx_http } -static ngx_int_t ngx_http_gzip_add_log_formats(ngx_conf_t *cf) +static ngx_int_t +ngx_http_gzip_add_log_formats(ngx_conf_t *cf) { ngx_http_log_op_name_t *op; @@ -945,7 +951,8 @@ static ngx_int_t ngx_http_gzip_add_log_f } -static ngx_int_t ngx_http_gzip_filter_init(ngx_cycle_t *cycle) +static ngx_int_t +ngx_http_gzip_filter_init(ngx_cycle_t *cycle) { ngx_http_next_header_filter = ngx_http_top_header_filter; ngx_http_top_header_filter = ngx_http_gzip_header_filter; @@ -957,7 +964,8 @@ static ngx_int_t ngx_http_gzip_filter_in } -static void *ngx_http_gzip_create_conf(ngx_conf_t *cf) +static void * +ngx_http_gzip_create_conf(ngx_conf_t *cf) { ngx_http_gzip_conf_t *conf; @@ -987,8 +995,8 @@ static void *ngx_http_gzip_create_conf(n } -static char *ngx_http_gzip_merge_conf(ngx_conf_t *cf, - void *parent, void *child) +static char * +ngx_http_gzip_merge_conf(ngx_conf_t *cf, void *parent, void *child) { ngx_http_gzip_conf_t *prev = parent; ngx_http_gzip_conf_t *conf = child; @@ -1000,10 +1008,9 @@ static char *ngx_http_gzip_merge_conf(ng ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 4, ngx_pagesize); ngx_conf_merge_unsigned_value(conf->http_version, prev->http_version, - NGX_HTTP_VERSION_11); + NGX_HTTP_VERSION_11); ngx_conf_merge_bitmask_value(conf->proxied, prev->proxied, - (NGX_CONF_BITMASK_SET - |NGX_HTTP_GZIP_PROXIED_OFF)); + (NGX_CONF_BITMASK_SET|NGX_HTTP_GZIP_PROXIED_OFF)); ngx_conf_merge_value(conf->level, prev->level, 1); ngx_conf_merge_size_value(conf->wbits, prev->wbits, MAX_WBITS); @@ -1037,8 +1044,8 @@ static char *ngx_http_gzip_merge_conf(ng } -static char *ngx_http_gzip_set_types(ngx_conf_t *cf, ngx_command_t *cmd, - void *conf) +static char * +ngx_http_gzip_set_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_gzip_conf_t *gcf = conf; @@ -1047,7 +1054,7 @@ static char *ngx_http_gzip_set_types(ngx ngx_http_gzip_type_t *type; if (gcf->types == NULL) { - gcf->types = ngx_array_create(cf->pool, 5, + gcf->types = ngx_array_create(cf->pool, 4, sizeof(ngx_http_gzip_type_t)); if (gcf->types == NULL) { return NGX_CONF_ERROR; @@ -1087,7 +1094,8 @@ static char *ngx_http_gzip_set_types(ngx } -static char *ngx_http_gzip_set_window(ngx_conf_t *cf, void *post, void *data) +static char * +ngx_http_gzip_set_window(ngx_conf_t *cf, void *post, void *data) { int *np = data; @@ -1110,7 +1118,8 @@ static char *ngx_http_gzip_set_window(ng } -static char *ngx_http_gzip_set_hash(ngx_conf_t *cf, void *post, void *data) +static char * +ngx_http_gzip_set_hash(ngx_conf_t *cf, void *post, void *data) { int *np = data; diff --git a/src/http/modules/ngx_http_ssi_filter.c b/src/http/modules/ngx_http_ssi_filter.c --- a/src/http/modules/ngx_http_ssi_filter.c +++ b/src/http/modules/ngx_http_ssi_filter.c @@ -8,56 +8,68 @@ #include #include - -#define NGX_HTTP_SSI_COMMAND_LEN 31 -#define NGX_HTTP_SSI_PARAM_LEN 31 +#define NGX_HTTP_SSI_MAX_PARAMS 16 -#define NGX_HTTP_SSI_COPY 1 -#define NGX_HTTP_SSI_INVALID_COMMAND 2 -#define NGX_HTTP_SSI_INVALID_PARAM 3 -#define NGX_HTTP_SSI_INVALID_VALUE 4 -#define NGX_HTTP_SSI_LONG_VALUE 5 +#define NGX_HTTP_SSI_COMMAND_LEN 31 +#define NGX_HTTP_SSI_PARAM_LEN 31 +#define NGX_HTTP_SSI_PARAMS_N 4 + +#define NGX_HTTP_SSI_ERROR 1 typedef struct { ngx_flag_t enable; + ngx_flag_t silent_errors; + + size_t min_file_chunk; size_t value_len; } ngx_http_ssi_conf_t; typedef struct { - int dummy; -} ngx_http_ssi_command_t; - + ngx_buf_t *buf; -typedef struct { - ngx_hunk_t *buf; - - u_char *start; - u_char *last; u_char *pos; + u_char *copy_start; + u_char *copy_end; ngx_str_t command; ngx_array_t params; ngx_table_elt_t *param; + ngx_table_elt_t params_array[NGX_HTTP_SSI_PARAMS_N]; ngx_chain_t *in; ngx_chain_t *out; ngx_chain_t **last_out; - ngx_chain_t *busy; ngx_uint_t state; + ngx_uint_t saved_state; size_t saved; + size_t looked; + + size_t value_len; } ngx_http_ssi_ctx_t; -typedef ngx_int_t (*ngx_http_ssi_opcode_pt) (ngx_http_request_t *r, - ngx_http_ssi_ctx_t *ctx); +typedef ngx_int_t (*ngx_http_ssi_command_pt) (ngx_http_request_t *r, + ngx_http_ssi_ctx_t *ctx, ngx_str_t **); + typedef struct { - ngx_str_t name; - ngx_http_ssi_opcode_pt op; -} ngx_http_ssi_op_t; + ngx_str_t name; + ngx_uint_t index; + + ngx_uint_t mandatory; +} ngx_http_ssi_param_t; + + +typedef struct { + ngx_str_t name; + ngx_http_ssi_command_pt handler; + ngx_http_ssi_param_t *params; + + ngx_uint_t flush; /* unsigned flush:1; */ +} ngx_http_ssi_command_t; typedef enum { @@ -73,9 +85,9 @@ typedef enum { ssi_preequal_state, ssi_prevalue_state, ssi_double_quoted_value_state, - ssi_double_quoted_value_quote_state, ssi_quoted_value_state, - ssi_quoted_value_quote_state, + ssi_quoted_symbol_state, + ssi_postparam_state, ssi_comment_end0_state, ssi_comment_end1_state, ssi_error_state, @@ -85,23 +97,17 @@ typedef enum { static ngx_int_t ngx_http_ssi_error(ngx_http_request_t *r, - ngx_http_ssi_ctx_t *ctx); + ngx_http_ssi_ctx_t *ctx); static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, - ngx_http_ssi_ctx_t *ctx); + ngx_http_ssi_ctx_t *ctx); static ngx_int_t ngx_http_ssi_echo(ngx_http_request_t *r, - ngx_http_ssi_ctx_t *ctx); + ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); static void *ngx_http_ssi_create_conf(ngx_conf_t *cf); static char *ngx_http_ssi_merge_conf(ngx_conf_t *cf, - void *parent, void *child); -static int ngx_http_ssi_filter_init(ngx_cycle_t *cycle); - - -static ngx_http_ssi_op_t ngx_http_ssi_commands[] = { - { ngx_string("echo"), ngx_http_ssi_echo }, - { ngx_null_string, NULL } -}; + void *parent, void *child); +static ngx_int_t ngx_http_ssi_filter_init(ngx_cycle_t *cycle); static ngx_command_t ngx_http_ssi_filter_commands[] = { @@ -113,7 +119,21 @@ static ngx_command_t ngx_http_ssi_filte offsetof(ngx_http_ssi_conf_t, enable), NULL }, - ngx_null_command + { ngx_string("ssi_silent_errors"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + ngx_conf_set_flag_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_ssi_conf_t, silent_errors), + NULL }, + + { ngx_string("ssi_min_file_chunk"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_ssi_conf_t, min_file_chunk), + NULL }, + + ngx_null_command }; @@ -142,18 +162,36 @@ ngx_module_t ngx_http_ssi_filter_module }; -static int (*ngx_http_next_header_filter) (ngx_http_request_t *r); -static int (*ngx_http_next_body_filter) (ngx_http_request_t *r, - ngx_chain_t *in); +static ngx_int_t (*ngx_http_next_header_filter) (ngx_http_request_t *r); +static ngx_int_t (*ngx_http_next_body_filter) (ngx_http_request_t *r, + ngx_chain_t *in); + + +static u_char ngx_http_ssi_string[] = "