From e04084c1b295f5a704c2962f82becb5f278d60e3 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Mon, 26 Jan 2004 08:52:49 +0000 Subject: nginx-0.0.1-2004-01-26-11:52:49 import --- src/http/modules/ngx_http_gzip_filter.c | 86 +++---- src/http/modules/ngx_http_ssi_filter.c | 394 ++++++++++++++++++++------------ 2 files changed, 292 insertions(+), 188 deletions(-) (limited to 'src/http/modules') diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index 09980eff3..c5e68c9a5 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -76,49 +76,49 @@ static ngx_conf_post_handler_pt ngx_http_gzip_set_hash_p = static ngx_command_t ngx_http_gzip_filter_commands[] = { - {ngx_string("gzip"), - 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_gzip_conf_t, enable), - NULL}, - - {ngx_string("gzip_buffers"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, - ngx_conf_set_bufs_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_gzip_conf_t, bufs), - NULL}, - - {ngx_string("gzip_comp_level"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_num_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_gzip_conf_t, level), - &ngx_http_gzip_comp_level_bounds}, - - {ngx_string("gzip_window"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_size_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_gzip_conf_t, wbits), - &ngx_http_gzip_set_window_p}, - - {ngx_string("gzip_hash"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_size_slot, - NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_gzip_conf_t, memlevel), - &ngx_http_gzip_set_hash_p}, - - {ngx_string("gzip_no_buffer"), - 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_gzip_conf_t, no_buffer), - NULL}, - - ngx_null_command + { ngx_string("gzip"), + 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_gzip_conf_t, enable), + NULL}, + + { ngx_string("gzip_buffers"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, + ngx_conf_set_bufs_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_gzip_conf_t, bufs), + NULL}, + + { ngx_string("gzip_comp_level"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_num_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_gzip_conf_t, level), + &ngx_http_gzip_comp_level_bounds}, + + { ngx_string("gzip_window"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_gzip_conf_t, wbits), + &ngx_http_gzip_set_window_p}, + + { ngx_string("gzip_hash"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_size_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_gzip_conf_t, memlevel), + &ngx_http_gzip_set_hash_p}, + + { ngx_string("gzip_no_buffer"), + 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_gzip_conf_t, no_buffer), + NULL}, + + ngx_null_command }; diff --git a/src/http/modules/ngx_http_ssi_filter.c b/src/http/modules/ngx_http_ssi_filter.c index e00c35280..78bf60826 100644 --- a/src/http/modules/ngx_http_ssi_filter.c +++ b/src/http/modules/ngx_http_ssi_filter.c @@ -7,7 +7,7 @@ #define NGX_HTTP_SSI_COMMAND_LEN 31 #define NGX_HTTP_SSI_PARAM_LEN 31 -#define NGX_HTTP_SSI_DONE 1 +#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 @@ -15,171 +15,263 @@ typedef struct { - ngx_hunk_t *hunk; - ngx_table_elt_t *param; - ngx_str_t command; - ngx_array_t params; - int state; - int looked; - char *pos; - ngx_chain_t *incoming; - int new_hunk; - u_int value_len; + int enable; +} ngx_http_ssi_conf_t; + + +typedef struct { + ngx_hunk_t *buf; + + char *start; + char *last; + char *pos; + + ngx_table_elt_t *param; + ngx_str_t command; + ngx_array_t params; + int state; + + ngx_chain_t *in; + ngx_chain_t *current; + ngx_chain_t *out; + ngx_chain_t **last_out; + ngx_chain_t *busy; + + size_t prev; + + u_int value_len; } ngx_http_ssi_ctx_t; +static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, + ngx_http_ssi_ctx_t *ctx); +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_command_t ngx_http_ssi_filter_commands[] = { + + { ngx_string("ssi"), + 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, enable), + NULL }, + + ngx_null_command +}; + + static ngx_http_module_t ngx_http_ssi_filter_module_ctx = { + NULL, /* pre conf */ + NULL, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ NULL, /* merge server configuration */ - NULL, /* create location configuration */ - NULL, /* merge location configuration */ + ngx_http_ssi_create_conf, /* create location configuration */ + ngx_http_ssi_merge_conf /* merge location configuration */ }; ngx_module_t ngx_http_ssi_filter_module = { NGX_MODULE, &ngx_http_ssi_filter_module_ctx, /* module context */ - NULL, /* module directives */ + ngx_http_ssi_filter_commands, /* module directives */ NGX_HTTP_MODULE, /* module type */ ngx_http_ssi_filter_init, /* init module */ NULL /* init child */ }; -static int (*next_header_filter) (ngx_http_request_t *r); -static int (*next_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch); +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 char comment_string[] = "