satisfy all|any

This commit is contained in:
Igor Sysoev 2007-12-29 16:38:23 +00:00
parent c7a9b7a990
commit 2d028f8910
3 changed files with 31 additions and 7 deletions

View File

@ -116,7 +116,7 @@ ngx_http_access_handler(ngx_http_request_t *r)
if (rule[i].deny) {
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
if (!clcf->satisfy_any) {
if (clcf->satisfy == NGX_HTTP_SATISFY_ALL) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"access forbidden by rule");
}

View File

@ -93,6 +93,10 @@ static ngx_conf_deprecated_t ngx_conf_deprecated_open_file_cache_retest = {
ngx_conf_deprecated, "open_file_cache_retest", "open_file_cache_valid"
};
static ngx_conf_deprecated_t ngx_conf_deprecated_satisfy_any = {
ngx_conf_deprecated, "satisfy_any", "satisfy"
};
static ngx_conf_enum_t ngx_http_core_request_body_in_file[] = {
{ ngx_string("off"), NGX_HTTP_REQUEST_BODY_FILE_OFF },
@ -102,6 +106,13 @@ static ngx_conf_enum_t ngx_http_core_request_body_in_file[] = {
};
static ngx_conf_enum_t ngx_http_core_satisfy[] = {
{ ngx_string("all"), NGX_HTTP_SATISFY_ALL },
{ ngx_string("any"), NGX_HTTP_SATISFY_ANY },
{ ngx_null_string, 0 }
};
#if (NGX_HTTP_GZIP)
static ngx_conf_enum_t ngx_http_gzip_http_version[] = {
@ -404,12 +415,19 @@ static ngx_command_t ngx_http_core_commands[] = {
0,
NULL },
{ ngx_string("satisfy"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_enum_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_core_loc_conf_t, satisfy),
&ngx_http_core_satisfy },
{ ngx_string("satisfy_any"),
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_core_loc_conf_t, satisfy_any),
NULL },
offsetof(ngx_http_core_loc_conf_t, satisfy),
&ngx_conf_deprecated_satisfy_any },
{ ngx_string("internal"),
NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,
@ -918,7 +936,7 @@ ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph)
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
if (clcf->satisfy_any == 0) {
if (clcf->satisfy == NGX_HTTP_SATISFY_ALL) {
if (rc == NGX_OK) {
r->phase_handler++;
@ -2674,7 +2692,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
lcf->client_max_body_size = NGX_CONF_UNSET;
lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE;
lcf->client_body_timeout = NGX_CONF_UNSET_MSEC;
lcf->satisfy_any = NGX_CONF_UNSET;
lcf->satisfy = NGX_CONF_UNSET;
lcf->internal = NGX_CONF_UNSET;
lcf->client_body_in_file_only = NGX_CONF_UNSET;
lcf->sendfile = NGX_CONF_UNSET;
@ -2859,7 +2877,8 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_msec_value(conf->client_body_timeout,
prev->client_body_timeout, 60000);
ngx_conf_merge_value(conf->satisfy_any, prev->satisfy_any, 0);
ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy,
NGX_HTTP_SATISFY_ALL);
ngx_conf_merge_value(conf->internal, prev->internal, 0);
ngx_conf_merge_value(conf->client_body_in_file_only,
prev->client_body_in_file_only, 0);

View File

@ -24,6 +24,10 @@
#define NGX_HTTP_GZIP_PROXIED_ANY 0x0200
#define NGX_HTTP_SATISFY_ALL 0
#define NGX_HTTP_SATISFY_ANY 1
typedef struct {
unsigned default_server:1;
unsigned bind:1;
@ -286,7 +290,8 @@ struct ngx_http_core_loc_conf_s {
time_t keepalive_header; /* keepalive_timeout */
ngx_flag_t satisfy_any; /* satisfy_any */
ngx_uint_t satisfy; /* satisfy */
ngx_flag_t internal; /* internal */
ngx_flag_t client_body_in_file_only; /* client_body_in_file_only */
ngx_flag_t sendfile; /* sendfile */