# HG changeset patch
# User Gena Makhomed <g...@csdoc.com>
# Date 1537528104 -10800
#      Fri Sep 21 14:08:24 2018 +0300
# Node ID a7533f3f3138fe5524a0f14293da4149e65b1402
# Parent  87d2ea860f380dc8418c97c0163412f53c2d008e
Allow 1xx 2xx 3xx 4xx 5xx codes in xxxxx_cache_valid directives.

For example, config fragment

    fastcgi_cache_valid 200 201 202 203 204 205 206 207 208 226 5m;
    fastcgi_cache_valid 300 301 302 303 304 305 306 307 308 10m;

now can be rewritten as

    fastcgi_cache_valid 2xx 5m;
    fastcgi_cache_valid 3xx 10m;

diff -r 87d2ea860f38 -r a7533f3f3138 src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c    Mon Sep 10 18:57:39 2018 +0300
+++ b/src/http/ngx_http_file_cache.c    Fri Sep 21 14:08:24 2018 +0300
@@ -2290,6 +2290,26 @@
             return valid[i].valid;
         }

+        if (valid[i].status == 1 && status >= 100 && status <= 199) {
+            return valid[i].valid;
+        }
+
+        if (valid[i].status == 2 && status >= 200 && status <= 299) {
+            return valid[i].valid;
+        }
+
+        if (valid[i].status == 3 && status >= 300 && status <= 399) {
+            return valid[i].valid;
+        }
+
+        if (valid[i].status == 4 && status >= 400 && status <= 499) {
+            return valid[i].valid;
+        }
+
+        if (valid[i].status == 5 && status >= 500 && status <= 599) {
+            return valid[i].valid;
+        }
+
         if (valid[i].status == status) {
             return valid[i].valid;
         }
@@ -2666,10 +2686,30 @@

             status = 0;

+        } else if(ngx_strcmp(value[i].data, "1xx") == 0) {
+
+            status = 1;
+
+        } else if(ngx_strcmp(value[i].data, "2xx") == 0) {
+
+            status = 2;
+
+        } else if(ngx_strcmp(value[i].data, "3xx") == 0) {
+
+            status = 3;
+
+        } else if(ngx_strcmp(value[i].data, "4xx") == 0) {
+
+            status = 4;
+
+        } else if(ngx_strcmp(value[i].data, "5xx") == 0) {
+
+            status = 5;
+
         } else {

             status = ngx_atoi(value[i].data, value[i].len);
-            if (status < 100) {
+            if (status < 100 || status > 599) {
                 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                                    "invalid status \"%V\"", &value[i]);
                 return NGX_CONF_ERROR;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to