aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/ngx_http_script.c')
-rw-r--r--src/http/ngx_http_script.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index 415388904..f2f5a1ca8 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -104,6 +104,37 @@ ngx_http_complex_value(ngx_http_request_t *r, ngx_http_complex_value_t *val,
}
+size_t
+ngx_http_complex_value_size(ngx_http_request_t *r,
+ ngx_http_complex_value_t *val, size_t default_value)
+{
+ size_t size;
+ ngx_str_t value;
+
+ if (val == NULL) {
+ return default_value;
+ }
+
+ if (val->lengths == NULL) {
+ return val->u.size;
+ }
+
+ if (ngx_http_complex_value(r, val, &value) != NGX_OK) {
+ return default_value;
+ }
+
+ size = ngx_parse_size(&value);
+
+ if (size == (size_t) NGX_ERROR) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "invalid size \"%V\"", &value);
+ return default_value;
+ }
+
+ return size;
+}
+
+
ngx_int_t
ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv)
{
@@ -244,6 +275,36 @@ ngx_http_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
+char *
+ngx_http_set_complex_value_size_slot(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf)
+{
+ char *p = conf;
+
+ char *rv;
+ ngx_http_complex_value_t *cv;
+
+ rv = ngx_http_set_complex_value_slot(cf, cmd, conf);
+
+ if (rv != NGX_CONF_OK) {
+ return rv;
+ }
+
+ cv = *(ngx_http_complex_value_t **) (p + cmd->offset);
+
+ if (cv->lengths) {
+ return NGX_CONF_OK;
+ }
+
+ cv->u.size = ngx_parse_size(&cv->value);
+ if (cv->u.size == (size_t) NGX_ERROR) {
+ return "invalid value";
+ }
+
+ return NGX_CONF_OK;
+}
+
+
ngx_int_t
ngx_http_test_predicates(ngx_http_request_t *r, ngx_array_t *predicates)
{