[-]
[+]
|
Changed |
_service
|
@@ -2,6 +2,6 @@
<service name="download_url">
<param name="host">nginx.org</param>
<param name="protocol">http</param>
- <param name="path">/download/nginx-1.13.3.tar.gz</param>
+ <param name="path">/download/nginx-1.13.5.tar.gz</param>
</service>
-<service name="download_url"><param name="host">nginx.org</param><param name="protocol">http</param><param name="path">/download/nginx-1.13.3.tar.gz</param></service><service name="download_url"><param name="host">www.openssl.org</param><param name="protocol">https</param><param name="path">/source/openssl-1.1.0f.tar.gz</param></service></services>
\ No newline at end of file
+<service name="download_url"><param name="host">nginx.org</param><param name="protocol">http</param><param name="path">/download/nginx-1.13.5.tar.gz</param></service><service name="download_url"><param name="host">www.openssl.org</param><param name="protocol">https</param><param name="path">/source/openssl-1.1.0f.tar.gz</param></service></services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/CHANGES
^
|
@@ -1,4 +1,39 @@
+Changes with nginx 1.13.5 05 Sep 2017
+
+ *) Feature: the $ssl_client_escaped_cert variable.
+
+ *) Bugfix: the "ssl_session_ticket_key" directive and the "include"
+ parameter of the "geo" directive did not work on Windows.
+
+ *) Bugfix: incorrect response length was returned on 32-bit platforms
+ when requesting more than 4 gigabytes with multiple ranges.
+
+ *) Bugfix: the "expires modified" directive and processing of the
+ "If-Range" request header line did not use the response last
+ modification time if proxying without caching was used.
+
+
+Changes with nginx 1.13.4 08 Aug 2017
+
+ *) Feature: the ngx_http_mirror_module.
+
+ *) Bugfix: client connections might be dropped during configuration
+ testing when using the "reuseport" parameter of the "listen"
+ directive on Linux.
+
+ *) Bugfix: request body might not be available in subrequests if it was
+ saved to a file and proxying was used.
+
+ *) Bugfix: cleaning cache based on the "max_size" parameter did not work
+ on Windows.
+
+ *) Bugfix: any shared memory allocation required 4096 bytes on Windows.
+
+ *) Bugfix: nginx worker might be terminated abnormally when using the
+ "zone" directive inside the "upstream" block on Windows.
+
+
Changes with nginx 1.13.3 11 Jul 2017
*) Security: a specially crafted request might result in an integer
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/CHANGES.ru
^
|
@@ -1,4 +1,39 @@
+Изменения в nginx 1.13.5 05.09.2017
+
+ *) Добавление: переменная $ssl_client_escaped_cert.
+
+ *) Исправление: директива ssl_session_ticket_key и параметр include
+ директивы geo не работали на Windows.
+
+ *) Исправление: на 32-битных платформах при запросе более 4 гигабайт с
+ помощью нескольких диапазонов возвращалась некорректная длина ответа.
+
+ *) Исправление: директива "expires modified" и обработка строки If-Range
+ заголовка запроса не учитывали время последнего изменения ответа,
+ если использовалось проксирование без кэширования.
+
+
+Изменения в nginx 1.13.4 08.08.2017
+
+ *) Добавление: модуль ngx_http_mirror_module.
+
+ *) Исправление: клиентские соединения могли сбрасываться при
+ тестировании конфигурации, если использовался параметр reuseport
+ директивы listen на Linux.
+
+ *) Исправление: тело запроса могло быть недоступно в подзапросах, если
+ оно было сохранено в файл и использовалось проксирование.
+
+ *) Исправление: очистка кэша по max_size не работала на Windows.
+
+ *) Исправление: любое выделение разделяемой памяти на Windows требовало
+ 4096 байт памяти.
+
+ *) Исправление: при использовании директивы zone в блоке upstream на
+ Windows рабочий процесс мог завершаться аварийно.
+
+
Изменения в nginx 1.13.3 11.07.2017
*) Безопасность: специально созданный запрос мог вызвать целочисленное
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/auto/lib/conf
^
|
@@ -7,7 +7,7 @@
. auto/lib/pcre/conf
else
- if [ $USE_PCRE = DISABLED -a $HTTP_REWRITE = YES ]; then
+ if [ $USE_PCRE = DISABLED -a $HTTP = YES -a $HTTP_REWRITE = YES ]; then
cat << END
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/auto/modules
^
|
@@ -506,6 +506,28 @@
. auto/module
fi
+ if [ $HTTP_MIRROR = YES ]; then
+ ngx_module_name=ngx_http_mirror_module
+ ngx_module_incs=
+ ngx_module_deps=
+ ngx_module_srcs=src/http/modules/ngx_http_mirror_module.c
+ ngx_module_libs=
+ ngx_module_link=$HTTP_MIRROR
+
+ . auto/module
+ fi
+
+ if :; then
+ ngx_module_name=ngx_http_try_files_module
+ ngx_module_incs=
+ ngx_module_deps=
+ ngx_module_srcs=src/http/modules/ngx_http_try_files_module.c
+ ngx_module_libs=
+ ngx_module_link=YES
+
+ . auto/module
+ fi
+
if [ $HTTP_AUTH_REQUEST = YES ]; then
ngx_module_name=ngx_http_auth_request_module
ngx_module_incs=
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/auto/options
^
|
@@ -70,6 +70,7 @@
HTTP_ACCESS=YES
HTTP_AUTH_BASIC=YES
HTTP_AUTH_REQUEST=NO
+HTTP_MIRROR=YES
HTTP_USERID=YES
HTTP_SLICE=NO
HTTP_AUTOINDEX=YES
@@ -249,6 +250,7 @@
--without-http_userid_module) HTTP_USERID=NO ;;
--without-http_access_module) HTTP_ACCESS=NO ;;
--without-http_auth_basic_module) HTTP_AUTH_BASIC=NO ;;
+ --without-http_mirror_module) HTTP_MIRROR=NO ;;
--without-http_autoindex_module) HTTP_AUTOINDEX=NO ;;
--without-http_status_module) HTTP_STATUS=NO ;;
--without-http_geo_module) HTTP_GEO=NO ;;
@@ -458,6 +460,7 @@
--without-http_userid_module disable ngx_http_userid_module
--without-http_access_module disable ngx_http_access_module
--without-http_auth_basic_module disable ngx_http_auth_basic_module
+ --without-http_mirror_module disable ngx_http_mirror_module
--without-http_autoindex_module disable ngx_http_autoindex_module
--without-http_geo_module disable ngx_http_geo_module
--without-http_map_module disable ngx_http_map_module
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/nginx.c
^
|
@@ -273,6 +273,12 @@
return 1;
}
+ /*
+ * ngx_slab_sizes_init() requires ngx_pagesize set in ngx_os_init()
+ */
+
+ ngx_slab_sizes_init();
+
if (ngx_add_inherited_sockets(&init_cycle) != NGX_OK) {
return 1;
}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/nginx.h
^
|
@@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_
-#define nginx_version 1013003
-#define NGINX_VERSION "1.13.3"
+#define nginx_version 1013005
+#define NGINX_VERSION "1.13.5"
#define NGINX_VER "nginx/" NGINX_VERSION
#ifdef NGX_BUILD
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/ngx_conf_file.c
^
|
@@ -178,6 +178,7 @@
/* open configuration file */
fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
+
if (fd == NGX_INVALID_FILE) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
ngx_open_file_n " \"%s\" failed",
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/ngx_connection.c
^
|
@@ -473,7 +473,7 @@
#if (NGX_HAVE_REUSEPORT)
- if (ls[i].reuseport) {
+ if (ls[i].reuseport && !ngx_test_config) {
int reuseport;
reuseport = 1;
@@ -483,7 +483,7 @@
== -1)
{
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
- "setsockopt(SO_REUSEPORT) %V failed, ignored",
+ "setsockopt(SO_REUSEPORT) %V failed",
&ls[i].addr_text);
if (ngx_close_socket(s) == -1) {
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/ngx_parse_time.c
^
|
@@ -58,7 +58,7 @@
return NGX_ERROR;
}
- day = (*p - '0') * 10 + *(p + 1) - '0';
+ day = (*p - '0') * 10 + (*(p + 1) - '0');
p += 2;
if (*p == ' ') {
@@ -132,7 +132,7 @@
}
year = (*p - '0') * 1000 + (*(p + 1) - '0') * 100
- + (*(p + 2) - '0') * 10 + *(p + 3) - '0';
+ + (*(p + 2) - '0') * 10 + (*(p + 3) - '0');
p += 4;
} else if (fmt == rfc850) {
@@ -140,7 +140,7 @@
return NGX_ERROR;
}
- year = (*p - '0') * 10 + *(p + 1) - '0';
+ year = (*p - '0') * 10 + (*(p + 1) - '0');
year += (year < 70) ? 2000 : 1900;
p += 2;
}
@@ -161,7 +161,7 @@
return NGX_ERROR;
}
- day = day * 10 + *p++ - '0';
+ day = day * 10 + (*p++ - '0');
}
if (end - p < 14) {
@@ -177,7 +177,7 @@
return NGX_ERROR;
}
- hour = (*p - '0') * 10 + *(p + 1) - '0';
+ hour = (*p - '0') * 10 + (*(p + 1) - '0');
p += 2;
if (*p++ != ':') {
@@ -188,7 +188,7 @@
return NGX_ERROR;
}
- min = (*p - '0') * 10 + *(p + 1) - '0';
+ min = (*p - '0') * 10 + (*(p + 1) - '0');
p += 2;
if (*p++ != ':') {
@@ -199,7 +199,7 @@
return NGX_ERROR;
}
- sec = (*p - '0') * 10 + *(p + 1) - '0';
+ sec = (*p - '0') * 10 + (*(p + 1) - '0');
if (fmt == isoc) {
p += 2;
@@ -216,7 +216,7 @@
}
year = (*p - '0') * 1000 + (*(p + 1) - '0') * 100
- + (*(p + 2) - '0') * 10 + *(p + 3) - '0';
+ + (*(p + 2) - '0') * 10 + (*(p + 3) - '0');
}
if (hour > 23 || min > 59 || sec > 59) {
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/ngx_regex.c
^
|
@@ -262,7 +262,7 @@
part = &studies->part;
elts = part->elts;
- for (i = 0 ; /* void */ ; i++) {
+ for (i = 0; /* void */ ; i++) {
if (i >= part->nelts) {
if (part->next == NULL) {
@@ -326,7 +326,7 @@
part = &ngx_pcre_studies->part;
elts = part->elts;
- for (i = 0 ; /* void */ ; i++) {
+ for (i = 0; /* void */ ; i++) {
if (i >= part->nelts) {
if (part->next == NULL) {
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/ngx_slab.c
^
|
@@ -83,6 +83,19 @@
void
+ngx_slab_sizes_init(void)
+{
+ ngx_uint_t n;
+
+ ngx_slab_max_size = ngx_pagesize / 2;
+ ngx_slab_exact_size = ngx_pagesize / (8 * sizeof(uintptr_t));
+ for (n = ngx_slab_exact_size; n >>= 1; ngx_slab_exact_shift++) {
+ /* void */
+ }
+}
+
+
+void
ngx_slab_init(ngx_slab_pool_t *pool)
{
u_char *p;
@@ -91,16 +104,6 @@
ngx_uint_t i, n, pages;
ngx_slab_page_t *slots, *page;
- /* STUB */
- if (ngx_slab_max_size == 0) {
- ngx_slab_max_size = ngx_pagesize / 2;
- ngx_slab_exact_size = ngx_pagesize / (8 * sizeof(uintptr_t));
- for (n = ngx_slab_exact_size; n >>= 1; ngx_slab_exact_shift++) {
- /* void */
- }
- }
- /**/
-
pool->min_size = (size_t) 1 << pool->min_shift;
slots = ngx_slab_slots(pool);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/ngx_slab.h
^
|
@@ -59,6 +59,7 @@
} ngx_slab_pool_t;
+void ngx_slab_sizes_init(void);
void ngx_slab_init(ngx_slab_pool_t *pool);
void *ngx_slab_alloc(ngx_slab_pool_t *pool, size_t size);
void *ngx_slab_alloc_locked(ngx_slab_pool_t *pool, size_t size);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/core/ngx_string.c
^
|
@@ -178,7 +178,7 @@
slen = (size_t) -1;
while (*fmt >= '0' && *fmt <= '9') {
- width = width * 10 + *fmt++ - '0';
+ width = width * 10 + (*fmt++ - '0');
}
@@ -211,7 +211,7 @@
fmt++;
while (*fmt >= '0' && *fmt <= '9') {
- frac_width = frac_width * 10 + *fmt++ - '0';
+ frac_width = frac_width * 10 + (*fmt++ - '0');
}
break;
@@ -1655,7 +1655,7 @@
state = sw_usual;
if (ch >= '0' && ch <= '9') {
- ch = (u_char) ((decoded << 4) + ch - '0');
+ ch = (u_char) ((decoded << 4) + (ch - '0'));
if (type & NGX_UNESCAPE_REDIRECT) {
if (ch > '%' && ch < 0x7f) {
@@ -1675,7 +1675,7 @@
c = (u_char) (ch | 0x20);
if (c >= 'a' && c <= 'f') {
- ch = (u_char) ((decoded << 4) + c - 'a' + 10);
+ ch = (u_char) ((decoded << 4) + (c - 'a') + 10);
if (type & NGX_UNESCAPE_URI) {
if (ch == '?') {
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/event/ngx_event.h
^
|
@@ -152,12 +152,12 @@
ngx_event_handler_pt handler;
ngx_file_t *file;
+ ngx_fd_t fd;
+
#if (NGX_HAVE_AIO_SENDFILE || NGX_COMPAT)
ssize_t (*preload_handler)(ngx_buf_t *file);
#endif
- ngx_fd_t fd;
-
#if (NGX_HAVE_EVENTFD)
int64_t res;
#endif
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/event/ngx_event_openssl.c
^
|
@@ -924,6 +924,7 @@
cln->data = passwords;
fd = ngx_open_file(file->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
+
if (fd == NGX_INVALID_FILE) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
ngx_open_file_n " \"%s\" failed", file->data);
@@ -2905,7 +2906,9 @@
file.name = path[i];
file.log = cf->log;
- file.fd = ngx_open_file(file.name.data, NGX_FILE_RDONLY, 0, 0);
+ file.fd = ngx_open_file(file.name.data, NGX_FILE_RDONLY,
+ NGX_FILE_OPEN, 0);
+
if (file.fd == NGX_INVALID_FILE) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
ngx_open_file_n " \"%V\" failed", &file.name);
@@ -3128,7 +3131,7 @@
{
if (paths) {
ngx_log_error(NGX_LOG_WARN, ssl->log, 0,
- "\"ssl_session_ticket_keys\" ignored, not supported");
+ "\"ssl_session_ticket_key\" ignored, not supported");
}
return NGX_OK;
@@ -3548,13 +3551,22 @@
{
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
- const char *servername;
+ size_t len;
+ const char *name;
+
+ name = SSL_get_servername(c->ssl->connection, TLSEXT_NAMETYPE_host_name);
+
+ if (name) {
+ len = ngx_strlen(name);
+
+ s->len = len;
+ s->data = ngx_pnalloc(pool, len);
+ if (s->data == NULL) {
+ return NGX_ERROR;
+ }
+
+ ngx_memcpy(s->data, name, len);
- servername = SSL_get_servername(c->ssl->connection,
- TLSEXT_NAMETYPE_host_name);
- if (servername) {
- s->data = (u_char *) servername;
- s->len = ngx_strlen(servername);
return NGX_OK;
}
@@ -3657,6 +3669,36 @@
return NGX_OK;
}
+
+
+ngx_int_t
+ngx_ssl_get_escaped_certificate(ngx_connection_t *c, ngx_pool_t *pool,
+ ngx_str_t *s)
+{
+ ngx_str_t cert;
+ uintptr_t n;
+
+ if (ngx_ssl_get_raw_certificate(c, pool, &cert) != NGX_OK) {
+ return NGX_ERROR;
+ }
+
+ if (cert.len == 0) {
+ s->len = 0;
+ return NGX_OK;
+ }
+
+ n = ngx_escape_uri(NULL, cert.data, cert.len, NGX_ESCAPE_URI_COMPONENT);
+
+ s->len = cert.len + n * 2;
+ s->data = ngx_pnalloc(pool, s->len);
+ if (s->data == NULL) {
+ return NGX_ERROR;
+ }
+
+ ngx_escape_uri(s->data, cert.data, cert.len, NGX_ESCAPE_URI_COMPONENT);
+
+ return NGX_OK;
+}
ngx_int_t
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/event/ngx_event_openssl.h
^
|
@@ -212,6 +212,8 @@
ngx_str_t *s);
ngx_int_t ngx_ssl_get_certificate(ngx_connection_t *c, ngx_pool_t *pool,
ngx_str_t *s);
+ngx_int_t ngx_ssl_get_escaped_certificate(ngx_connection_t *c, ngx_pool_t *pool,
+ ngx_str_t *s);
ngx_int_t ngx_ssl_get_subject_dn(ngx_connection_t *c, ngx_pool_t *pool,
ngx_str_t *s);
ngx_int_t ngx_ssl_get_issuer_dn(ngx_connection_t *c, ngx_pool_t *pool,
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/event/ngx_event_openssl_stapling.c
^
|
@@ -1486,7 +1486,7 @@
return NGX_ERROR;
}
- ctx->code = ctx->code * 10 + ch - '0';
+ ctx->code = ctx->code * 10 + (ch - '0');
if (++ctx->count == 3) {
state = sw_space_after_status;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_addition_filter_module.c
^
|
@@ -123,6 +123,8 @@
ngx_http_clear_accept_ranges(r);
ngx_http_weak_etag(r);
+ r->preserve_body = 1;
+
return ngx_http_next_header_filter(r);
}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_browser_module.c
^
|
@@ -38,13 +38,6 @@
typedef struct {
- ngx_str_t name;
- ngx_http_get_variable_pt handler;
- uintptr_t data;
-} ngx_http_browser_variable_t;
-
-
-typedef struct {
ngx_array_t *modern_browsers;
ngx_array_t *ancient_browsers;
ngx_http_variable_value_t *modern_browser_value;
@@ -63,7 +56,7 @@
static ngx_uint_t ngx_http_browser(ngx_http_request_t *r,
ngx_http_browser_conf_t *cf);
-static ngx_int_t ngx_http_browser_add_variable(ngx_conf_t *cf);
+static ngx_int_t ngx_http_browser_add_variables(ngx_conf_t *cf);
static void *ngx_http_browser_create_conf(ngx_conf_t *cf);
static char *ngx_http_browser_merge_conf(ngx_conf_t *cf, void *parent,
void *child);
@@ -114,7 +107,7 @@
static ngx_http_module_t ngx_http_browser_module_ctx = {
- ngx_http_browser_add_variable, /* preconfiguration */
+ ngx_http_browser_add_variables, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
@@ -218,13 +211,18 @@
};
-static ngx_http_browser_variable_t ngx_http_browsers[] = {
- { ngx_string("msie"), ngx_http_msie_variable, 0 },
- { ngx_string("modern_browser"), ngx_http_browser_variable,
- NGX_HTTP_MODERN_BROWSER },
- { ngx_string("ancient_browser"), ngx_http_browser_variable,
- NGX_HTTP_ANCIENT_BROWSER },
- { ngx_null_string, NULL, 0 }
+static ngx_http_variable_t ngx_http_browser_vars[] = {
+
+ { ngx_string("msie"), NULL, ngx_http_msie_variable,
+ 0, NGX_HTTP_VAR_CHANGEABLE, 0 },
+
+ { ngx_string("modern_browser"), NULL, ngx_http_browser_variable,
+ NGX_HTTP_MODERN_BROWSER, NGX_HTTP_VAR_CHANGEABLE, 0 },
+
+ { ngx_string("ancient_browser"), NULL, ngx_http_browser_variable,
+ NGX_HTTP_ANCIENT_BROWSER, NGX_HTTP_VAR_CHANGEABLE, 0 },
+
+ ngx_http_null_variable
};
@@ -397,20 +395,19 @@
static ngx_int_t
-ngx_http_browser_add_variable(ngx_conf_t *cf)
+ngx_http_browser_add_variables(ngx_conf_t *cf)
{
- ngx_http_browser_variable_t *var;
- ngx_http_variable_t *v;
+ ngx_http_variable_t *var, *v;
- for (var = ngx_http_browsers; var->name.len; var++) {
+ for (v = ngx_http_browser_vars; v->name.len; v++) {
- v = ngx_http_add_variable(cf, &var->name, NGX_HTTP_VAR_CHANGEABLE);
- if (v == NULL) {
+ var = ngx_http_add_variable(cf, &v->name, v->flags);
+ if (var == NULL) {
return NGX_ERROR;
}
- v->get_handler = var->handler;
- v->data = var->data;
+ var->get_handler = v->get_handler;
+ var->data = v->data;
}
return NGX_OK;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_fastcgi_module.c
^
|
@@ -631,7 +631,7 @@
ngx_http_fastcgi_path_info_variable, 0,
NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_geo_module.c
^
|
@@ -1400,7 +1400,8 @@
file.name = *name;
file.log = cf->log;
- file.fd = ngx_open_file(name->data, NGX_FILE_RDONLY, 0, 0);
+ file.fd = ngx_open_file(name->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
+
if (file.fd == NGX_INVALID_FILE) {
err = ngx_errno;
if (err != NGX_ENOENT) {
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_geoip_module.c
^
|
@@ -232,7 +232,7 @@
ngx_http_geoip_city_int_variable,
offsetof(GeoIPRecord, area_code), 0, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
|
[-]
[+]
|
Added |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_mirror_module.c
^
|
@@ -0,0 +1,264 @@
+
+/*
+ * Copyright (C) Roman Arutyunyan
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_http.h>
+
+
+typedef struct {
+ ngx_array_t *mirror;
+ ngx_flag_t request_body;
+} ngx_http_mirror_loc_conf_t;
+
+
+typedef struct {
+ ngx_int_t status;
+} ngx_http_mirror_ctx_t;
+
+
+static ngx_int_t ngx_http_mirror_handler(ngx_http_request_t *r);
+static void ngx_http_mirror_body_handler(ngx_http_request_t *r);
+static ngx_int_t ngx_http_mirror_handler_internal(ngx_http_request_t *r);
+static void *ngx_http_mirror_create_loc_conf(ngx_conf_t *cf);
+static char *ngx_http_mirror_merge_loc_conf(ngx_conf_t *cf, void *parent,
+ void *child);
+static char *ngx_http_mirror(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static ngx_int_t ngx_http_mirror_init(ngx_conf_t *cf);
+
+
+static ngx_command_t ngx_http_mirror_commands[] = {
+
+ { ngx_string("mirror"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_http_mirror,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ { ngx_string("mirror_request_body"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_mirror_loc_conf_t, request_body),
+ NULL },
+
+ ngx_null_command
+};
+
+
+static ngx_http_module_t ngx_http_mirror_module_ctx = {
+ NULL, /* preconfiguration */
+ ngx_http_mirror_init, /* postconfiguration */
+
+ NULL, /* create main configuration */
+ NULL, /* init main configuration */
+
+ NULL, /* create server configuration */
+ NULL, /* merge server configuration */
+
+ ngx_http_mirror_create_loc_conf, /* create location configuration */
+ ngx_http_mirror_merge_loc_conf /* merge location configuration */
+};
+
+
+ngx_module_t ngx_http_mirror_module = {
+ NGX_MODULE_V1,
+ &ngx_http_mirror_module_ctx, /* module context */
+ ngx_http_mirror_commands, /* module directives */
+ NGX_HTTP_MODULE, /* module type */
+ NULL, /* init master */
+ NULL, /* init module */
+ NULL, /* init process */
+ NULL, /* init thread */
+ NULL, /* exit thread */
+ NULL, /* exit process */
+ NULL, /* exit master */
+ NGX_MODULE_V1_PADDING
+};
+
+
+static ngx_int_t
+ngx_http_mirror_handler(ngx_http_request_t *r)
+{
+ ngx_int_t rc;
+ ngx_http_mirror_ctx_t *ctx;
+ ngx_http_mirror_loc_conf_t *mlcf;
+
+ if (r != r->main) {
+ return NGX_DECLINED;
+ }
+
+ mlcf = ngx_http_get_module_loc_conf(r, ngx_http_mirror_module);
+
+ if (mlcf->mirror == NULL) {
+ return NGX_DECLINED;
+ }
+
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "mirror handler");
+
+ if (mlcf->request_body) {
+ ctx = ngx_http_get_module_ctx(r, ngx_http_mirror_module);
+
+ if (ctx) {
+ return ctx->status;
+ }
+
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_mirror_ctx_t));
+ if (ctx == NULL) {
+ return NGX_ERROR;
+ }
+
+ ctx->status = NGX_DONE;
+
+ ngx_http_set_ctx(r, ctx, ngx_http_mirror_module);
+
+ rc = ngx_http_read_client_request_body(r, ngx_http_mirror_body_handler);
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
+ return rc;
+ }
+
+ ngx_http_finalize_request(r, NGX_DONE);
+ return NGX_DONE;
+ }
+
+ return ngx_http_mirror_handler_internal(r);
+}
+
+
+static void
+ngx_http_mirror_body_handler(ngx_http_request_t *r)
+{
+ ngx_http_mirror_ctx_t *ctx;
+
+ ctx = ngx_http_get_module_ctx(r, ngx_http_mirror_module);
+
+ ctx->status = ngx_http_mirror_handler_internal(r);
+
+ r->preserve_body = 1;
+
+ r->write_event_handler = ngx_http_core_run_phases;
+ ngx_http_core_run_phases(r);
+}
+
+
+static ngx_int_t
+ngx_http_mirror_handler_internal(ngx_http_request_t *r)
+{
+ ngx_str_t *name;
+ ngx_uint_t i;
+ ngx_http_request_t *sr;
+ ngx_http_mirror_loc_conf_t *mlcf;
+
+ mlcf = ngx_http_get_module_loc_conf(r, ngx_http_mirror_module);
+
+ name = mlcf->mirror->elts;
+
+ for (i = 0; i < mlcf->mirror->nelts; i++) {
+ if (ngx_http_subrequest(r, &name[i], &r->args, &sr, NULL,
+ NGX_HTTP_SUBREQUEST_BACKGROUND)
+ != NGX_OK)
+ {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ sr->header_only = 1;
+ sr->method = r->method;
+ sr->method_name = r->method_name;
+ }
+
+ return NGX_DECLINED;
+}
+
+
+static void *
+ngx_http_mirror_create_loc_conf(ngx_conf_t *cf)
+{
+ ngx_http_mirror_loc_conf_t *mlcf;
+
+ mlcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_mirror_loc_conf_t));
+ if (mlcf == NULL) {
+ return NULL;
+ }
+
+ mlcf->mirror = NGX_CONF_UNSET_PTR;
+ mlcf->request_body = NGX_CONF_UNSET;
+
+ return mlcf;
+}
+
+
+static char *
+ngx_http_mirror_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
+{
+ ngx_http_mirror_loc_conf_t *prev = parent;
+ ngx_http_mirror_loc_conf_t *conf = child;
+
+ ngx_conf_merge_ptr_value(conf->mirror, prev->mirror, NULL);
+ ngx_conf_merge_value(conf->request_body, prev->request_body, 1);
+
+ return NGX_CONF_OK;
+}
+
+
+static char *
+ngx_http_mirror(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_http_mirror_loc_conf_t *mlcf = conf;
+
+ ngx_str_t *value, *s;
+
+ value = cf->args->elts;
+
+ if (ngx_strcmp(value[1].data, "off") == 0) {
+ if (mlcf->mirror != NGX_CONF_UNSET_PTR) {
+ return "is duplicate";
+ }
+
+ mlcf->mirror = NULL;
+ return NGX_CONF_OK;
+ }
+
+ if (mlcf->mirror == NULL) {
+ return "is duplicate";
+ }
+
+ if (mlcf->mirror == NGX_CONF_UNSET_PTR) {
+ mlcf->mirror = ngx_array_create(cf->pool, 4, sizeof(ngx_str_t));
+ if (mlcf->mirror == NULL) {
+ return NGX_CONF_ERROR;
+ }
+ }
+
+ s = ngx_array_push(mlcf->mirror);
+ if (s == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ *s = value[1];
+
+ return NGX_CONF_OK;
+}
+
+
+static ngx_int_t
+ngx_http_mirror_init(ngx_conf_t *cf)
+{
+ ngx_http_handler_pt *h;
+ ngx_http_core_main_conf_t *cmcf;
+
+ cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
+
+ h = ngx_array_push(&cmcf->phases[NGX_HTTP_PRECONTENT_PHASE].handlers);
+ if (h == NULL) {
+ return NGX_ERROR;
+ }
+
+ *h = ngx_http_mirror_handler;
+
+ return NGX_OK;
+}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_proxy_module.c
^
|
@@ -829,7 +829,7 @@
ngx_http_proxy_internal_chunked_variable, 0,
NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_range_filter_module.c
^
|
@@ -315,7 +315,7 @@
return NGX_HTTP_RANGE_NOT_SATISFIABLE;
}
- start = start * 10 + *p++ - '0';
+ start = start * 10 + (*p++ - '0');
}
while (*p == ' ') { p++; }
@@ -345,7 +345,7 @@
return NGX_HTTP_RANGE_NOT_SATISFIABLE;
}
- end = end * 10 + *p++ - '0';
+ end = end * 10 + (*p++ - '0');
}
while (*p == ' ') { p++; }
@@ -463,23 +463,24 @@
ngx_http_range_multipart_header(ngx_http_request_t *r,
ngx_http_range_filter_ctx_t *ctx)
{
- size_t len;
+ off_t len;
+ size_t size;
ngx_uint_t i;
ngx_http_range_t *range;
ngx_atomic_uint_t boundary;
- len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
- + sizeof(CRLF "Content-Type: ") - 1
- + r->headers_out.content_type.len
- + sizeof(CRLF "Content-Range: bytes ") - 1;
+ size = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
+ + sizeof(CRLF "Content-Type: ") - 1
+ + r->headers_out.content_type.len
+ + sizeof(CRLF "Content-Range: bytes ") - 1;
if (r->headers_out.content_type_len == r->headers_out.content_type.len
&& r->headers_out.charset.len)
{
- len += sizeof("; charset=") - 1 + r->headers_out.charset.len;
+ size += sizeof("; charset=") - 1 + r->headers_out.charset.len;
}
- ctx->boundary_header.data = ngx_pnalloc(r->pool, len);
+ ctx->boundary_header.data = ngx_pnalloc(r->pool, size);
if (ctx->boundary_header.data == NULL) {
return NGX_ERROR;
}
@@ -569,7 +570,7 @@
- range[i].content_range.data;
len += ctx->boundary_header.len + range[i].content_range.len
- + (size_t) (range[i].end - range[i].start);
+ + (range[i].end - range[i].start);
}
r->headers_out.content_length_n = len;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_realip_module.c
^
|
@@ -122,7 +122,7 @@
{ ngx_string("realip_remote_port"), NULL,
ngx_http_realip_remote_port_variable, 0, 0, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_referer_module.c
^
|
@@ -32,6 +32,7 @@
} ngx_http_referer_conf_t;
+static ngx_int_t ngx_http_referer_add_variables(ngx_conf_t *cf);
static void * ngx_http_referer_create_conf(ngx_conf_t *cf);
static char * ngx_http_referer_merge_conf(ngx_conf_t *cf, void *parent,
void *child);
@@ -77,7 +78,7 @@
static ngx_http_module_t ngx_http_referer_module_ctx = {
- NULL, /* preconfiguration */
+ ngx_http_referer_add_variables, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
@@ -107,6 +108,9 @@
};
+static ngx_str_t ngx_http_invalid_referer_name = ngx_string("invalid_referer");
+
+
static ngx_int_t
ngx_http_referer_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
uintptr_t data)
@@ -263,6 +267,23 @@
}
+static ngx_int_t
+ngx_http_referer_add_variables(ngx_conf_t *cf)
+{
+ ngx_http_variable_t *var;
+
+ var = ngx_http_add_variable(cf, &ngx_http_invalid_referer_name,
+ NGX_HTTP_VAR_CHANGEABLE);
+ if (var == NULL) {
+ return NGX_ERROR;
+ }
+
+ var->get_handler = ngx_http_referer_variable;
+
+ return NGX_OK;
+}
+
+
static void *
ngx_http_referer_create_conf(ngx_conf_t *cf)
{
@@ -452,19 +473,9 @@
{
ngx_http_referer_conf_t *rlcf = conf;
- u_char *p;
- ngx_str_t *value, uri, name;
- ngx_uint_t i;
- ngx_http_variable_t *var;
-
- ngx_str_set(&name, "invalid_referer");
-
- var = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGEABLE);
- if (var == NULL) {
- return NGX_CONF_ERROR;
- }
-
- var->get_handler = ngx_http_referer_variable;
+ u_char *p;
+ ngx_str_t *value, uri;
+ ngx_uint_t i;
if (rlcf->keys == NULL) {
rlcf->keys = ngx_pcalloc(cf->temp_pool, sizeof(ngx_hash_keys_arrays_t));
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_scgi_module.c
^
|
@@ -819,7 +819,7 @@
key = e.pos;
#endif
code = *(ngx_http_script_code_pt *) e.ip;
- code((ngx_http_script_engine_t *) & e);
+ code((ngx_http_script_engine_t *) &e);
#if (NGX_DEBUG)
val = e.pos;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_secure_link_module.c
^
|
@@ -107,7 +107,7 @@
ngx_md5_t md5;
ngx_http_secure_link_ctx_t *ctx;
ngx_http_secure_link_conf_t *conf;
- u_char hash_buf[16], md5_buf[16];
+ u_char hash_buf[18], md5_buf[16];
conf = ngx_http_get_module_loc_conf(r, ngx_http_secure_link_module);
@@ -154,7 +154,6 @@
goto not_found;
}
- hash.len = 16;
hash.data = hash_buf;
if (ngx_decode_base64url(&hash, &val) != NGX_OK) {
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_slice_filter_module.c
^
|
@@ -190,6 +190,8 @@
return rc;
}
+ r->preserve_body = 1;
+
if (r->headers_out.status == NGX_HTTP_PARTIAL_CONTENT) {
if (ctx->start + (off_t) slcf->size <= r->headers_out.content_offset) {
ctx->start = slcf->size
@@ -317,7 +319,7 @@
return NGX_ERROR;
}
- start = start * 10 + *p++ - '0';
+ start = start * 10 + (*p++ - '0');
}
while (*p == ' ') { p++; }
@@ -337,7 +339,7 @@
return NGX_ERROR;
}
- end = end * 10 + *p++ - '0';
+ end = end * 10 + (*p++ - '0');
}
end++;
@@ -362,7 +364,7 @@
return NGX_ERROR;
}
- complete_length = complete_length * 10 + *p++ - '0';
+ complete_length = complete_length * 10 + (*p++ - '0');
}
} else {
@@ -479,7 +481,7 @@
return 0;
}
- start = start * 10 + *p++ - '0';
+ start = start * 10 + (*p++ - '0');
}
return start;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_ssi_filter_module.c
^
|
@@ -321,7 +321,7 @@
{ ngx_string("date_gmt"), NULL, ngx_http_ssi_date_gmt_local_variable, 1,
NGX_HTTP_VAR_NOCACHEABLE, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
@@ -370,6 +370,8 @@
ngx_http_clear_content_length(r);
ngx_http_clear_accept_ranges(r);
+ r->preserve_body = 1;
+
if (!slcf->last_modified) {
ngx_http_clear_last_modified(r);
ngx_http_clear_etag(r);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_ssl_module.c
^
|
@@ -299,6 +299,10 @@
(uintptr_t) ngx_ssl_get_raw_certificate,
NGX_HTTP_VAR_CHANGEABLE, 0 },
+ { ngx_string("ssl_client_escaped_cert"), NULL, ngx_http_ssl_variable,
+ (uintptr_t) ngx_ssl_get_escaped_certificate,
+ NGX_HTTP_VAR_CHANGEABLE, 0 },
+
{ ngx_string("ssl_client_s_dn"), NULL, ngx_http_ssl_variable,
(uintptr_t) ngx_ssl_get_subject_dn, NGX_HTTP_VAR_CHANGEABLE, 0 },
@@ -329,7 +333,7 @@
{ ngx_string("ssl_client_v_remain"), NULL, ngx_http_ssl_variable,
(uintptr_t) ngx_ssl_get_client_v_remain, NGX_HTTP_VAR_CHANGEABLE, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_stub_status_module.c
^
|
@@ -76,7 +76,7 @@
{ ngx_string("connections_waiting"), NULL, ngx_http_stub_status_variable,
3, NGX_HTTP_VAR_NOCACHEABLE, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
|
[-]
[+]
|
Added |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_try_files_module.c
^
|
@@ -0,0 +1,404 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_http.h>
+
+
+typedef struct {
+ ngx_array_t *lengths;
+ ngx_array_t *values;
+ ngx_str_t name;
+
+ unsigned code:10;
+ unsigned test_dir:1;
+} ngx_http_try_file_t;
+
+
+typedef struct {
+ ngx_http_try_file_t *try_files;
+} ngx_http_try_files_loc_conf_t;
+
+
+static ngx_int_t ngx_http_try_files_handler(ngx_http_request_t *r);
+static char *ngx_http_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static void *ngx_http_try_files_create_loc_conf(ngx_conf_t *cf);
+static ngx_int_t ngx_http_try_files_init(ngx_conf_t *cf);
+
+
+static ngx_command_t ngx_http_try_files_commands[] = {
+
+ { ngx_string("try_files"),
+ NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE,
+ ngx_http_try_files,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ 0,
+ NULL },
+
+ ngx_null_command
+};
+
+
+static ngx_http_module_t ngx_http_try_files_module_ctx = {
+ NULL, /* preconfiguration */
+ ngx_http_try_files_init, /* postconfiguration */
+
+ NULL, /* create main configuration */
+ NULL, /* init main configuration */
+
+ NULL, /* create server configuration */
+ NULL, /* merge server configuration */
+
+ ngx_http_try_files_create_loc_conf, /* create location configuration */
+ NULL /* merge location configuration */
+};
+
+
+ngx_module_t ngx_http_try_files_module = {
+ NGX_MODULE_V1,
+ &ngx_http_try_files_module_ctx, /* module context */
+ ngx_http_try_files_commands, /* module directives */
+ NGX_HTTP_MODULE, /* module type */
+ NULL, /* init master */
+ NULL, /* init module */
+ NULL, /* init process */
+ NULL, /* init thread */
+ NULL, /* exit thread */
+ NULL, /* exit process */
+ NULL, /* exit master */
+ NGX_MODULE_V1_PADDING
+};
+
+
+static ngx_int_t
+ngx_http_try_files_handler(ngx_http_request_t *r)
+{
+ size_t len, root, alias, reserve, allocated;
+ u_char *p, *name;
+ ngx_str_t path, args;
+ ngx_uint_t test_dir;
+ ngx_http_try_file_t *tf;
+ ngx_open_file_info_t of;
+ ngx_http_script_code_pt code;
+ ngx_http_script_engine_t e;
+ ngx_http_core_loc_conf_t *clcf;
+ ngx_http_script_len_code_pt lcode;
+ ngx_http_try_files_loc_conf_t *tlcf;
+
+ tlcf = ngx_http_get_module_loc_conf(r, ngx_http_try_files_module);
+
+ if (tlcf->try_files == NULL) {
+ return NGX_DECLINED;
+ }
+
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "try files handler");
+
+ allocated = 0;
+ root = 0;
+ name = NULL;
+ /* suppress MSVC warning */
+ path.data = NULL;
+
+ tf = tlcf->try_files;
+
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
+ alias = clcf->alias;
+
+ for ( ;; ) {
+
+ if (tf->lengths) {
+ ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
+
+ e.ip = tf->lengths->elts;
+ e.request = r;
+
+ /* 1 is for terminating '\0' as in static names */
+ len = 1;
+
+ while (*(uintptr_t *) e.ip) {
+ lcode = *(ngx_http_script_len_code_pt *) e.ip;
+ len += lcode(&e);
+ }
+
+ } else {
+ len = tf->name.len;
+ }
+
+ if (!alias) {
+ reserve = len > r->uri.len ? len - r->uri.len : 0;
+
+ } else if (alias == NGX_MAX_SIZE_T_VALUE) {
+ reserve = len;
+
+ } else {
+ reserve = len > r->uri.len - alias ? len - (r->uri.len - alias) : 0;
+ }
+
+ if (reserve > allocated || !allocated) {
+
+ /* 16 bytes are preallocation */
+ allocated = reserve + 16;
+
+ if (ngx_http_map_uri_to_path(r, &path, &root, allocated) == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ name = path.data + root;
+ }
+
+ if (tf->values == NULL) {
+
+ /* tf->name.len includes the terminating '\0' */
+
+ ngx_memcpy(name, tf->name.data, tf->name.len);
+
+ path.len = (name + tf->name.len - 1) - path.data;
+
+ } else {
+ e.ip = tf->values->elts;
+ e.pos = name;
+ e.flushed = 1;
+
+ while (*(uintptr_t *) e.ip) {
+ code = *(ngx_http_script_code_pt *) e.ip;
+ code((ngx_http_script_engine_t *) &e);
+ }
+
+ path.len = e.pos - path.data;
+
+ *e.pos = '\0';
+
+ if (alias && alias != NGX_MAX_SIZE_T_VALUE
+ && ngx_strncmp(name, r->uri.data, alias) == 0)
+ {
+ ngx_memmove(name, name + alias, len - alias);
+ path.len -= alias;
+ }
+ }
+
+ test_dir = tf->test_dir;
+
+ tf++;
+
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "trying to use %s: \"%s\" \"%s\"",
+ test_dir ? "dir" : "file", name, path.data);
+
+ if (tf->lengths == NULL && tf->name.len == 0) {
+
+ if (tf->code) {
+ return tf->code;
+ }
+
+ path.len -= root;
+ path.data += root;
+
+ if (path.data[0] == '@') {
+ (void) ngx_http_named_location(r, &path);
+
+ } else {
+ ngx_http_split_args(r, &path, &args);
+
+ (void) ngx_http_internal_redirect(r, &path, &args);
+ }
+
+ ngx_http_finalize_request(r, NGX_DONE);
+ return NGX_DONE;
+ }
+
+ ngx_memzero(&of, sizeof(ngx_open_file_info_t));
+
+ of.read_ahead = clcf->read_ahead;
+ of.directio = clcf->directio;
+ of.valid = clcf->open_file_cache_valid;
+ of.min_uses = clcf->open_file_cache_min_uses;
+ of.test_only = 1;
+ of.errors = clcf->open_file_cache_errors;
+ of.events = clcf->open_file_cache_events;
+
+ if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
+ != NGX_OK)
+ {
+ if (of.err == 0) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ if (of.err != NGX_ENOENT
+ && of.err != NGX_ENOTDIR
+ && of.err != NGX_ENAMETOOLONG)
+ {
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
+ "%s \"%s\" failed", of.failed, path.data);
+ }
+
+ continue;
+ }
+
+ if (of.is_dir != test_dir) {
+ continue;
+ }
+
+ path.len -= root;
+ path.data += root;
+
+ if (!alias) {
+ r->uri = path;
+
+ } else if (alias == NGX_MAX_SIZE_T_VALUE) {
+ if (!test_dir) {
+ r->uri = path;
+ r->add_uri_to_alias = 1;
+ }
+
+ } else {
+ name = r->uri.data;
+
+ r->uri.len = alias + path.len;
+ r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
+ if (r->uri.data == NULL) {
+ r->uri.len = 0;
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ p = ngx_copy(r->uri.data, name, alias);
+ ngx_memcpy(p, path.data, path.len);
+ }
+
+ ngx_http_set_exten(r);
+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "try file uri: \"%V\"", &r->uri);
+
+ return NGX_DECLINED;
+ }
+
+ /* not reached */
+}
+
+
+static char *
+ngx_http_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_http_try_files_loc_conf_t *tlcf = conf;
+
+ ngx_str_t *value;
+ ngx_int_t code;
+ ngx_uint_t i, n;
+ ngx_http_try_file_t *tf;
+ ngx_http_script_compile_t sc;
+
+ if (tlcf->try_files) {
+ return "is duplicate";
+ }
+
+ tf = ngx_pcalloc(cf->pool, cf->args->nelts * sizeof(ngx_http_try_file_t));
+ if (tf == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+ tlcf->try_files = tf;
+
+ value = cf->args->elts;
+
+ for (i = 0; i < cf->args->nelts - 1; i++) {
+
+ tf[i].name = value[i + 1];
+
+ if (tf[i].name.len > 0
+ && tf[i].name.data[tf[i].name.len - 1] == '/'
+ && i + 2 < cf->args->nelts)
+ {
+ tf[i].test_dir = 1;
+ tf[i].name.len--;
+ tf[i].name.data[tf[i].name.len] = '\0';
+ }
+
+ n = ngx_http_script_variables_count(&tf[i].name);
+
+ if (n) {
+ ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
+
+ sc.cf = cf;
+ sc.source = &tf[i].name;
+ sc.lengths = &tf[i].lengths;
+ sc.values = &tf[i].values;
+ sc.variables = n;
+ sc.complete_lengths = 1;
+ sc.complete_values = 1;
+
+ if (ngx_http_script_compile(&sc) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
+
+ } else {
+ /* add trailing '\0' to length */
+ tf[i].name.len++;
+ }
+ }
+
+ if (tf[i - 1].name.data[0] == '=') {
+
+ code = ngx_atoi(tf[i - 1].name.data + 1, tf[i - 1].name.len - 2);
+
+ if (code == NGX_ERROR || code > 999) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid code \"%*s\"",
+ tf[i - 1].name.len - 1, tf[i - 1].name.data);
+ return NGX_CONF_ERROR;
+ }
+
+ tf[i].code = code;
+ }
+
+ return NGX_CONF_OK;
+}
+
+
+static void *
+ngx_http_try_files_create_loc_conf(ngx_conf_t *cf)
+{
+ ngx_http_try_files_loc_conf_t *tlcf;
+
+ tlcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_try_files_loc_conf_t));
+ if (tlcf == NULL) {
+ return NULL;
+ }
+
+ /*
+ * set by ngx_pcalloc():
+ *
+ * tlcf->try_files = NULL;
+ */
+
+ return tlcf;
+}
+
+
+static ngx_int_t
+ngx_http_try_files_init(ngx_conf_t *cf)
+{
+ ngx_http_handler_pt *h;
+ ngx_http_core_main_conf_t *cmcf;
+
+ cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
+
+ h = ngx_array_push(&cmcf->phases[NGX_HTTP_PRECONTENT_PHASE].handlers);
+ if (h == NULL) {
+ return NGX_ERROR;
+ }
+
+ *h = ngx_http_try_files_handler;
+
+ return NGX_OK;
+}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_upstream_zone_module.c
^
|
@@ -16,6 +16,8 @@
void *data);
static ngx_http_upstream_rr_peers_t *ngx_http_upstream_zone_copy_peers(
ngx_slab_pool_t *shpool, ngx_http_upstream_srv_conf_t *uscf);
+static ngx_http_upstream_rr_peer_t *ngx_http_upstream_zone_copy_peer(
+ ngx_http_upstream_rr_peers_t *peers, ngx_http_upstream_rr_peer_t *src);
static ngx_command_t ngx_http_upstream_zone_commands[] = {
@@ -185,6 +187,7 @@
ngx_http_upstream_zone_copy_peers(ngx_slab_pool_t *shpool,
ngx_http_upstream_srv_conf_t *uscf)
{
+ ngx_str_t *name;
ngx_http_upstream_rr_peer_t *peer, **peerp;
ngx_http_upstream_rr_peers_t *peers, *backup;
@@ -195,18 +198,30 @@
ngx_memcpy(peers, uscf->peer.data, sizeof(ngx_http_upstream_rr_peers_t));
+ name = ngx_slab_alloc(shpool, sizeof(ngx_str_t));
+ if (name == NULL) {
+ return NULL;
+ }
+
+ name->data = ngx_slab_alloc(shpool, peers->name->len);
+ if (name->data == NULL) {
+ return NULL;
+ }
+
+ ngx_memcpy(name->data, peers->name->data, peers->name->len);
+ name->len = peers->name->len;
+
+ peers->name = name;
+
peers->shpool = shpool;
for (peerp = &peers->peer; *peerp; peerp = &peer->next) {
/* pool is unlocked */
- peer = ngx_slab_calloc_locked(shpool,
- sizeof(ngx_http_upstream_rr_peer_t));
+ peer = ngx_http_upstream_zone_copy_peer(peers, *peerp);
if (peer == NULL) {
return NULL;
}
- ngx_memcpy(peer, *peerp, sizeof(ngx_http_upstream_rr_peer_t));
-
*peerp = peer;
}
@@ -221,18 +236,17 @@
ngx_memcpy(backup, peers->next, sizeof(ngx_http_upstream_rr_peers_t));
+ backup->name = name;
+
backup->shpool = shpool;
for (peerp = &backup->peer; *peerp; peerp = &peer->next) {
/* pool is unlocked */
- peer = ngx_slab_calloc_locked(shpool,
- sizeof(ngx_http_upstream_rr_peer_t));
+ peer = ngx_http_upstream_zone_copy_peer(backup, *peerp);
if (peer == NULL) {
return NULL;
}
- ngx_memcpy(peer, *peerp, sizeof(ngx_http_upstream_rr_peer_t));
-
*peerp = peer;
}
@@ -244,3 +258,68 @@
return peers;
}
+
+
+static ngx_http_upstream_rr_peer_t *
+ngx_http_upstream_zone_copy_peer(ngx_http_upstream_rr_peers_t *peers,
+ ngx_http_upstream_rr_peer_t *src)
+{
+ ngx_slab_pool_t *pool;
+ ngx_http_upstream_rr_peer_t *dst;
+
+ pool = peers->shpool;
+
+ dst = ngx_slab_calloc_locked(pool, sizeof(ngx_http_upstream_rr_peer_t));
+ if (dst == NULL) {
+ return NULL;
+ }
+
+ if (src) {
+ ngx_memcpy(dst, src, sizeof(ngx_http_upstream_rr_peer_t));
+ dst->sockaddr = NULL;
+ dst->name.data = NULL;
+ dst->server.data = NULL;
+ }
+
+ dst->sockaddr = ngx_slab_calloc_locked(pool, NGX_SOCKADDRLEN);
+ if (dst->sockaddr == NULL) {
+ goto failed;
+ }
+
+ dst->name.data = ngx_slab_calloc_locked(pool, NGX_SOCKADDR_STRLEN);
+ if (dst->name.data == NULL) {
+ goto failed;
+ }
+
+ if (src) {
+ ngx_memcpy(dst->sockaddr, src->sockaddr, src->socklen);
+ ngx_memcpy(dst->name.data, src->name.data, src->name.len);
+
+ dst->server.data = ngx_slab_alloc_locked(pool, src->server.len);
+ if (dst->server.data == NULL) {
+ goto failed;
+ }
+
+ ngx_memcpy(dst->server.data, src->server.data, src->server.len);
+ }
+
+ return dst;
+
+failed:
+
+ if (dst->server.data) {
+ ngx_slab_free_locked(pool, dst->server.data);
+ }
+
+ if (dst->name.data) {
+ ngx_slab_free_locked(pool, dst->name.data);
+ }
+
+ if (dst->sockaddr) {
+ ngx_slab_free_locked(pool, dst->sockaddr);
+ }
+
+ ngx_slab_free_locked(pool, dst);
+
+ return NULL;
+}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/modules/ngx_http_uwsgi_module.c
^
|
@@ -865,7 +865,7 @@
lcode = *(ngx_http_script_len_code_pt *) le.ip;
skip_empty = lcode(&le);
- for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode (&le)) {
+ for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
lcode = *(ngx_http_script_len_code_pt *) le.ip;
}
le.ip += sizeof(uintptr_t);
@@ -990,7 +990,7 @@
while (*(uintptr_t *) le.ip) {
lcode = *(ngx_http_script_len_code_pt *) le.ip;
- key_len = (u_char) lcode (&le);
+ key_len = (u_char) lcode(&le);
lcode = *(ngx_http_script_len_code_pt *) le.ip;
skip_empty = lcode(&le);
@@ -1018,14 +1018,14 @@
*e.pos++ = (u_char) ((key_len >> 8) & 0xff);
code = *(ngx_http_script_code_pt *) e.ip;
- code((ngx_http_script_engine_t *) & e);
+ code((ngx_http_script_engine_t *) &e);
*e.pos++ = (u_char) (val_len & 0xff);
*e.pos++ = (u_char) ((val_len >> 8) & 0xff);
while (*(uintptr_t *) e.ip) {
code = *(ngx_http_script_code_pt *) e.ip;
- code((ngx_http_script_engine_t *) & e);
+ code((ngx_http_script_engine_t *) &e);
}
e.ip += sizeof(uintptr_t);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http.c
^
|
@@ -382,6 +382,13 @@
return NGX_ERROR;
}
+ if (ngx_array_init(&cmcf->phases[NGX_HTTP_PRECONTENT_PHASE].handlers,
+ cf->pool, 2, sizeof(ngx_http_handler_pt))
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers,
cf->pool, 4, sizeof(ngx_http_handler_pt))
!= NGX_OK)
@@ -459,8 +466,7 @@
n = 1 /* find config phase */
+ use_rewrite /* post rewrite phase */
- + use_access /* post access phase */
- + cmcf->try_files;
+ + use_access; /* post access phase */
for (i = 0; i < NGX_HTTP_LOG_PHASE; i++) {
n += cmcf->phases[i].handlers.nelts;
@@ -529,15 +535,6 @@
continue;
- case NGX_HTTP_TRY_FILES_PHASE:
- if (cmcf->try_files) {
- ph->checker = ngx_http_core_try_files_phase;
- n++;
- ph++;
- }
-
- continue;
-
case NGX_HTTP_CONTENT_PHASE:
checker = ngx_http_core_content_phase;
break;
@@ -548,7 +545,7 @@
n += cmcf->phases[i].handlers.nelts;
- for (j = cmcf->phases[i].handlers.nelts - 1; j >=0; j--) {
+ for (j = cmcf->phases[i].handlers.nelts - 1; j >= 0; j--) {
ph->checker = checker;
ph->handler = h[j];
ph->next = n;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http_core_module.c
^
|
@@ -61,8 +61,6 @@
void *conf);
static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
-static char *ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd,
- void *conf);
static char *ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static char *ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd,
@@ -649,13 +647,6 @@
0,
NULL },
- { ngx_string("try_files"),
- NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE,
- ngx_http_core_try_files,
- NGX_HTTP_LOC_CONF_OFFSET,
- 0,
- NULL },
-
{ ngx_string("post_action"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|NGX_CONF_TAKE1,
@@ -1159,223 +1150,6 @@
ngx_int_t
-ngx_http_core_try_files_phase(ngx_http_request_t *r,
- ngx_http_phase_handler_t *ph)
-{
- size_t len, root, alias, reserve, allocated;
- u_char *p, *name;
- ngx_str_t path, args;
- ngx_uint_t test_dir;
- ngx_http_try_file_t *tf;
- ngx_open_file_info_t of;
- ngx_http_script_code_pt code;
- ngx_http_script_engine_t e;
- ngx_http_core_loc_conf_t *clcf;
- ngx_http_script_len_code_pt lcode;
-
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "try files phase: %ui", r->phase_handler);
-
- clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
-
- if (clcf->try_files == NULL) {
- r->phase_handler++;
- return NGX_AGAIN;
- }
-
- allocated = 0;
- root = 0;
- name = NULL;
- /* suppress MSVC warning */
- path.data = NULL;
-
- tf = clcf->try_files;
-
- alias = clcf->alias;
-
- for ( ;; ) {
-
- if (tf->lengths) {
- ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
-
- e.ip = tf->lengths->elts;
- e.request = r;
-
- /* 1 is for terminating '\0' as in static names */
- len = 1;
-
- while (*(uintptr_t *) e.ip) {
- lcode = *(ngx_http_script_len_code_pt *) e.ip;
- len += lcode(&e);
- }
-
- } else {
- len = tf->name.len;
- }
-
- if (!alias) {
- reserve = len > r->uri.len ? len - r->uri.len : 0;
-
- } else if (alias == NGX_MAX_SIZE_T_VALUE) {
- reserve = len;
-
- } else {
- reserve = len > r->uri.len - alias ? len - (r->uri.len - alias) : 0;
- }
-
- if (reserve > allocated || !allocated) {
-
- /* 16 bytes are preallocation */
- allocated = reserve + 16;
-
- if (ngx_http_map_uri_to_path(r, &path, &root, allocated) == NULL) {
- ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
- return NGX_OK;
- }
-
- name = path.data + root;
- }
-
- if (tf->values == NULL) {
-
- /* tf->name.len includes the terminating '\0' */
-
- ngx_memcpy(name, tf->name.data, tf->name.len);
-
- path.len = (name + tf->name.len - 1) - path.data;
-
- } else {
- e.ip = tf->values->elts;
- e.pos = name;
- e.flushed = 1;
-
- while (*(uintptr_t *) e.ip) {
- code = *(ngx_http_script_code_pt *) e.ip;
- code((ngx_http_script_engine_t *) &e);
- }
-
- path.len = e.pos - path.data;
-
- *e.pos = '\0';
-
- if (alias && alias != NGX_MAX_SIZE_T_VALUE
- && ngx_strncmp(name, r->uri.data, alias) == 0)
- {
- ngx_memmove(name, name + alias, len - alias);
- path.len -= alias;
- }
- }
-
- test_dir = tf->test_dir;
-
- tf++;
-
- ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "trying to use %s: \"%s\" \"%s\"",
- test_dir ? "dir" : "file", name, path.data);
-
- if (tf->lengths == NULL && tf->name.len == 0) {
-
- if (tf->code) {
- ngx_http_finalize_request(r, tf->code);
- return NGX_OK;
- }
-
- path.len -= root;
- path.data += root;
-
- if (path.data[0] == '@') {
- (void) ngx_http_named_location(r, &path);
-
- } else {
- ngx_http_split_args(r, &path, &args);
-
- (void) ngx_http_internal_redirect(r, &path, &args);
- }
-
- ngx_http_finalize_request(r, NGX_DONE);
- return NGX_OK;
- }
-
- ngx_memzero(&of, sizeof(ngx_open_file_info_t));
-
- of.read_ahead = clcf->read_ahead;
- of.directio = clcf->directio;
- of.valid = clcf->open_file_cache_valid;
- of.min_uses = clcf->open_file_cache_min_uses;
- of.test_only = 1;
- of.errors = clcf->open_file_cache_errors;
- of.events = clcf->open_file_cache_events;
-
- if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
- ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
- return NGX_OK;
- }
-
- if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
- != NGX_OK)
- {
- if (of.err == 0) {
- ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
- return NGX_OK;
- }
-
- if (of.err != NGX_ENOENT
- && of.err != NGX_ENOTDIR
- && of.err != NGX_ENAMETOOLONG)
- {
- ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
- "%s \"%s\" failed", of.failed, path.data);
- }
-
- continue;
- }
-
- if (of.is_dir != test_dir) {
- continue;
- }
-
- path.len -= root;
- path.data += root;
-
- if (!alias) {
- r->uri = path;
-
- } else if (alias == NGX_MAX_SIZE_T_VALUE) {
- if (!test_dir) {
- r->uri = path;
- r->add_uri_to_alias = 1;
- }
-
- } else {
- name = r->uri.data;
-
- r->uri.len = alias + path.len;
- r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
- if (r->uri.data == NULL) {
- r->uri.len = 0;
- ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
- return NGX_OK;
- }
-
- p = ngx_copy(r->uri.data, name, alias);
- ngx_memcpy(p, path.data, path.len);
- }
-
- ngx_http_set_exten(r);
-
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "try file uri: \"%V\"", &r->uri);
-
- r->phase_handler++;
- return NGX_AGAIN;
- }
-
- /* not reached */
-}
-
-
-ngx_int_t
ngx_http_core_content_phase(ngx_http_request_t *r,
ngx_http_phase_handler_t *ph)
{
@@ -3561,7 +3335,6 @@
* clcf->default_type = { 0, NULL };
* clcf->error_log = NULL;
* clcf->error_pages = NULL;
- * clcf->try_files = NULL;
* clcf->client_body_path = NULL;
* clcf->regex = NULL;
* clcf->exact_match = 0;
@@ -4881,89 +4654,6 @@
}
return NGX_CONF_OK;
-}
-
-
-static char *
-ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
-{
- ngx_http_core_loc_conf_t *clcf = conf;
-
- ngx_str_t *value;
- ngx_int_t code;
- ngx_uint_t i, n;
- ngx_http_try_file_t *tf;
- ngx_http_script_compile_t sc;
- ngx_http_core_main_conf_t *cmcf;
-
- if (clcf->try_files) {
- return "is duplicate";
- }
-
- cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
-
- cmcf->try_files = 1;
-
- tf = ngx_pcalloc(cf->pool, cf->args->nelts * sizeof(ngx_http_try_file_t));
- if (tf == NULL) {
- return NGX_CONF_ERROR;
- }
-
- clcf->try_files = tf;
-
- value = cf->args->elts;
-
- for (i = 0; i < cf->args->nelts - 1; i++) {
-
- tf[i].name = value[i + 1];
-
- if (tf[i].name.len > 0
- && tf[i].name.data[tf[i].name.len - 1] == '/'
- && i + 2 < cf->args->nelts)
- {
- tf[i].test_dir = 1;
- tf[i].name.len--;
- tf[i].name.data[tf[i].name.len] = '\0';
- }
-
- n = ngx_http_script_variables_count(&tf[i].name);
-
- if (n) {
- ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
-
- sc.cf = cf;
- sc.source = &tf[i].name;
- sc.lengths = &tf[i].lengths;
- sc.values = &tf[i].values;
- sc.variables = n;
- sc.complete_lengths = 1;
- sc.complete_values = 1;
-
- if (ngx_http_script_compile(&sc) != NGX_OK) {
- return NGX_CONF_ERROR;
- }
-
- } else {
- /* add trailing '\0' to length */
- tf[i].name.len++;
- }
- }
-
- if (tf[i - 1].name.data[0] == '=') {
-
- code = ngx_atoi(tf[i - 1].name.data + 1, tf[i - 1].name.len - 2);
-
- if (code == NGX_ERROR || code > 999) {
- ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
- "invalid code \"%*s\"",
- tf[i - 1].name.len - 1, tf[i - 1].name.data);
- return NGX_CONF_ERROR;
- }
-
- tf[i].code = code;
- }
-
- return NGX_CONF_OK;
}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http_core_module.h
^
|
@@ -119,7 +119,8 @@
NGX_HTTP_ACCESS_PHASE,
NGX_HTTP_POST_ACCESS_PHASE,
- NGX_HTTP_TRY_FILES_PHASE,
+ NGX_HTTP_PRECONTENT_PHASE,
+
NGX_HTTP_CONTENT_PHASE,
NGX_HTTP_LOG_PHASE
@@ -172,8 +173,6 @@
ngx_array_t *ports;
- ngx_uint_t try_files; /* unsigned try_files:1 */
-
ngx_http_phase_t phases[NGX_HTTP_LOG_PHASE + 1];
} ngx_http_core_main_conf_t;
@@ -296,16 +295,6 @@
} ngx_http_err_page_t;
-typedef struct {
- ngx_array_t *lengths;
- ngx_array_t *values;
- ngx_str_t name;
-
- unsigned code:10;
- unsigned test_dir:1;
-} ngx_http_try_file_t;
-
-
struct ngx_http_core_loc_conf_s {
ngx_str_t name; /* location name */
@@ -425,7 +414,6 @@
#endif
ngx_array_t *error_pages; /* error_page */
- ngx_http_try_file_t *try_files; /* try_files */
ngx_path_t *client_body_temp_path; /* client_body_temp_path */
@@ -486,8 +474,6 @@
ngx_http_phase_handler_t *ph);
ngx_int_t ngx_http_core_post_access_phase(ngx_http_request_t *r,
ngx_http_phase_handler_t *ph);
-ngx_int_t ngx_http_core_try_files_phase(ngx_http_request_t *r,
- ngx_http_phase_handler_t *ph);
ngx_int_t ngx_http_core_content_phase(ngx_http_request_t *r,
ngx_http_phase_handler_t *ph);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http_file_cache.c
^
|
@@ -129,6 +129,7 @@
if (shm_zone->shm.exists) {
cache->sh = cache->shpool->data;
cache->bsize = ngx_fs_bsize(cache->path->name.data);
+ cache->max_size /= cache->bsize;
return NGX_OK;
}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http_parse.c
^
|
@@ -742,7 +742,7 @@
return NGX_HTTP_PARSE_INVALID_REQUEST;
}
- r->http_major = r->http_major * 10 + ch - '0';
+ r->http_major = r->http_major * 10 + (ch - '0');
if (r->http_major > 1) {
return NGX_HTTP_PARSE_INVALID_VERSION;
@@ -784,7 +784,7 @@
return NGX_HTTP_PARSE_INVALID_REQUEST;
}
- r->http_minor = r->http_minor * 10 + ch - '0';
+ r->http_minor = r->http_minor * 10 + (ch - '0');
break;
case sw_spaces_after_digit:
@@ -1518,7 +1518,7 @@
case sw_quoted_second:
if (ch >= '0' && ch <= '9') {
- ch = (u_char) ((decoded << 4) + ch - '0');
+ ch = (u_char) ((decoded << 4) + (ch - '0'));
if (ch == '%' || ch == '#') {
state = sw_usual;
@@ -1536,7 +1536,7 @@
c = (u_char) (ch | 0x20);
if (c >= 'a' && c <= 'f') {
- ch = (u_char) ((decoded << 4) + c - 'a' + 10);
+ ch = (u_char) ((decoded << 4) + (c - 'a') + 10);
if (ch == '?') {
state = sw_usual;
@@ -1701,7 +1701,7 @@
return NGX_ERROR;
}
- r->http_major = r->http_major * 10 + ch - '0';
+ r->http_major = r->http_major * 10 + (ch - '0');
break;
/* the first digit of minor HTTP version */
@@ -1729,7 +1729,7 @@
return NGX_ERROR;
}
- r->http_minor = r->http_minor * 10 + ch - '0';
+ r->http_minor = r->http_minor * 10 + (ch - '0');
break;
/* HTTP status code */
@@ -1742,7 +1742,7 @@
return NGX_ERROR;
}
- status->code = status->code * 10 + ch - '0';
+ status->code = status->code * 10 + (ch - '0');
if (++status->count == 3) {
state = sw_space_after_status;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http_request.h
^
|
@@ -537,6 +537,7 @@
unsigned main_filter_need_in_memory:1;
unsigned filter_need_in_memory:1;
unsigned filter_need_temporary:1;
+ unsigned preserve_body:1;
unsigned allow_ranges:1;
unsigned subrequest_ranges:1;
unsigned single_range:1;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http_upstream.c
^
|
@@ -427,7 +427,7 @@
{ ngx_string("upstream_cookie_"), NULL, ngx_http_upstream_cookie_variable,
0, NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_PREFIX, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
@@ -1077,6 +1077,10 @@
return NGX_OK;
}
+ if (r == r->main) {
+ r->preserve_body = 1;
+ }
+
if (ngx_http_subrequest(r, &r->uri, &r->args, &sr, NULL,
NGX_HTTP_SUBREQUEST_CLONE
|NGX_HTTP_SUBREQUEST_BACKGROUND)
@@ -2857,7 +2861,9 @@
u->pipe->downstream_error = 1;
}
- if (r->request_body && r->request_body->temp_file) {
+ if (r->request_body && r->request_body->temp_file
+ && r == r->main && !r->preserve_body)
+ {
ngx_pool_run_cleanup_file(r->pool, r->request_body->temp_file->file.fd);
r->request_body->temp_file->file.fd = NGX_INVALID_FILE;
}
@@ -4384,15 +4390,8 @@
u = r->upstream;
u->headers_in.last_modified = h;
-
-#if (NGX_HTTP_CACHE)
-
- if (u->cacheable) {
- u->headers_in.last_modified_time = ngx_parse_http_time(h->value.data,
- h->value.len);
- }
-
-#endif
+ u->headers_in.last_modified_time = ngx_parse_http_time(h->value.data,
+ h->value.len);
return NGX_OK;
}
@@ -4503,7 +4502,7 @@
}
if (*p >= '0' && *p <= '9') {
- n = n * 10 + *p - '0';
+ n = n * 10 + (*p - '0');
continue;
}
@@ -4531,7 +4530,7 @@
}
if (*p >= '0' && *p <= '9') {
- n = n * 10 + *p - '0';
+ n = n * 10 + (*p - '0');
continue;
}
@@ -4554,7 +4553,7 @@
}
if (*p >= '0' && *p <= '9') {
- n = n * 10 + *p - '0';
+ n = n * 10 + (*p - '0');
continue;
}
@@ -4934,15 +4933,8 @@
*ho = *h;
r->headers_out.last_modified = ho;
-
-#if (NGX_HTTP_CACHE)
-
- if (r->upstream->cacheable) {
- r->headers_out.last_modified_time =
+ r->headers_out.last_modified_time =
r->upstream->headers_in.last_modified_time;
- }
-
-#endif
return NGX_OK;
}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http_variables.c
^
|
@@ -376,7 +376,7 @@
{ ngx_string("arg_"), NULL, ngx_http_variable_argument,
0, NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_PREFIX, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/ngx_http_variables.h
^
|
@@ -43,6 +43,8 @@
ngx_uint_t index;
};
+#define ngx_http_null_variable { ngx_null_string, NULL, NULL, 0, 0, 0 }
+
ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name,
ngx_uint_t flags);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/http/v2/ngx_http_v2_module.c
^
|
@@ -225,7 +225,7 @@
{ ngx_string("http2"), NULL,
ngx_http_v2_variable, 0, 0, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_http_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/misc/ngx_google_perftools_module.c
^
|
@@ -36,7 +36,7 @@
offsetof(ngx_google_perftools_conf_t, profiles),
NULL },
- ngx_null_command
+ ngx_null_command
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/os/unix/ngx_files.c
^
|
@@ -620,6 +620,7 @@
{
fm->fd = ngx_open_file(fm->name, NGX_FILE_RDWR, NGX_FILE_TRUNCATE,
NGX_FILE_DEFAULT_ACCESS);
+
if (fm->fd == NGX_INVALID_FILE) {
ngx_log_error(NGX_LOG_CRIT, fm->log, ngx_errno,
ngx_open_file_n " \"%s\" failed", fm->name);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_geo_module.c
^
|
@@ -1326,7 +1326,8 @@
file.name = *name;
file.log = cf->log;
- file.fd = ngx_open_file(name->data, NGX_FILE_RDONLY, 0, 0);
+ file.fd = ngx_open_file(name->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
+
if (file.fd == NGX_INVALID_FILE) {
err = ngx_errno;
if (err != NGX_ENOENT) {
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_geoip_module.c
^
|
@@ -210,7 +210,7 @@
ngx_stream_geoip_city_int_variable,
offsetof(GeoIPRecord, area_code), 0, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_stream_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_realip_module.c
^
|
@@ -89,7 +89,7 @@
{ ngx_string("realip_remote_port"), NULL,
ngx_stream_realip_remote_port_variable, 0, 0, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_stream_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_ssl_module.c
^
|
@@ -249,6 +249,10 @@
(uintptr_t) ngx_ssl_get_raw_certificate,
NGX_STREAM_VAR_CHANGEABLE, 0 },
+ { ngx_string("ssl_client_escaped_cert"), NULL, ngx_stream_ssl_variable,
+ (uintptr_t) ngx_ssl_get_escaped_certificate,
+ NGX_STREAM_VAR_CHANGEABLE, 0 },
+
{ ngx_string("ssl_client_s_dn"), NULL, ngx_stream_ssl_variable,
(uintptr_t) ngx_ssl_get_subject_dn, NGX_STREAM_VAR_CHANGEABLE, 0 },
@@ -273,7 +277,7 @@
{ ngx_string("ssl_client_v_remain"), NULL, ngx_stream_ssl_variable,
(uintptr_t) ngx_ssl_get_client_v_remain, NGX_STREAM_VAR_CHANGEABLE, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_stream_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_ssl_preread_module.c
^
|
@@ -85,7 +85,7 @@
{ ngx_string("ssl_preread_server_name"), NULL,
ngx_stream_ssl_preread_server_name_variable, 0, 0, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_stream_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_upstream.c
^
|
@@ -100,7 +100,7 @@
ngx_stream_upstream_bytes_variable, 1,
NGX_STREAM_VAR_NOCACHEABLE, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_stream_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_upstream_zone_module.c
^
|
@@ -16,6 +16,8 @@
void *data);
static ngx_stream_upstream_rr_peers_t *ngx_stream_upstream_zone_copy_peers(
ngx_slab_pool_t *shpool, ngx_stream_upstream_srv_conf_t *uscf);
+static ngx_stream_upstream_rr_peer_t *ngx_stream_upstream_zone_copy_peer(
+ ngx_stream_upstream_rr_peers_t *peers, ngx_stream_upstream_rr_peer_t *src);
static ngx_command_t ngx_stream_upstream_zone_commands[] = {
@@ -182,6 +184,7 @@
ngx_stream_upstream_zone_copy_peers(ngx_slab_pool_t *shpool,
ngx_stream_upstream_srv_conf_t *uscf)
{
+ ngx_str_t *name;
ngx_stream_upstream_rr_peer_t *peer, **peerp;
ngx_stream_upstream_rr_peers_t *peers, *backup;
@@ -192,18 +195,30 @@
ngx_memcpy(peers, uscf->peer.data, sizeof(ngx_stream_upstream_rr_peers_t));
+ name = ngx_slab_alloc(shpool, sizeof(ngx_str_t));
+ if (name == NULL) {
+ return NULL;
+ }
+
+ name->data = ngx_slab_alloc(shpool, peers->name->len);
+ if (name->data == NULL) {
+ return NULL;
+ }
+
+ ngx_memcpy(name->data, peers->name->data, peers->name->len);
+ name->len = peers->name->len;
+
+ peers->name = name;
+
peers->shpool = shpool;
for (peerp = &peers->peer; *peerp; peerp = &peer->next) {
/* pool is unlocked */
- peer = ngx_slab_calloc_locked(shpool,
- sizeof(ngx_stream_upstream_rr_peer_t));
+ peer = ngx_stream_upstream_zone_copy_peer(peers, *peerp);
if (peer == NULL) {
return NULL;
}
- ngx_memcpy(peer, *peerp, sizeof(ngx_stream_upstream_rr_peer_t));
-
*peerp = peer;
}
@@ -218,18 +233,17 @@
ngx_memcpy(backup, peers->next, sizeof(ngx_stream_upstream_rr_peers_t));
+ backup->name = name;
+
backup->shpool = shpool;
for (peerp = &backup->peer; *peerp; peerp = &peer->next) {
/* pool is unlocked */
- peer = ngx_slab_calloc_locked(shpool,
- sizeof(ngx_stream_upstream_rr_peer_t));
+ peer = ngx_stream_upstream_zone_copy_peer(backup, *peerp);
if (peer == NULL) {
return NULL;
}
- ngx_memcpy(peer, *peerp, sizeof(ngx_stream_upstream_rr_peer_t));
-
*peerp = peer;
}
@@ -241,3 +255,68 @@
return peers;
}
+
+
+static ngx_stream_upstream_rr_peer_t *
+ngx_stream_upstream_zone_copy_peer(ngx_stream_upstream_rr_peers_t *peers,
+ ngx_stream_upstream_rr_peer_t *src)
+{
+ ngx_slab_pool_t *pool;
+ ngx_stream_upstream_rr_peer_t *dst;
+
+ pool = peers->shpool;
+
+ dst = ngx_slab_calloc_locked(pool, sizeof(ngx_stream_upstream_rr_peer_t));
+ if (dst == NULL) {
+ return NULL;
+ }
+
+ if (src) {
+ ngx_memcpy(dst, src, sizeof(ngx_stream_upstream_rr_peer_t));
+ dst->sockaddr = NULL;
+ dst->name.data = NULL;
+ dst->server.data = NULL;
+ }
+
+ dst->sockaddr = ngx_slab_calloc_locked(pool, NGX_SOCKADDRLEN);
+ if (dst->sockaddr == NULL) {
+ goto failed;
+ }
+
+ dst->name.data = ngx_slab_calloc_locked(pool, NGX_SOCKADDR_STRLEN);
+ if (dst->name.data == NULL) {
+ goto failed;
+ }
+
+ if (src) {
+ ngx_memcpy(dst->sockaddr, src->sockaddr, src->socklen);
+ ngx_memcpy(dst->name.data, src->name.data, src->name.len);
+
+ dst->server.data = ngx_slab_alloc_locked(pool, src->server.len);
+ if (dst->server.data == NULL) {
+ goto failed;
+ }
+
+ ngx_memcpy(dst->server.data, src->server.data, src->server.len);
+ }
+
+ return dst;
+
+failed:
+
+ if (dst->server.data) {
+ ngx_slab_free_locked(pool, dst->server.data);
+ }
+
+ if (dst->name.data) {
+ ngx_slab_free_locked(pool, dst->name.data);
+ }
+
+ if (dst->sockaddr) {
+ ngx_slab_free_locked(pool, dst->sockaddr);
+ }
+
+ ngx_slab_free_locked(pool, dst);
+
+ return NULL;
+}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_variables.c
^
|
@@ -111,7 +111,7 @@
{ ngx_string("protocol"), NULL,
ngx_stream_variable_protocol, 0, 0, 0 },
- { ngx_null_string, NULL, NULL, 0, 0, 0 }
+ ngx_stream_null_variable
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.5.tar.gz/src/stream/ngx_stream_variables.h
^
|
@@ -43,6 +43,8 @@
ngx_uint_t index;
};
+#define ngx_stream_null_variable { ngx_null_string, NULL, NULL, 0, 0, 0 }
+
ngx_stream_variable_t *ngx_stream_add_variable(ngx_conf_t *cf, ngx_str_t *name,
ngx_uint_t flags);
|