mirror of
https://github.com/nginx/nginx.git
synced 2024-12-02 20:09:01 +08:00
ngx_http_test_predicates(), ngx_http_set_predicate_slot()
This commit is contained in:
parent
e48f042f40
commit
7fc29052e8
@ -211,6 +211,76 @@ ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv)
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_test_predicates(ngx_http_request_t *r, ngx_array_t *predicates)
|
||||
{
|
||||
ngx_str_t val;
|
||||
ngx_uint_t i;
|
||||
ngx_http_complex_value_t *cv;
|
||||
|
||||
if (predicates == NULL) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
cv = predicates->elts;
|
||||
|
||||
for (i = 0; i < predicates->nelts; i++) {
|
||||
if (ngx_http_complex_value(r, &cv[i], &val) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (val.len && val.data[0] != '0') {
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
char *p = conf;
|
||||
|
||||
ngx_str_t *value;
|
||||
ngx_uint_t i;
|
||||
ngx_array_t **a;
|
||||
ngx_http_complex_value_t *cv;
|
||||
ngx_http_compile_complex_value_t ccv;
|
||||
|
||||
a = (ngx_array_t **) (p + cmd->offset);
|
||||
|
||||
if (*a == NGX_CONF_UNSET_PTR) {
|
||||
*a = ngx_array_create(cf->pool, 1, sizeof(ngx_http_complex_value_t));
|
||||
if (*a == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
value = cf->args->elts;
|
||||
|
||||
for (i = 1; i < cf->args->nelts; i++) {
|
||||
cv = ngx_array_push(*a);
|
||||
if (cv == NULL) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
||||
|
||||
ccv.cf = cf;
|
||||
ccv.value = &value[i];
|
||||
ccv.complex_value = cv;
|
||||
|
||||
if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
|
||||
ngx_uint_t
|
||||
ngx_http_script_variables_count(ngx_str_t *value)
|
||||
{
|
||||
|
@ -208,6 +208,11 @@ ngx_int_t ngx_http_complex_value(ngx_http_request_t *r,
|
||||
ngx_http_complex_value_t *val, ngx_str_t *value);
|
||||
ngx_int_t ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv);
|
||||
|
||||
ngx_int_t ngx_http_test_predicates(ngx_http_request_t *r,
|
||||
ngx_array_t *predicates);
|
||||
char *ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
|
||||
ngx_uint_t ngx_http_script_variables_count(ngx_str_t *value);
|
||||
ngx_int_t ngx_http_script_compile(ngx_http_script_compile_t *sc);
|
||||
u_char *ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value,
|
||||
|
Loading…
Reference in New Issue
Block a user