[-]
[+]
|
Changed |
nginx-1.9.changes
|
|
[-]
[+]
|
Changed |
nginx-1.9.spec
^
|
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/CHANGES
^
|
@@ -1,11 +1,26 @@
+Changes with nginx 1.9.8 08 Dec 2015
+
+ *) Feature: pwritev() support.
+
+ *) Feature: the "include" directive inside the "upstream" block.
+
+ *) Feature: the ngx_http_slice_module.
+
+ *) Bugfix: a segmentation fault might occur in a worker process when
+ using LibreSSL; the bug had appeared in 1.9.6.
+
+ *) Bugfix: nginx could not be built on OS X in some cases.
+
+
Changes with nginx 1.9.7 17 Nov 2015
*) Feature: the "nohostname" parameter of logging to syslog.
*) Feature: the "proxy_cache_convert_head" directive.
- *) Feature: the $realip_remote_addr in the ngx_http_realip_module.
+ *) Feature: the $realip_remote_addr variable in the
+ ngx_http_realip_module.
*) Bugfix: the "expires" directive might not work when using variables.
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/CHANGES.ru
^
|
@@ -1,4 +1,18 @@
+Изменения в nginx 1.9.8 08.12.2015
+
+ *) Добавление: поддержка pwritev().
+
+ *) Добавление: директива include в блоке upstream.
+
+ *) Добавление: модуль ngx_http_slice_module.
+
+ *) Исправление: при использовании LibreSSL в рабочем процессе мог
+ произойти segmentation fault; ошибка появилась в 1.9.6.
+
+ *) Исправление: nginx мог не собираться на OS X.
+
+
Изменения в nginx 1.9.7 17.11.2015
*) Добавление: параметр nohostname логгирования в syslog.
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/auto/lib/openssl/conf
^
|
@@ -105,6 +105,7 @@
if [ $ngx_found = yes ]; then
have=NGX_SSL . auto/have
+ CORE_INCS="$CORE_INCS $ngx_feature_path"
CORE_LIBS="$CORE_LIBS $ngx_feature_libs $NGX_LIBDL"
OPENSSL=YES
fi
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/auto/lib/perl/conf
^
|
@@ -57,7 +57,7 @@
if [ "$NGX_SYSTEM" = "Darwin" ]; then
# OS X system perl wants to link universal binaries
ngx_perl_ldopts=`echo $ngx_perl_ldopts \
- | sed -e 's/-arch x86_64 -arch i386//'`
+ | sed -e 's/-arch i386//' -e 's/-arch x86_64//'`
fi
CORE_LINK="$CORE_LINK $ngx_perl_ldopts"
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/auto/modules
^
|
@@ -73,6 +73,11 @@
fi
+if [ $HTTP_SLICE = YES ]; then
+ HTTP_POSTPONE=YES
+fi
+
+
if [ $HTTP_ADDITION = YES ]; then
HTTP_POSTPONE=YES
fi
@@ -110,6 +115,7 @@
# ngx_http_copy_filter
# ngx_http_range_body_filter
# ngx_http_not_modified_filter
+# ngx_http_slice_filter
HTTP_FILTER_MODULES="$HTTP_WRITE_FILTER_MODULE \
$HTTP_HEADER_FILTER_MODULE \
@@ -179,6 +185,12 @@
HTTP_SRCS="$HTTP_SRCS $HTTP_USERID_SRCS"
fi
+if [ $HTTP_SLICE = YES ]; then
+ HTTP_SRCS="$HTTP_SRCS $HTTP_SLICE_SRCS"
+else
+ HTTP_SLICE_FILTER_MODULE=""
+fi
+
if [ $HTTP_V2 = YES ]; then
have=NGX_HTTP_V2 . auto/have
@@ -461,7 +473,8 @@
$HTTP_AUX_FILTER_MODULES \
$HTTP_COPY_FILTER_MODULE \
$HTTP_RANGE_BODY_FILTER_MODULE \
- $HTTP_NOT_MODIFIED_FILTER_MODULE"
+ $HTTP_NOT_MODIFIED_FILTER_MODULE \
+ $HTTP_SLICE_FILTER_MODULE"
NGX_ADDON_DEPS="$NGX_ADDON_DEPS \$(HTTP_DEPS)"
fi
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/auto/options
^
|
@@ -71,6 +71,7 @@
HTTP_AUTH_BASIC=YES
HTTP_AUTH_REQUEST=NO
HTTP_USERID=YES
+HTTP_SLICE=NO
HTTP_AUTOINDEX=YES
HTTP_RANDOM_INDEX=NO
HTTP_STATUS=NO
@@ -226,6 +227,7 @@
--with-http_random_index_module) HTTP_RANDOM_INDEX=YES ;;
--with-http_secure_link_module) HTTP_SECURE_LINK=YES ;;
--with-http_degradation_module) HTTP_DEGRADATION=YES ;;
+ --with-http_slice_module) HTTP_SLICE=YES ;;
--without-http_charset_module) HTTP_CHARSET=NO ;;
--without-http_gzip_module) HTTP_GZIP=NO ;;
@@ -394,6 +396,7 @@
--with-http_random_index_module enable ngx_http_random_index_module
--with-http_secure_link_module enable ngx_http_secure_link_module
--with-http_degradation_module enable ngx_http_degradation_module
+ --with-http_slice_module enable ngx_http_slice_module
--with-http_stub_status_module enable ngx_http_stub_status_module
--without-http_charset_module disable ngx_http_charset_module
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/auto/sources
^
|
@@ -254,9 +254,6 @@
NGX_WIN32_RC="src/os/win32/nginx.rc"
-# the http modules that have their logging formats
-# must be after ngx_http_log_module
-
HTTP_MODULES="ngx_http_module \
ngx_http_core_module \
ngx_http_log_module \
@@ -363,6 +360,10 @@
HTTP_USERID_SRCS=src/http/modules/ngx_http_userid_filter_module.c
+HTTP_SLICE_FILTER_MODULE=ngx_http_slice_filter_module
+HTTP_SLICE_SRCS=src/http/modules/ngx_http_slice_filter_module.c
+
+
HTTP_REALIP_MODULE=ngx_http_realip_module
HTTP_REALIP_SRCS=src/http/modules/ngx_http_realip_module.c
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/auto/unix
^
|
@@ -589,6 +589,22 @@
. auto/feature
+# pwritev() was introduced in FreeBSD 6 and Linux 2.6.30, glibc 2.10
+
+ngx_feature="pwritev()"
+ngx_feature_name="NGX_HAVE_PWRITEV"
+ngx_feature_run=no
+ngx_feature_incs='#include <sys/uio.h>'
+ngx_feature_path=
+ngx_feature_libs=
+ngx_feature_test="char buf[1]; struct iovec vec[1]; ssize_t n;
+ vec[0].iov_base = buf;
+ vec[0].iov_len = 1;
+ n = pwritev(1, vec, 1, 0);
+ if (n == -1) return 1"
+. auto/feature
+
+
ngx_feature="sys_nerr"
ngx_feature_name="NGX_SYS_NERR"
ngx_feature_run=value
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/core/nginx.h
^
|
@@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_
-#define nginx_version 1009007
-#define NGINX_VERSION "1.9.7"
+#define nginx_version 1009008
+#define NGINX_VERSION "1.9.8"
#define NGINX_VER "nginx/" NGINX_VERSION
#ifdef NGX_BUILD
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/core/ngx_conf_file.h
^
|
@@ -50,7 +50,7 @@
#define NGX_DIRECT_CONF 0x00010000
#define NGX_MAIN_CONF 0x01000000
-#define NGX_ANY_CONF 0x0F000000
+#define NGX_ANY_CONF 0x1F000000
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/core/ngx_string.c
^
|
@@ -410,7 +410,7 @@
hex = 2;
sign = 0;
zero = '0';
- width = NGX_PTR_SIZE * 2;
+ width = 2 * sizeof(void *);
break;
case 'c':
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_chunked_filter_module.c
^
|
@@ -64,7 +64,7 @@
|| r->headers_out.status == NGX_HTTP_NO_CONTENT
|| r->headers_out.status < NGX_HTTP_OK
|| r != r->main
- || (r->method & NGX_HTTP_HEAD))
+ || r->method == NGX_HTTP_HEAD)
{
return ngx_http_next_header_filter(r);
}
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_fastcgi_module.c
^
|
@@ -773,10 +773,11 @@
} else {
u->resolved->host = url.host;
- u->resolved->port = url.port;
- u->resolved->no_port = url.no_port;
}
+ u->resolved->port = url.port;
+ u->resolved->no_port = url.no_port;
+
return NGX_OK;
}
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_proxy_module.c
^
|
@@ -1015,10 +1015,11 @@
} else {
u->resolved->host = url.host;
- u->resolved->port = (in_port_t) (url.no_port ? port : url.port);
- u->resolved->no_port = url.no_port;
}
+ u->resolved->port = (in_port_t) (url.no_port ? port : url.port);
+ u->resolved->no_port = url.no_port;
+
return NGX_OK;
}
@@ -1156,25 +1157,24 @@
if (u->method.len) {
/* HEAD was changed to GET to cache response */
method = u->method;
- method.len++;
} else if (plcf->method.len) {
method = plcf->method;
} else {
method = r->method_name;
- method.len++;
}
ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
- if (method.len == 5
- && ngx_strncasecmp(method.data, (u_char *) "HEAD ", 5) == 0)
+ if (method.len == 4
+ && ngx_strncasecmp(method.data, (u_char *) "HEAD", 4) == 0)
{
ctx->head = 1;
}
- len = method.len + sizeof(ngx_http_proxy_version) - 1 + sizeof(CRLF) - 1;
+ len = method.len + 1 + sizeof(ngx_http_proxy_version) - 1
+ + sizeof(CRLF) - 1;
escape = 0;
loc_len = 0;
@@ -1293,6 +1293,7 @@
/* the request line */
b->last = ngx_copy(b->last, method.data, method.len);
+ *b->last++ = ' ';
u->uri.data = b->last;
@@ -3158,13 +3159,6 @@
ngx_conf_merge_str_value(conf->method, prev->method, "");
- if (conf->method.len
- && conf->method.data[conf->method.len - 1] != ' ')
- {
- conf->method.data[conf->method.len] = ' ';
- conf->method.len++;
- }
-
ngx_conf_merge_value(conf->upstream.pass_request_headers,
prev->upstream.pass_request_headers, 1);
ngx_conf_merge_value(conf->upstream.pass_request_body,
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_range_filter_module.c
^
|
@@ -154,7 +154,7 @@
if (r->http_version < NGX_HTTP_VERSION_10
|| r->headers_out.status != NGX_HTTP_OK
- || r != r->main
+ || (r != r->main && !r->subrequest_ranges)
|| r->headers_out.content_length_n == -1
|| !r->allow_ranges)
{
@@ -222,6 +222,8 @@
return NGX_ERROR;
}
+ ctx->offset = r->headers_out.content_offset;
+
if (ngx_array_init(&ctx->ranges, r->pool, 1, sizeof(ngx_http_range_t))
!= NGX_OK)
{
@@ -273,10 +275,21 @@
ngx_http_range_parse(ngx_http_request_t *r, ngx_http_range_filter_ctx_t *ctx,
ngx_uint_t ranges)
{
- u_char *p;
- off_t start, end, size, content_length, cutoff, cutlim;
- ngx_uint_t suffix;
- ngx_http_range_t *range;
+ u_char *p;
+ off_t start, end, size, content_length, cutoff,
+ cutlim;
+ ngx_uint_t suffix;
+ ngx_http_range_t *range;
+ ngx_http_range_filter_ctx_t *mctx;
+
+ if (r != r->main) {
+ mctx = ngx_http_get_module_ctx(r->main,
+ ngx_http_range_body_filter_module);
+ if (mctx) {
+ ctx->ranges = mctx->ranges;
+ return NGX_OK;
+ }
+ }
p = r->headers_in.range->value.data + 6;
size = 0;
@@ -395,6 +408,10 @@
ngx_table_elt_t *content_range;
ngx_http_range_t *range;
+ if (r != r->main) {
+ return ngx_http_next_header_filter(r);
+ }
+
content_range = ngx_list_push(&r->headers_out.headers);
if (content_range == NULL) {
return NGX_ERROR;
@@ -422,6 +439,7 @@
- content_range->value.data;
r->headers_out.content_length_n = range->end - range->start;
+ r->headers_out.content_offset = range->start;
if (r->headers_out.content_length) {
r->headers_out.content_length->hash = 0;
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_scgi_module.c
^
|
@@ -569,10 +569,11 @@
} else {
u->resolved->host = url.host;
- u->resolved->port = url.port;
- u->resolved->no_port = url.no_port;
}
+ u->resolved->port = url.port;
+ u->resolved->no_port = url.no_port;
+
return NGX_OK;
}
|
[-]
[+]
|
Added |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_slice_filter_module.c
^
|
@@ -0,0 +1,526 @@
+
+/*
+ * Copyright (C) Roman Arutyunyan
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_http.h>
+
+
+typedef struct {
+ size_t size;
+} ngx_http_slice_loc_conf_t;
+
+
+typedef struct {
+ off_t start;
+ off_t end;
+ ngx_str_t range;
+ ngx_str_t etag;
+ ngx_uint_t last; /* unsigned last:1; */
+} ngx_http_slice_ctx_t;
+
+
+typedef struct {
+ off_t start;
+ off_t end;
+ off_t complete_length;
+} ngx_http_slice_content_range_t;
+
+
+static ngx_int_t ngx_http_slice_header_filter(ngx_http_request_t *r);
+static ngx_int_t ngx_http_slice_body_filter(ngx_http_request_t *r,
+ ngx_chain_t *in);
+static ngx_int_t ngx_http_slice_parse_content_range(ngx_http_request_t *r,
+ ngx_http_slice_content_range_t *cr);
+static ngx_int_t ngx_http_slice_range_variable(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
+static off_t ngx_http_slice_get_start(ngx_http_request_t *r);
+static void *ngx_http_slice_create_loc_conf(ngx_conf_t *cf);
+static char *ngx_http_slice_merge_loc_conf(ngx_conf_t *cf, void *parent,
+ void *child);
+static ngx_int_t ngx_http_slice_add_variables(ngx_conf_t *cf);
+static ngx_int_t ngx_http_slice_init(ngx_conf_t *cf);
+
+
+static ngx_command_t ngx_http_slice_filter_commands[] = {
+
+ { ngx_string("slice"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_size_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_slice_loc_conf_t, size),
+ NULL },
+
+ ngx_null_command
+};
+
+
+static ngx_http_module_t ngx_http_slice_filter_module_ctx = {
+ ngx_http_slice_add_variables, /* preconfiguration */
+ ngx_http_slice_init, /* postconfiguration */
+
+ NULL, /* create main configuration */
+ NULL, /* init main configuration */
+
+ NULL, /* create server configuration */
+ NULL, /* merge server configuration */
+
+ ngx_http_slice_create_loc_conf, /* create location configuration */
+ ngx_http_slice_merge_loc_conf /* merge location configuration */
+};
+
+
+ngx_module_t ngx_http_slice_filter_module = {
+ NGX_MODULE_V1,
+ &ngx_http_slice_filter_module_ctx, /* module context */
+ ngx_http_slice_filter_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_str_t ngx_http_slice_range_name = ngx_string("slice_range");
+
+static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
+static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
+
+
+static ngx_int_t
+ngx_http_slice_header_filter(ngx_http_request_t *r)
+{
+ off_t end;
+ ngx_int_t rc;
+ ngx_table_elt_t *h;
+ ngx_http_slice_ctx_t *ctx;
+ ngx_http_slice_loc_conf_t *slcf;
+ ngx_http_slice_content_range_t cr;
+
+ ctx = ngx_http_get_module_ctx(r, ngx_http_slice_filter_module);
+ if (ctx == NULL) {
+ return ngx_http_next_header_filter(r);
+ }
+
+ if (r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT) {
+ if (r == r->main) {
+ ngx_http_set_ctx(r, NULL, ngx_http_slice_filter_module);
+ return ngx_http_next_header_filter(r);
+ }
+
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "unexpected status code %ui in slice response",
+ r->headers_out.status);
+ return NGX_ERROR;
+ }
+
+ h = r->headers_out.etag;
+
+ if (ctx->etag.len) {
+ if (h == NULL
+ || h->value.len != ctx->etag.len
+ || ngx_strncmp(h->value.data, ctx->etag.data, ctx->etag.len)
+ != 0)
+ {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "etag mismatch in slice response");
+ return NGX_ERROR;
+ }
+ }
+
+ if (h) {
+ ctx->etag = h->value;
+ }
+
+ if (ngx_http_slice_parse_content_range(r, &cr) != NGX_OK) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "invalid range in slice response");
+ return NGX_ERROR;
+ }
+
+ if (cr.complete_length == -1) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "no complete length in slice response");
+ return NGX_ERROR;
+ }
+
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http slice response range: %O-%O/%O",
+ cr.start, cr.end, cr.complete_length);
+
+ slcf = ngx_http_get_module_loc_conf(r, ngx_http_slice_filter_module);
+
+ end = ngx_min(cr.start + (off_t) slcf->size, cr.complete_length);
+
+ if (cr.start != ctx->start || cr.end != end) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "unexpected range in slice response: %O-%O",
+ cr.start, cr.end);
+ return NGX_ERROR;
+ }
+
+ ctx->start = end;
+
+ r->headers_out.status = NGX_HTTP_OK;
+ r->headers_out.status_line.len = 0;
+ r->headers_out.content_length_n = cr.complete_length;
+ r->headers_out.content_offset = cr.start;
+ r->headers_out.content_range->hash = 0;
+ r->headers_out.content_range = NULL;
+
+ r->allow_ranges = 1;
+ r->subrequest_ranges = 1;
+ r->single_range = 1;
+
+ rc = ngx_http_next_header_filter(r);
+
+ if (r != r->main) {
+ return rc;
+ }
+
+ 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
+ * (r->headers_out.content_offset / slcf->size);
+ }
+
+ ctx->end = r->headers_out.content_offset
+ + r->headers_out.content_length_n;
+
+ } else {
+ ctx->end = cr.complete_length;
+ }
+
+ return rc;
+}
+
+
+static ngx_int_t
+ngx_http_slice_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
+{
+ ngx_int_t rc;
+ ngx_chain_t *cl;
+ ngx_http_request_t *sr;
+ ngx_http_slice_ctx_t *ctx;
+ ngx_http_slice_loc_conf_t *slcf;
+
+ ctx = ngx_http_get_module_ctx(r, ngx_http_slice_filter_module);
+
+ if (ctx == NULL || r != r->main) {
+ return ngx_http_next_body_filter(r, in);
+ }
+
+ for (cl = in; cl; cl = cl->next) {
+ if (cl->buf->last_buf) {
+ cl->buf->last_buf = 0;
+ cl->buf->last_in_chain = 1;
+ cl->buf->sync = 1;
+ ctx->last = 1;
+ }
+ }
+
+ rc = ngx_http_next_body_filter(r, in);
+
+ if (rc == NGX_ERROR || !ctx->last) {
+ return rc;
+ }
+
+ if (ctx->start >= ctx->end) {
+ ngx_http_set_ctx(r, NULL, ngx_http_slice_filter_module);
+ ngx_http_send_special(r, NGX_HTTP_LAST);
+ return rc;
+ }
+
+ if (r->buffered) {
+ return rc;
+ }
+
+ if (ngx_http_subrequest(r, &r->uri, &r->args, &sr, NULL, 0) != NGX_OK) {
+ return NGX_ERROR;
+ }
+
+ ngx_http_set_ctx(sr, ctx, ngx_http_slice_filter_module);
+
+ slcf = ngx_http_get_module_loc_conf(r, ngx_http_slice_filter_module);
+
+ ctx->range.len = ngx_sprintf(ctx->range.data, "bytes=%O-%O", ctx->start,
+ ctx->start + (off_t) slcf->size - 1)
+ - ctx->range.data;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http slice subrequest: \"%V\"", &ctx->range);
+
+ return rc;
+}
+
+
+static ngx_int_t
+ngx_http_slice_parse_content_range(ngx_http_request_t *r,
+ ngx_http_slice_content_range_t *cr)
+{
+ off_t start, end, complete_length, cutoff, cutlim;
+ u_char *p;
+ ngx_table_elt_t *h;
+
+ h = r->headers_out.content_range;
+
+ if (h == NULL
+ || h->value.len < 7
+ || ngx_strncmp(h->value.data, "bytes ", 6) != 0)
+ {
+ return NGX_ERROR;
+ }
+
+ p = h->value.data + 6;
+
+ cutoff = NGX_MAX_OFF_T_VALUE / 10;
+ cutlim = NGX_MAX_OFF_T_VALUE % 10;
+
+ start = 0;
+ end = 0;
+ complete_length = 0;
+
+ while (*p == ' ') { p++; }
+
+ if (*p < '0' || *p > '9') {
+ return NGX_ERROR;
+ }
+
+ while (*p >= '0' && *p <= '9') {
+ if (start >= cutoff && (start > cutoff || *p - '0' > cutlim)) {
+ return NGX_ERROR;
+ }
+
+ start = start * 10 + *p++ - '0';
+ }
+
+ while (*p == ' ') { p++; }
+
+ if (*p++ != '-') {
+ return NGX_ERROR;
+ }
+
+ while (*p == ' ') { p++; }
+
+ if (*p < '0' || *p > '9') {
+ return NGX_ERROR;
+ }
+
+ while (*p >= '0' && *p <= '9') {
+ if (end >= cutoff && (end > cutoff || *p - '0' > cutlim)) {
+ return NGX_ERROR;
+ }
+
+ end = end * 10 + *p++ - '0';
+ }
+
+ end++;
+
+ while (*p == ' ') { p++; }
+
+ if (*p++ != '/') {
+ return NGX_ERROR;
+ }
+
+ while (*p == ' ') { p++; }
+
+ if (*p != '*') {
+ if (*p < '0' || *p > '9') {
+ return NGX_ERROR;
+ }
+
+ while (*p >= '0' && *p <= '9') {
+ if (complete_length >= cutoff
+ && (complete_length > cutoff || *p - '0' > cutlim))
+ {
+ return NGX_ERROR;
+ }
+
+ complete_length = complete_length * 10 + *p++ - '0';
+ }
+
+ } else {
+ complete_length = -1;
+ p++;
+ }
+
+ while (*p == ' ') { p++; }
+
+ if (*p != '\0') {
+ return NGX_ERROR;
+ }
+
+ cr->start = start;
+ cr->end = end;
+ cr->complete_length = complete_length;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_http_slice_range_variable(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ u_char *p;
+ ngx_http_slice_ctx_t *ctx;
+ ngx_http_slice_loc_conf_t *slcf;
+
+ ctx = ngx_http_get_module_ctx(r, ngx_http_slice_filter_module);
+
+ if (ctx == NULL) {
+ if (r != r->main || r->headers_out.status) {
+ v->not_found = 1;
+ return NGX_OK;
+ }
+
+ slcf = ngx_http_get_module_loc_conf(r, ngx_http_slice_filter_module);
+
+ if (slcf->size == 0) {
+ v->not_found = 1;
+ return NGX_OK;
+ }
+
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_slice_ctx_t));
+ if (ctx == NULL) {
+ return NGX_ERROR;
+ }
+
+ ngx_http_set_ctx(r, ctx, ngx_http_slice_filter_module);
+
+ p = ngx_pnalloc(r->pool, sizeof("bytes=-") - 1 + 2 * NGX_OFF_T_LEN);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ ctx->start = slcf->size * (ngx_http_slice_get_start(r) / slcf->size);
+
+ ctx->range.data = p;
+ ctx->range.len = ngx_sprintf(p, "bytes=%O-%O", ctx->start,
+ ctx->start + (off_t) slcf->size - 1)
+ - p;
+ }
+
+ v->data = ctx->range.data;
+ v->valid = 1;
+ v->not_found = 0;
+ v->no_cacheable = 1;
+ v->len = ctx->range.len;
+
+ return NGX_OK;
+}
+
+
+static off_t
+ngx_http_slice_get_start(ngx_http_request_t *r)
+{
+ off_t start, cutoff, cutlim;
+ u_char *p;
+ ngx_table_elt_t *h;
+
+ if (r->headers_in.if_range) {
+ return 0;
+ }
+
+ h = r->headers_in.range;
+
+ if (h == NULL
+ || h->value.len < 7
+ || ngx_strncasecmp(h->value.data, (u_char *) "bytes=", 6) != 0)
+ {
+ return 0;
+ }
+
+ p = h->value.data + 6;
+
+ if (ngx_strchr(p, ',')) {
+ return 0;
+ }
+
+ while (*p == ' ') { p++; }
+
+ if (*p == '-') {
+ return 0;
+ }
+
+ cutoff = NGX_MAX_OFF_T_VALUE / 10;
+ cutlim = NGX_MAX_OFF_T_VALUE % 10;
+
+ start = 0;
+
+ while (*p >= '0' && *p <= '9') {
+ if (start >= cutoff && (start > cutoff || *p - '0' > cutlim)) {
+ return 0;
+ }
+
+ start = start * 10 + *p++ - '0';
+ }
+
+ return start;
+}
+
+
+static void *
+ngx_http_slice_create_loc_conf(ngx_conf_t *cf)
+{
+ ngx_http_slice_loc_conf_t *slcf;
+
+ slcf = ngx_palloc(cf->pool, sizeof(ngx_http_slice_loc_conf_t));
+ if (slcf == NULL) {
+ return NULL;
+ }
+
+ slcf->size = NGX_CONF_UNSET_SIZE;
+
+ return slcf;
+}
+
+
+static char *
+ngx_http_slice_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
+{
+ ngx_http_slice_loc_conf_t *prev = parent;
+ ngx_http_slice_loc_conf_t *conf = child;
+
+ ngx_conf_merge_size_value(conf->size, prev->size, 0);
+
+ return NGX_CONF_OK;
+}
+
+
+static ngx_int_t
+ngx_http_slice_add_variables(ngx_conf_t *cf)
+{
+ ngx_http_variable_t *var;
+
+ var = ngx_http_add_variable(cf, &ngx_http_slice_range_name, 0);
+ if (var == NULL) {
+ return NGX_ERROR;
+ }
+
+ var->get_handler = ngx_http_slice_range_variable;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_http_slice_init(ngx_conf_t *cf)
+{
+ ngx_http_next_header_filter = ngx_http_top_header_filter;
+ ngx_http_top_header_filter = ngx_http_slice_header_filter;
+
+ ngx_http_next_body_filter = ngx_http_top_body_filter;
+ ngx_http_top_body_filter = ngx_http_slice_body_filter;
+
+ return NGX_OK;
+}
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_static_module.c
^
|
@@ -204,7 +204,7 @@
#endif
- if (r->method & NGX_HTTP_POST) {
+ if (r->method == NGX_HTTP_POST) {
return NGX_HTTP_NOT_ALLOWED;
}
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_stub_status_module.c
^
|
@@ -89,7 +89,7 @@
ngx_chain_t out;
ngx_atomic_int_t ap, hn, ac, rq, rd, wr, wa;
- if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
+ if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
return NGX_HTTP_NOT_ALLOWED;
}
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/modules/ngx_http_uwsgi_module.c
^
|
@@ -771,10 +771,11 @@
} else {
u->resolved->host = url.host;
- u->resolved->port = url.port;
- u->resolved->no_port = url.no_port;
}
+ u->resolved->port = url.port;
+ u->resolved->no_port = url.no_port;
+
return NGX_OK;
}
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/ngx_http_core_module.c
^
|
@@ -776,7 +776,7 @@
};
-ngx_str_t ngx_http_core_get_method = { 3, (u_char *) "GET " };
+ngx_str_t ngx_http_core_get_method = { 3, (u_char *) "GET" };
void
@@ -3503,7 +3503,7 @@
/* TODO: it does not merge, it inits only */
ngx_conf_merge_size_value(conf->connection_pool_size,
- prev->connection_pool_size, 256);
+ prev->connection_pool_size, 64 * sizeof(void *));
ngx_conf_merge_size_value(conf->request_pool_size,
prev->request_pool_size, 4096);
ngx_conf_merge_msec_value(conf->client_header_timeout,
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/ngx_http_request.c
^
|
@@ -837,6 +837,10 @@
c = ngx_ssl_get_connection(ssl_conn);
+ if (c->ssl->renegotiation) {
+ return SSL_TLSEXT_ERR_NOACK;
+ }
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
"SSL server name: \"%s\"", servername);
@@ -1788,7 +1792,7 @@
}
}
- if (r->method & NGX_HTTP_TRACE) {
+ if (r->method == NGX_HTTP_TRACE) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
"client sent TRACE method");
ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED);
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/ngx_http_request.h
^
|
@@ -271,6 +271,7 @@
ngx_array_t cache_control;
off_t content_length_n;
+ off_t content_offset;
time_t date_time;
time_t last_modified_time;
} ngx_http_headers_out_t;
@@ -530,6 +531,7 @@
unsigned filter_need_in_memory:1;
unsigned filter_need_temporary:1;
unsigned allow_ranges:1;
+ unsigned subrequest_ranges:1;
unsigned single_range:1;
unsigned disable_not_modified:1;
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/ngx_http_special_response.c
^
|
@@ -359,9 +359,6 @@
};
-static ngx_str_t ngx_http_get_name = { 3, (u_char *) "GET " };
-
-
ngx_int_t
ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
{
@@ -564,7 +561,7 @@
if (r->method != NGX_HTTP_HEAD) {
r->method = NGX_HTTP_GET;
- r->method_name = ngx_http_get_name;
+ r->method_name = ngx_http_core_get_method;
}
return ngx_http_internal_redirect(r, &uri, &args);
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/ngx_http_upstream.c
^
|
@@ -250,6 +250,11 @@
ngx_http_upstream_copy_allow_ranges,
offsetof(ngx_http_headers_out_t, accept_ranges), 1 },
+ { ngx_string("Content-Range"),
+ ngx_http_upstream_ignore_header_line, 0,
+ ngx_http_upstream_copy_header_line,
+ offsetof(ngx_http_headers_out_t, content_range), 0 },
+
{ ngx_string("Connection"),
ngx_http_upstream_process_connection, 0,
ngx_http_upstream_ignore_header_line, 0, 0 },
@@ -633,8 +638,18 @@
u->ssl_name = u->resolved->host;
#endif
+ host = &u->resolved->host;
+
if (u->resolved->sockaddr) {
+ if (u->resolved->port == 0) {
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "no port in upstream \"%V\"", host);
+ ngx_http_upstream_finalize_request(r, u,
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
if (ngx_http_upstream_create_round_robin_peer(r, u->resolved)
!= NGX_OK)
{
@@ -648,8 +663,6 @@
return;
}
- host = &u->resolved->host;
-
umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
uscfp = umcf->upstreams.elts;
@@ -764,7 +777,7 @@
return rc;
}
- if ((r->method & NGX_HTTP_HEAD) && u->conf->cache_convert_head) {
+ if (r->method == NGX_HTTP_HEAD && u->conf->cache_convert_head) {
u->method = ngx_http_core_get_method;
}
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/http/v2/ngx_http_v2.c
^
|
@@ -3294,9 +3294,6 @@
ngx_memcpy(p, ending, sizeof(ending));
- /* some modules expect the space character after method name */
- r->method_name.data = r->request_line.data;
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http2 http request line: \"%V\"", &r->request_line);
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/os/unix/ngx_files.c
^
|
@@ -14,6 +14,9 @@
static void ngx_thread_read_handler(void *data, ngx_log_t *log);
#endif
+static ssize_t ngx_writev_file(ngx_file_t *file, ngx_array_t *vec, size_t size,
+ off_t offset);
+
#if (NGX_HAVE_FILE_AIO)
@@ -176,7 +179,8 @@
ssize_t
ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
{
- ssize_t n, written;
+ ssize_t n, written;
+ ngx_err_t err;
ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
"write: %d, %p, %uz, %O", file->fd, buf, size, offset);
@@ -189,7 +193,15 @@
n = pwrite(file->fd, buf + written, size, offset);
if (n == -1) {
- ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
+ err = ngx_errno;
+
+ if (err == NGX_EINTR) {
+ ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
+ "pwrite() was interrupted");
+ continue;
+ }
+
+ ngx_log_error(NGX_LOG_CRIT, file->log, err,
"pwrite() \"%s\" failed", file->name.data);
return NGX_ERROR;
}
@@ -221,11 +233,20 @@
n = write(file->fd, buf + written, size);
if (n == -1) {
- ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
+ err = ngx_errno;
+
+ if (err == NGX_EINTR) {
+ ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
+ "write() was interrupted");
+ continue;
+ }
+
+ ngx_log_error(NGX_LOG_CRIT, file->log, err,
"write() \"%s\" failed", file->name.data);
return NGX_ERROR;
}
+ file->sys_offset += n;
file->offset += n;
written += n;
@@ -264,7 +285,6 @@
u_char *prev;
size_t size;
ssize_t total, n;
- ngx_err_t err;
ngx_array_t vec;
struct iovec *iov, iovs[NGX_IOVS];
@@ -326,52 +346,101 @@
return total + n;
}
- if (file->sys_offset != offset) {
- if (lseek(file->fd, offset, SEEK_SET) == -1) {
- ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
- "lseek() \"%s\" failed", file->name.data);
- return NGX_ERROR;
- }
+ n = ngx_writev_file(file, &vec, size, offset);
- file->sys_offset = offset;
+ if (n == NGX_ERROR) {
+ return n;
}
+ offset += n;
+ total += n;
+
+ } while (cl);
+
+ return total;
+}
+
+
+static ssize_t
+ngx_writev_file(ngx_file_t *file, ngx_array_t *vec, size_t size, off_t offset)
+{
+ ssize_t n;
+ ngx_err_t err;
+
+ ngx_log_debug3(NGX_LOG_DEBUG_CORE, file->log, 0,
+ "writev: %d, %uz, %O", file->fd, size, offset);
+
+#if (NGX_HAVE_PWRITEV)
+
eintr:
- n = writev(file->fd, vec.elts, vec.nelts);
+ n = pwritev(file->fd, vec->elts, vec->nelts, offset);
- if (n == -1) {
- err = ngx_errno;
+ if (n == -1) {
+ err = ngx_errno;
- if (err == NGX_EINTR) {
- ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
- "writev() was interrupted");
- goto eintr;
- }
+ if (err == NGX_EINTR) {
+ ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
+ "pwritev() was interrupted");
+ goto eintr;
+ }
- ngx_log_error(NGX_LOG_CRIT, file->log, err,
- "writev() \"%s\" failed", file->name.data);
+ ngx_log_error(NGX_LOG_CRIT, file->log, err,
+ "pwritev() \"%s\" failed", file->name.data);
+ return NGX_ERROR;
+ }
+
+ if ((size_t) n != size) {
+ ngx_log_error(NGX_LOG_CRIT, file->log, 0,
+ "pwritev() \"%s\" has written only %z of %uz",
+ file->name.data, n, size);
+ return NGX_ERROR;
+ }
+
+#else
+
+ if (file->sys_offset != offset) {
+ if (lseek(file->fd, offset, SEEK_SET) == -1) {
+ ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
+ "lseek() \"%s\" failed", file->name.data);
return NGX_ERROR;
}
- if ((size_t) n != size) {
- ngx_log_error(NGX_LOG_CRIT, file->log, 0,
- "writev() \"%s\" has written only %z of %uz",
- file->name.data, n, size);
- return NGX_ERROR;
+ file->sys_offset = offset;
+ }
+
+eintr:
+
+ n = writev(file->fd, vec->elts, vec->nelts);
+
+ if (n == -1) {
+ err = ngx_errno;
+
+ if (err == NGX_EINTR) {
+ ngx_log_debug0(NGX_LOG_DEBUG_CORE, file->log, err,
+ "writev() was interrupted");
+ goto eintr;
}
- ngx_log_debug2(NGX_LOG_DEBUG_CORE, file->log, 0,
- "writev: %d, %z", file->fd, n);
+ ngx_log_error(NGX_LOG_CRIT, file->log, err,
+ "writev() \"%s\" failed", file->name.data);
+ return NGX_ERROR;
+ }
- file->sys_offset += n;
- file->offset += n;
- offset += n;
- total += n;
+ if ((size_t) n != size) {
+ ngx_log_error(NGX_LOG_CRIT, file->log, 0,
+ "writev() \"%s\" has written only %z of %uz",
+ file->name.data, n, size);
+ return NGX_ERROR;
+ }
- } while (cl);
+ file->sys_offset += n;
- return total;
+#endif
+
+ file->offset += n;
+
+ return n;
}
|
[-]
[+]
|
Changed |
nginx-1.9.8.tar.bz2/src/os/unix/ngx_posix_init.c
^
|
@@ -63,7 +63,7 @@
if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
ngx_log_error(NGX_LOG_ALERT, log, errno,
- "getrlimit(RLIMIT_NOFILE) failed)");
+ "getrlimit(RLIMIT_NOFILE) failed");
return NGX_ERROR;
}
|