]> git.kaiwu.me - nginx.git/commitdiff
Moved ngx_http_parse_time() to core, renamed accordingly.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 11 Jun 2015 17:42:31 +0000 (20:42 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 11 Jun 2015 17:42:31 +0000 (20:42 +0300)
The function is now called ngx_parse_http_time(), and can be used by
any code to parse HTTP-style date and time.  In particular, it will be
used for OCSP stapling.

For compatibility, a macro to map ngx_http_parse_time() to the new name
provided for a while.

auto/sources
src/core/ngx_core.h
src/core/ngx_parse_time.c [moved from src/http/ngx_http_parse_time.c with 98% similarity]
src/core/ngx_parse_time.h [new file with mode: 0644]
src/http/modules/ngx_http_dav_module.c
src/http/modules/ngx_http_headers_filter_module.c
src/http/modules/ngx_http_not_modified_filter_module.c
src/http/modules/ngx_http_range_filter_module.c
src/http/ngx_http.h
src/http/ngx_http_core_module.c
src/http/ngx_http_upstream.c

index b5bb92ca58c738a7a9ba5f18afbad2b04401bd5f..44fba5159e6a353fae6f4df02581a91db6e30c42 100644 (file)
@@ -19,6 +19,7 @@ CORE_DEPS="src/core/nginx.h \
            src/core/ngx_queue.h \
            src/core/ngx_string.h \
            src/core/ngx_parse.h \
+           src/core/ngx_parse_time.h \
            src/core/ngx_inet.h \
            src/core/ngx_file.h \
            src/core/ngx_crc.h \
@@ -53,6 +54,7 @@ CORE_SRCS="src/core/nginx.c \
            src/core/ngx_output_chain.c \
            src/core/ngx_string.c \
            src/core/ngx_parse.c \
+           src/core/ngx_parse_time.c \
            src/core/ngx_inet.c \
            src/core/ngx_file.c \
            src/core/ngx_crc32.c \
@@ -303,7 +305,6 @@ HTTP_SRCS="src/http/ngx_http.c \
            src/http/ngx_http_script.c \
            src/http/ngx_http_upstream.c \
            src/http/ngx_http_upstream_round_robin.c \
-           src/http/ngx_http_parse_time.c \
            src/http/modules/ngx_http_static_module.c \
            src/http/modules/ngx_http_index_module.c \
            src/http/modules/ngx_http_chunked_filter_module.c \
index a279c81d662629daa8691a83f1f591a5f9456acd..6b317056a6324478d5bd69671116eb4acf0e1abf 100644 (file)
@@ -54,6 +54,7 @@ typedef void (*ngx_connection_handler_pt)(ngx_connection_t *c);
 #include <ngx_process.h>
 #include <ngx_user.h>
 #include <ngx_parse.h>
+#include <ngx_parse_time.h>
 #include <ngx_log.h>
 #include <ngx_alloc.h>
 #include <ngx_palloc.h>
similarity index 98%
rename from src/http/ngx_http_parse_time.c
rename to src/core/ngx_parse_time.c
index 985af31725b74646ceae26d5ba4386b6adeb1507..831cc71bf5ae6f6941a4678afaa7198e281742aa 100644 (file)
@@ -7,13 +7,12 @@
 
 #include <ngx_config.h>
 #include <ngx_core.h>
-#include <ngx_http.h>
 
 
 static ngx_uint_t  mday[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
 
 time_t
-ngx_http_parse_time(u_char *value, size_t len)
+ngx_parse_http_time(u_char *value, size_t len)
 {
     u_char      *p, *end;
     ngx_int_t    month;
diff --git a/src/core/ngx_parse_time.h b/src/core/ngx_parse_time.h
new file mode 100644 (file)
index 0000000..aa542eb
--- /dev/null
@@ -0,0 +1,22 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#ifndef _NGX_PARSE_TIME_H_INCLUDED_
+#define _NGX_PARSE_TIME_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+time_t ngx_parse_http_time(u_char *value, size_t len);
+
+/* compatibility */
+#define ngx_http_parse_time(value, len)  ngx_parse_http_time(value, len)
+
+
+#endif /* _NGX_PARSE_TIME_H_INCLUDED_ */
index 529aba53341351c3579f6f0cd8fc07e8cbd3f918..b9fadd00119e067bc654873b836896ba7481fd98 100644 (file)
@@ -255,7 +255,7 @@ ngx_http_dav_put_handler(ngx_http_request_t *r)
     ext.log = r->connection->log;
 
     if (r->headers_in.date) {
-        date = ngx_http_parse_time(r->headers_in.date->value.data,
+        date = ngx_parse_http_time(r->headers_in.date->value.data,
                                    r->headers_in.date->value.len);
 
         if (date != NGX_ERROR) {
index a356814e4ce9be8143e2df29e9a8307ad8b5e358..985e5b33508f399a5fae17e4f806efc4f4de95e8 100644 (file)
@@ -498,7 +498,7 @@ ngx_http_set_last_modified(ngx_http_request_t *r, ngx_http_header_val_t *hv,
     }
 
     r->headers_out.last_modified_time =
-        (value->len) ? ngx_http_parse_time(value->data, value->len) : -1;
+        (value->len) ? ngx_parse_http_time(value->data, value->len) : -1;
 
     return NGX_OK;
 }
index acc94ded31ad8bf0a409b0b1134675f00061925c..032ba96fd4e9e49d6ba80ad118bc53a801d239f8 100644 (file)
@@ -118,7 +118,7 @@ ngx_http_test_if_unmodified(ngx_http_request_t *r)
         return 0;
     }
 
-    iums = ngx_http_parse_time(r->headers_in.if_unmodified_since->value.data,
+    iums = ngx_parse_http_time(r->headers_in.if_unmodified_since->value.data,
                                r->headers_in.if_unmodified_since->value.len);
 
     ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -148,7 +148,7 @@ ngx_http_test_if_modified(ngx_http_request_t *r)
         return 1;
     }
 
-    ims = ngx_http_parse_time(r->headers_in.if_modified_since->value.data,
+    ims = ngx_parse_http_time(r->headers_in.if_modified_since->value.data,
                               r->headers_in.if_modified_since->value.len);
 
     ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
index bb9a42c544ebe6940d55387448e84527a7f3389a..952da75539506c01875313433e7c261d363b5e27 100644 (file)
@@ -204,7 +204,7 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
             goto next_filter;
         }
 
-        if_range_time = ngx_http_parse_time(if_range->data, if_range->len);
+        if_range_time = ngx_parse_http_time(if_range->data, if_range->len);
 
         ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                        "http ir:%d lm:%d",
index 328f49e941f29edac3cdaf20f2ab38891cc0c823..844f50249107f6928e36f05c4b680b2b5aa7521f 100644 (file)
@@ -148,9 +148,6 @@ ngx_int_t ngx_http_filter_finalize_request(ngx_http_request_t *r,
 void ngx_http_clean_header(ngx_http_request_t *r);
 
 
-time_t ngx_http_parse_time(u_char *value, size_t len);
-
-
 ngx_int_t ngx_http_discard_request_body(ngx_http_request_t *r);
 void ngx_http_discarded_request_body_handler(ngx_http_request_t *r);
 void ngx_http_block_reading(ngx_http_request_t *r);
index f5255265e3f5f75241a74794b5f67cc6168be7eb..d423d8b8074dc3c0d5c31402609b510ea1073c71 100644 (file)
@@ -2195,7 +2195,7 @@ ngx_http_gzip_ok(ngx_http_request_t *r)
             return NGX_DECLINED;
         }
 
-        expires = ngx_http_parse_time(e->value.data, e->value.len);
+        expires = ngx_parse_http_time(e->value.data, e->value.len);
         if (expires == NGX_ERROR) {
             return NGX_DECLINED;
         }
@@ -2203,7 +2203,7 @@ ngx_http_gzip_ok(ngx_http_request_t *r)
         d = r->headers_out.date;
 
         if (d) {
-            date = ngx_http_parse_time(d->value.data, d->value.len);
+            date = ngx_parse_http_time(d->value.data, d->value.len);
             if (date == NGX_ERROR) {
                 return NGX_DECLINED;
             }
index 47b574e84bd809614d531d095fcd7d9a9f3caff5..4b0332a42032d73956bf42bbc0624393ca109f41 100644 (file)
@@ -3731,7 +3731,7 @@ ngx_http_upstream_store(ngx_http_request_t *r, ngx_http_upstream_t *u)
 
     if (u->headers_in.last_modified) {
 
-        lm = ngx_http_parse_time(u->headers_in.last_modified->value.data,
+        lm = ngx_parse_http_time(u->headers_in.last_modified->value.data,
                                  u->headers_in.last_modified->value.len);
 
         if (lm != NGX_ERROR) {
@@ -4128,7 +4128,7 @@ ngx_http_upstream_process_last_modified(ngx_http_request_t *r,
 #if (NGX_HTTP_CACHE)
 
     if (u->cacheable) {
-        u->headers_in.last_modified_time = ngx_http_parse_time(h->value.data,
+        u->headers_in.last_modified_time = ngx_parse_http_time(h->value.data,
                                                                h->value.len);
     }
 
@@ -4292,7 +4292,7 @@ ngx_http_upstream_process_expires(ngx_http_request_t *r, ngx_table_elt_t *h,
         return NGX_OK;
     }
 
-    expires = ngx_http_parse_time(h->value.data, h->value.len);
+    expires = ngx_parse_http_time(h->value.data, h->value.len);
 
     if (expires == NGX_ERROR || expires < ngx_time()) {
         u->cacheable = 0;