Welcome! Log In Create A New Profile

Advanced

[nginx] Added the ngx_http_test_required_predicates() function.

Vladimir Homutov
January 17, 2019 06:38AM
details: https://hg.nginx.org/nginx/rev/5efc23d83bc2
branches:
changeset: 7439:5efc23d83bc2
user: Vladimir Homutov <vl@nginx.com>
date: Thu Jan 17 14:31:04 2019 +0300
description:
Added the ngx_http_test_required_predicates() function.

In contrast to ngx_http_test_predicates(), it requires all values to be
non-empty and not equal to "0".

diffstat:

src/http/ngx_http_script.c | 28 ++++++++++++++++++++++++++++
src/http/ngx_http_script.h | 2 ++
2 files changed, 30 insertions(+), 0 deletions(-)

diffs (50 lines):

diff -r 134343f2a877 -r 5efc23d83bc2 src/http/ngx_http_script.c
--- a/src/http/ngx_http_script.c Thu Jan 17 14:31:01 2019 +0300
+++ b/src/http/ngx_http_script.c Thu Jan 17 14:31:04 2019 +0300
@@ -271,6 +271,34 @@ ngx_http_test_predicates(ngx_http_reques
}


+ngx_int_t
+ngx_http_test_required_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 == 0 || (val.len == 1 && 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)
{
diff -r 134343f2a877 -r 5efc23d83bc2 src/http/ngx_http_script.h
--- a/src/http/ngx_http_script.h Thu Jan 17 14:31:01 2019 +0300
+++ b/src/http/ngx_http_script.h Thu Jan 17 14:31:04 2019 +0300
@@ -214,6 +214,8 @@ char *ngx_http_set_complex_value_slot(ng

ngx_int_t ngx_http_test_predicates(ngx_http_request_t *r,
ngx_array_t *predicates);
+ngx_int_t ngx_http_test_required_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);

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Added the ngx_http_test_required_predicates() function.

Vladimir Homutov 264 January 17, 2019 06:38AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 219
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready