[-]
[+]
|
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.1.tar.gz</param>
+ <param name="path">/download/nginx-1.13.2.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.2.tar.gz/CHANGES
^
|
@@ -1,4 +1,25 @@
+Changes with nginx 1.13.2 27 Jun 2017
+
+ *) Change: nginx now returns 200 instead of 416 when a range starting
+ with 0 is requested from an empty file.
+
+ *) Feature: the "add_trailer" directive.
+ Thanks to Piotr Sikora.
+
+ *) Bugfix: nginx could not be built on Cygwin and NetBSD; the bug had
+ appeared in 1.13.0.
+
+ *) Bugfix: nginx could not be built under MSYS2 / MinGW 64-bit.
+ Thanks to Orgad Shaneh.
+
+ *) Bugfix: a segmentation fault might occur in a worker process when
+ using SSI with many includes and proxy_pass with variables.
+
+ *) Bugfix: in the ngx_http_v2_module.
+ Thanks to Piotr Sikora.
+
+
Changes with nginx 1.13.1 30 May 2017
*) Feature: now a hostname can be used as the "set_real_ip_from"
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/CHANGES.ru
^
|
@@ -1,4 +1,26 @@
+Изменения в nginx 1.13.2 27.06.2017
+
+ *) Изменение: теперь при запросе диапазона, начинающегося с 0, из
+ пустого файла nginx возвращает ответ 200 вместо 416.
+
+ *) Добавление: директива add_trailer.
+ Спасибо Piotr Sikora.
+
+ *) Исправление: nginx не собирался под Cygwin и NetBSD; ошибка появилась
+ в 1.13.0.
+
+ *) Исправление: nginx не собирался под MSYS2 / MinGW 64-bit.
+ Спасибо Orgad Shaneh.
+
+ *) Исправление: при использовании SSI с большим количеством подзапросов
+ и proxy_pass с переменными в рабочем процессе мог произойти
+ segmentation fault.
+
+ *) Исправление: в модуле ngx_http_v2_module.
+ Спасибо Piotr Sikora.
+
+
Изменения в nginx 1.13.1 30.05.2017
*) Добавление: теперь в качестве параметра директивы set_real_ip_from
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/auto/cc/bcc
^
|
@@ -62,7 +62,6 @@
ngx_objout="-o"
ngx_binout="-e"
ngx_objext="obj"
-ngx_binext=".exe"
ngx_long_start='@&&|
'
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/auto/cc/msvc
^
|
@@ -142,7 +142,6 @@
ngx_objout="-Fo"
ngx_binout="-Fe"
ngx_objext="obj"
-ngx_binext=".exe"
ngx_long_start='@<<
'
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/auto/cc/owc
^
|
@@ -84,7 +84,6 @@
ngx_objout="-fo"
ngx_binout="-fe="
ngx_objext="obj"
-ngx_binext=".exe"
ngx_regex_dirsep='\\'
ngx_dirsep="\\"
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/auto/os/conf
^
|
@@ -41,6 +41,14 @@
'
;;
+ NetBSD:*)
+ CORE_INCS="$UNIX_INCS"
+ CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
+ CORE_SRCS="$UNIX_SRCS"
+
+ NGX_RPATH=YES
+ ;;
+
HP-UX:*)
# HP/UX
have=NGX_HPUX . auto/have_headers
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/auto/os/win32
^
|
@@ -13,6 +13,7 @@
SELECT_SRCS=$WIN32_SELECT_SRCS
ngx_pic_opt=
+ngx_binext=".exe"
case "$NGX_CC_NAME" in
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/auto/unix
^
|
@@ -428,7 +428,10 @@
#include <netinet/in.h>"
ngx_feature_path=
ngx_feature_libs=
-ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_PKTINFO, NULL, 0)"
+ngx_feature_test="struct in_pktinfo pkt;
+ pkt.ipi_spec_dst.s_addr = INADDR_ANY;
+ (void) pkt;
+ setsockopt(0, IPPROTO_IP, IP_PKTINFO, NULL, 0)"
. auto/feature
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/configure
^
|
@@ -36,7 +36,7 @@
NGX_PLATFORM="$NGX_SYSTEM:$NGX_RELEASE:$NGX_MACHINE";
case "$NGX_SYSTEM" in
- MINGW32_*)
+ MINGW32_* | MINGW64_* | MSYS_*)
NGX_PLATFORM=win32
;;
esac
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/core/nginx.h
^
|
@@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_
-#define nginx_version 1013001
-#define NGINX_VERSION "1.13.1"
+#define nginx_version 1013002
+#define NGINX_VERSION "1.13.2"
#define NGINX_VER "nginx/" NGINX_VERSION
#ifdef NGX_BUILD
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/core/ngx_cycle.c
^
|
@@ -1124,9 +1124,7 @@
if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) {
ngx_file_info_t fi;
- if (ngx_file_info((const char *) file[i].name.data, &fi)
- == NGX_FILE_ERROR)
- {
+ if (ngx_file_info(file[i].name.data, &fi) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
ngx_file_info_n " \"%s\" failed",
file[i].name.data);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/core/ngx_file.c
^
|
@@ -622,9 +622,7 @@
{
ngx_file_info_t fi;
- if (ngx_file_info((const char *) path[i]->name.data, &fi)
- == NGX_FILE_ERROR)
- {
+ if (ngx_file_info(path[i]->name.data, &fi) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
ngx_file_info_n " \"%s\" failed", path[i]->name.data);
return NGX_ERROR;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/core/ngx_resolver.c
^
|
@@ -443,7 +443,7 @@
name.data = ngx_resolver_alloc(r, name.len);
if (name.data == NULL) {
- return NGX_ERROR;
+ goto failed;
}
if (slen == ctx->service.len) {
@@ -481,6 +481,8 @@
ngx_resolver_free(r, ctx->event);
}
+failed:
+
ngx_resolver_free(r, ctx);
return NGX_ERROR;
@@ -744,6 +746,7 @@
last->next = rn->waiting;
rn->waiting = ctx;
ctx->state = NGX_AGAIN;
+ ctx->async = 1;
do {
ctx->node = rn;
@@ -890,6 +893,7 @@
rn->waiting = ctx;
ctx->state = NGX_AGAIN;
+ ctx->async = 1;
do {
ctx->node = rn;
@@ -1021,6 +1025,7 @@
ctx->next = rn->waiting;
rn->waiting = ctx;
ctx->state = NGX_AGAIN;
+ ctx->async = 1;
ctx->node = rn;
/* unlock addr mutex */
@@ -1117,6 +1122,7 @@
/* unlock addr mutex */
ctx->state = NGX_AGAIN;
+ ctx->async = 1;
ctx->node = rn;
return NGX_OK;
@@ -3017,6 +3023,7 @@
srv = cctx->srvs;
ctx->count--;
+ ctx->async |= cctx->async;
srv->ctx = NULL;
srv->state = cctx->state;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/core/ngx_resolver.h
^
|
@@ -218,7 +218,8 @@
void *data;
ngx_msec_t timeout;
- ngx_uint_t quick; /* unsigned quick:1; */
+ unsigned quick:1;
+ unsigned async:1;
ngx_uint_t recursion;
ngx_event_t *event;
};
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/core/ngx_rwlock.c
^
|
@@ -94,7 +94,7 @@
readers = *lock;
if (readers == NGX_RWLOCK_WLOCK) {
- *lock = 0;
+ (void) ngx_atomic_cmp_set(lock, NGX_RWLOCK_WLOCK, 0);
return;
}
@@ -108,6 +108,15 @@
}
}
+
+void
+ngx_rwlock_downgrade(ngx_atomic_t *lock)
+{
+ if (*lock == NGX_RWLOCK_WLOCK) {
+ *lock = 1;
+ }
+}
+
#else
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/core/ngx_rwlock.h
^
|
@@ -16,6 +16,7 @@
void ngx_rwlock_wlock(ngx_atomic_t *lock);
void ngx_rwlock_rlock(ngx_atomic_t *lock);
void ngx_rwlock_unlock(ngx_atomic_t *lock);
+void ngx_rwlock_downgrade(ngx_atomic_t *lock);
#endif /* _NGX_RWLOCK_H_INCLUDED_ */
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/modules/ngx_http_chunked_filter_module.c
^
|
@@ -17,6 +17,8 @@
static ngx_int_t ngx_http_chunked_filter_init(ngx_conf_t *cf);
+static ngx_chain_t *ngx_http_chunked_create_trailers(ngx_http_request_t *r,
+ ngx_http_chunked_filter_ctx_t *ctx);
static ngx_http_module_t ngx_http_chunked_filter_module_ctx = {
@@ -69,27 +71,29 @@
return ngx_http_next_header_filter(r);
}
- if (r->headers_out.content_length_n == -1) {
- if (r->http_version < NGX_HTTP_VERSION_11) {
- r->keepalive = 0;
+ if (r->headers_out.content_length_n == -1
+ || r->expect_trailers)
+ {
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
- } else {
- clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+ if (r->http_version >= NGX_HTTP_VERSION_11
+ && clcf->chunked_transfer_encoding)
+ {
+ if (r->expect_trailers) {
+ ngx_http_clear_content_length(r);
+ }
- if (clcf->chunked_transfer_encoding) {
- r->chunked = 1;
+ r->chunked = 1;
- ctx = ngx_pcalloc(r->pool,
- sizeof(ngx_http_chunked_filter_ctx_t));
- if (ctx == NULL) {
- return NGX_ERROR;
- }
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_chunked_filter_ctx_t));
+ if (ctx == NULL) {
+ return NGX_ERROR;
+ }
- ngx_http_set_ctx(r, ctx, ngx_http_chunked_filter_module);
+ ngx_http_set_ctx(r, ctx, ngx_http_chunked_filter_module);
- } else {
- r->keepalive = 0;
- }
+ } else if (r->headers_out.content_length_n == -1) {
+ r->keepalive = 0;
}
}
@@ -179,26 +183,17 @@
}
if (cl->buf->last_buf) {
- tl = ngx_chain_get_free_buf(r->pool, &ctx->free);
+ tl = ngx_http_chunked_create_trailers(r, ctx);
if (tl == NULL) {
return NGX_ERROR;
}
- b = tl->buf;
-
- b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module;
- b->temporary = 0;
- b->memory = 1;
- b->last_buf = 1;
- b->pos = (u_char *) CRLF "0" CRLF CRLF;
- b->last = b->pos + 7;
-
cl->buf->last_buf = 0;
*ll = tl;
if (size == 0) {
- b->pos += 2;
+ tl->buf->pos += 2;
}
} else if (size > 0) {
@@ -230,6 +225,109 @@
}
+static ngx_chain_t *
+ngx_http_chunked_create_trailers(ngx_http_request_t *r,
+ ngx_http_chunked_filter_ctx_t *ctx)
+{
+ size_t len;
+ ngx_buf_t *b;
+ ngx_uint_t i;
+ ngx_chain_t *cl;
+ ngx_list_part_t *part;
+ ngx_table_elt_t *header;
+
+ len = 0;
+
+ part = &r->headers_out.trailers.part;
+ header = part->elts;
+
+ for (i = 0; /* void */; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+
+ part = part->next;
+ header = part->elts;
+ i = 0;
+ }
+
+ if (header[i].hash == 0) {
+ continue;
+ }
+
+ len += header[i].key.len + sizeof(": ") - 1
+ + header[i].value.len + sizeof(CRLF) - 1;
+ }
+
+ cl = ngx_chain_get_free_buf(r->pool, &ctx->free);
+ if (cl == NULL) {
+ return NULL;
+ }
+
+ b = cl->buf;
+
+ b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module;
+ b->temporary = 0;
+ b->memory = 1;
+ b->last_buf = 1;
+
+ if (len == 0) {
+ b->pos = (u_char *) CRLF "0" CRLF CRLF;
+ b->last = b->pos + sizeof(CRLF "0" CRLF CRLF) - 1;
+ return cl;
+ }
+
+ len += sizeof(CRLF "0" CRLF CRLF) - 1;
+
+ b->pos = ngx_palloc(r->pool, len);
+ if (b->pos == NULL) {
+ return NULL;
+ }
+
+ b->last = b->pos;
+
+ *b->last++ = CR; *b->last++ = LF;
+ *b->last++ = '0';
+ *b->last++ = CR; *b->last++ = LF;
+
+ part = &r->headers_out.trailers.part;
+ header = part->elts;
+
+ for (i = 0; /* void */; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+
+ part = part->next;
+ header = part->elts;
+ i = 0;
+ }
+
+ if (header[i].hash == 0) {
+ continue;
+ }
+
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http trailer: \"%V: %V\"",
+ &header[i].key, &header[i].value);
+
+ b->last = ngx_copy(b->last, header[i].key.data, header[i].key.len);
+ *b->last++ = ':'; *b->last++ = ' ';
+
+ b->last = ngx_copy(b->last, header[i].value.data, header[i].value.len);
+ *b->last++ = CR; *b->last++ = LF;
+ }
+
+ *b->last++ = CR; *b->last++ = LF;
+
+ return cl;
+}
+
+
static ngx_int_t
ngx_http_chunked_filter_init(ngx_conf_t *cf)
{
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/modules/ngx_http_gzip_filter_module.c
^
|
@@ -1084,10 +1084,6 @@
ngx_uint_t zint, zfrac;
ngx_http_gzip_ctx_t *ctx;
- v->valid = 1;
- v->no_cacheable = 0;
- v->not_found = 0;
-
ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module);
if (ctx == NULL || ctx->zout == 0) {
@@ -1095,6 +1091,10 @@
return NGX_OK;
}
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+
v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN + 3);
if (v->data == NULL) {
return NGX_ERROR;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/modules/ngx_http_range_filter_module.c
^
|
@@ -382,6 +382,9 @@
if (ranges-- == 0) {
return NGX_DECLINED;
}
+
+ } else if (start == 0) {
+ return NGX_DECLINED;
}
if (*p++ != ',') {
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/modules/ngx_http_ssi_filter_module.c
^
|
@@ -2388,7 +2388,7 @@
ctx->timefmt.len = value->len;
ctx->timefmt.data = ngx_pnalloc(r->pool, value->len + 1);
if (ctx->timefmt.data == NULL) {
- return NGX_HTTP_SSI_ERROR;
+ return NGX_ERROR;
}
ngx_cpystrn(ctx->timefmt.data, value->data, value->len + 1);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/modules/ngx_http_userid_filter_module.c
^
|
@@ -472,6 +472,10 @@
vv = ngx_http_get_indexed_variable(r, ngx_http_userid_reset_index);
+ if (vv == NULL || vv->not_found) {
+ return NGX_ERROR;
+ }
+
if (vv->len == 0 || (vv->len == 1 && vv->data[0] == '0')) {
if (conf->mark == '\0'
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/ngx_http_core_module.c
^
|
@@ -1353,6 +1353,7 @@
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;
}
@@ -2481,6 +2482,13 @@
sizeof(ngx_table_elt_t))
!= NGX_OK)
{
+ return NGX_ERROR;
+ }
+
+ if (ngx_list_init(&sr->headers_out.trailers, r->pool, 4,
+ sizeof(ngx_table_elt_t))
+ != NGX_OK)
+ {
return NGX_ERROR;
}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/ngx_http_request.c
^
|
@@ -562,6 +562,14 @@
return NULL;
}
+ if (ngx_list_init(&r->headers_out.trailers, r->pool, 4,
+ sizeof(ngx_table_elt_t))
+ != NGX_OK)
+ {
+ ngx_destroy_pool(r->pool);
+ return NULL;
+ }
+
r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
if (r->ctx == NULL) {
ngx_destroy_pool(r->pool);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/ngx_http_request.h
^
|
@@ -252,6 +252,7 @@
typedef struct {
ngx_list_t headers;
+ ngx_list_t trailers;
ngx_uint_t status;
ngx_str_t status_line;
@@ -514,6 +515,7 @@
unsigned pipeline:1;
unsigned chunked:1;
unsigned header_only:1;
+ unsigned expect_trailers:1;
unsigned keepalive:1;
unsigned lingering_close:1;
unsigned discard_body:1;
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/ngx_http_upstream.c
^
|
@@ -182,7 +182,9 @@
#if (NGX_HTTP_SSL)
static void ngx_http_upstream_ssl_init_connection(ngx_http_request_t *,
ngx_http_upstream_t *u, ngx_connection_t *c);
-static void ngx_http_upstream_ssl_handshake(ngx_connection_t *c);
+static void ngx_http_upstream_ssl_handshake_handler(ngx_connection_t *c);
+static void ngx_http_upstream_ssl_handshake(ngx_http_request_t *,
+ ngx_http_upstream_t *u, ngx_connection_t *c);
static ngx_int_t ngx_http_upstream_ssl_name(ngx_http_request_t *r,
ngx_http_upstream_t *u, ngx_connection_t *c);
#endif
@@ -1143,11 +1145,14 @@
static void
ngx_http_upstream_resolve_handler(ngx_resolver_ctx_t *ctx)
{
+ ngx_uint_t run_posted;
ngx_connection_t *c;
ngx_http_request_t *r;
ngx_http_upstream_t *u;
ngx_http_upstream_resolved_t *ur;
+ run_posted = ctx->async;
+
r = ctx->data;
c = r->connection;
@@ -1211,7 +1216,9 @@
failed:
- ngx_http_run_posted_requests(c);
+ if (run_posted) {
+ ngx_http_run_posted_requests(c);
+ }
}
@@ -1662,26 +1669,43 @@
ngx_add_timer(c->write, u->conf->connect_timeout);
}
- c->ssl->handler = ngx_http_upstream_ssl_handshake;
+ c->ssl->handler = ngx_http_upstream_ssl_handshake_handler;
return;
}
- ngx_http_upstream_ssl_handshake(c);
+ ngx_http_upstream_ssl_handshake(r, u, c);
}
static void
-ngx_http_upstream_ssl_handshake(ngx_connection_t *c)
+ngx_http_upstream_ssl_handshake_handler(ngx_connection_t *c)
{
- long rc;
ngx_http_request_t *r;
ngx_http_upstream_t *u;
r = c->data;
+
u = r->upstream;
+ c = r->connection;
ngx_http_set_log_request(c->log, r);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http upstream ssl handshake: \"%V?%V\"",
+ &r->uri, &r->args);
+
+ ngx_http_upstream_ssl_handshake(r, u, u->peer.connection);
+
+ ngx_http_run_posted_requests(c);
+}
+
+
+static void
+ngx_http_upstream_ssl_handshake(ngx_http_request_t *r, ngx_http_upstream_t *u,
+ ngx_connection_t *c)
+{
+ long rc;
+
if (c->ssl->handshaked) {
if (u->conf->ssl_verify) {
@@ -1709,28 +1733,19 @@
c->write->handler = ngx_http_upstream_handler;
c->read->handler = ngx_http_upstream_handler;
- c = r->connection;
-
ngx_http_upstream_send_request(r, u, 1);
- ngx_http_run_posted_requests(c);
return;
}
if (c->write->timedout) {
- c = r->connection;
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_TIMEOUT);
- ngx_http_run_posted_requests(c);
return;
}
failed:
- c = r->connection;
-
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
-
- ngx_http_run_posted_requests(c);
}
@@ -2729,7 +2744,7 @@
rev = c->read;
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
- "http upstream process body on memory");
+ "http upstream process body in memory");
if (rev->timedout) {
ngx_connection_error(c, NGX_ETIMEDOUT, "upstream timed out");
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/ngx_http_variables.c
^
|
@@ -38,6 +38,8 @@
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_unknown_header_out(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_unknown_trailer_out(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_line(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_cookie(ngx_http_request_t *r,
@@ -365,6 +367,9 @@
{ ngx_string("sent_http_"), NULL, ngx_http_variable_unknown_header_out,
0, NGX_HTTP_VAR_PREFIX, 0 },
+ { ngx_string("sent_trailer_"), NULL, ngx_http_variable_unknown_trailer_out,
+ 0, NGX_HTTP_VAR_PREFIX, 0 },
+
{ ngx_string("cookie_"), NULL, ngx_http_variable_cookie,
0, NGX_HTTP_VAR_PREFIX, 0 },
@@ -934,6 +939,16 @@
}
+static ngx_int_t
+ngx_http_variable_unknown_trailer_out(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ return ngx_http_variable_unknown_header(v, (ngx_str_t *) data,
+ &r->headers_out.trailers.part,
+ sizeof("sent_trailer_") - 1);
+}
+
+
ngx_int_t
ngx_http_variable_unknown_header(ngx_http_variable_value_t *v, ngx_str_t *var,
ngx_list_part_t *part, size_t prefix)
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/v2/ngx_http_v2.c
^
|
@@ -28,6 +28,7 @@
#define NGX_HTTP_V2_HTTP_1_1_REQUIRED 0xd
/* frame sizes */
+#define NGX_HTTP_V2_SETTINGS_ACK_SIZE 0
#define NGX_HTTP_V2_RST_STREAM_SIZE 4
#define NGX_HTTP_V2_PRIORITY_SIZE 5
#define NGX_HTTP_V2_PING_SIZE 8
@@ -128,8 +129,7 @@
#define ngx_http_v2_index_size(h2scf) (h2scf->streams_index_mask + 1)
#define ngx_http_v2_index(h2scf, sid) ((sid >> 1) & h2scf->streams_index_mask)
-static ngx_int_t ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c,
- ngx_uint_t ack);
+static ngx_int_t ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c);
static ngx_int_t ngx_http_v2_settings_frame_handler(
ngx_http_v2_connection_t *h2c, ngx_http_v2_out_frame_t *frame);
static ngx_int_t ngx_http_v2_send_window_update(ngx_http_v2_connection_t *h2c,
@@ -269,7 +269,7 @@
return;
}
- if (ngx_http_v2_send_settings(h2c, 0) == NGX_ERROR) {
+ if (ngx_http_v2_send_settings(h2c) == NGX_ERROR) {
ngx_http_close_connection(c);
return;
}
@@ -1568,6 +1568,10 @@
rc = ngx_http_v2_pseudo_header(r, header);
if (rc == NGX_OK) {
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http2 pseudo-header: \":%V: %V\"",
+ &header->name, &header->value);
+
return ngx_http_v2_state_header_complete(h2c, pos, end);
}
@@ -1609,36 +1613,40 @@
NGX_HTTP_V2_INTERNAL_ERROR);
}
- return ngx_http_v2_state_header_complete(h2c, pos, end);
- }
-
- h = ngx_list_push(&r->headers_in.headers);
- if (h == NULL) {
- return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
- }
+ } else {
+ h = ngx_list_push(&r->headers_in.headers);
+ if (h == NULL) {
+ return ngx_http_v2_connection_error(h2c,
+ NGX_HTTP_V2_INTERNAL_ERROR);
+ }
- h->key.len = header->name.len;
- h->key.data = header->name.data;
+ h->key.len = header->name.len;
+ h->key.data = header->name.data;
- /* TODO Optimization: precalculate hash and handler for indexed headers. */
- h->hash = ngx_hash_key(h->key.data, h->key.len);
+ /*
+ * TODO Optimization: precalculate hash
+ * and handler for indexed headers.
+ */
+ h->hash = ngx_hash_key(h->key.data, h->key.len);
- h->value.len = header->value.len;
- h->value.data = header->value.data;
+ h->value.len = header->value.len;
+ h->value.data = header->value.data;
- h->lowcase_key = h->key.data;
+ h->lowcase_key = h->key.data;
- cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
+ cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
- hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash,
- h->lowcase_key, h->key.len);
+ hh = ngx_hash_find(&cmcf->headers_in_hash, h->hash,
+ h->lowcase_key, h->key.len);
- if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
- goto error;
+ if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
+ goto error;
+ }
}
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "http2 http header: \"%V: %V\"", &h->key, &h->value);
+ "http2 http header: \"%V: %V\"",
+ &header->name, &header->value);
return ngx_http_v2_state_header_complete(h2c, pos, end);
@@ -1951,8 +1959,6 @@
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR);
}
- ngx_http_v2_send_settings(h2c, 1);
-
return ngx_http_v2_state_settings_params(h2c, pos, end);
}
@@ -1961,7 +1967,11 @@
ngx_http_v2_state_settings_params(ngx_http_v2_connection_t *h2c, u_char *pos,
u_char *end)
{
- ngx_uint_t id, value;
+ ssize_t window_delta;
+ ngx_uint_t id, value;
+ ngx_http_v2_out_frame_t *frame;
+
+ window_delta = 0;
while (h2c->state.length) {
if (end - pos < NGX_HTTP_V2_SETTINGS_PARAM_SIZE) {
@@ -1987,12 +1997,7 @@
NGX_HTTP_V2_FLOW_CTRL_ERROR);
}
- if (ngx_http_v2_adjust_windows(h2c, value - h2c->init_window)
- != NGX_OK)
- {
- return ngx_http_v2_connection_error(h2c,
- NGX_HTTP_V2_INTERNAL_ERROR);
- }
+ window_delta = value - h2c->init_window;
h2c->init_window = value;
break;
@@ -2020,6 +2025,22 @@
pos += NGX_HTTP_V2_SETTINGS_PARAM_SIZE;
}
+ frame = ngx_http_v2_get_frame(h2c, NGX_HTTP_V2_SETTINGS_ACK_SIZE,
+ NGX_HTTP_V2_SETTINGS_FRAME,
+ NGX_HTTP_V2_ACK_FLAG, 0);
+ if (frame == NULL) {
+ return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
+ }
+
+ ngx_http_v2_queue_ordered_frame(h2c, frame);
+
+ if (window_delta) {
+ if (ngx_http_v2_adjust_windows(h2c, window_delta) != NGX_OK) {
+ return ngx_http_v2_connection_error(h2c,
+ NGX_HTTP_V2_INTERNAL_ERROR);
+ }
+ }
+
return ngx_http_v2_state_complete(h2c, pos, end);
}
@@ -2463,7 +2484,7 @@
static ngx_int_t
-ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c, ngx_uint_t ack)
+ngx_http_v2_send_settings(ngx_http_v2_connection_t *h2c)
{
size_t len;
ngx_buf_t *buf;
@@ -2471,8 +2492,8 @@
ngx_http_v2_srv_conf_t *h2scf;
ngx_http_v2_out_frame_t *frame;
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
- "http2 send SETTINGS frame ack:%ui", ack);
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
+ "http2 send SETTINGS frame");
frame = ngx_palloc(h2c->pool, sizeof(ngx_http_v2_out_frame_t));
if (frame == NULL) {
@@ -2484,7 +2505,7 @@
return NGX_ERROR;
}
- len = ack ? 0 : (sizeof(uint16_t) + sizeof(uint32_t)) * 3;
+ len = NGX_HTTP_V2_SETTINGS_PARAM_SIZE * 3;
buf = ngx_create_temp_buf(h2c->pool, NGX_HTTP_V2_FRAME_HEADER_SIZE + len);
if (buf == NULL) {
@@ -2508,28 +2529,26 @@
buf->last = ngx_http_v2_write_len_and_type(buf->last, len,
NGX_HTTP_V2_SETTINGS_FRAME);
- *buf->last++ = ack ? NGX_HTTP_V2_ACK_FLAG : NGX_HTTP_V2_NO_FLAG;
+ *buf->last++ = NGX_HTTP_V2_NO_FLAG;
buf->last = ngx_http_v2_write_sid(buf->last, 0);
- if (!ack) {
- h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
- ngx_http_v2_module);
-
- buf->last = ngx_http_v2_write_uint16(buf->last,
- NGX_HTTP_V2_MAX_STREAMS_SETTING);
- buf->last = ngx_http_v2_write_uint32(buf->last,
- h2scf->concurrent_streams);
+ h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
+ ngx_http_v2_module);
- buf->last = ngx_http_v2_write_uint16(buf->last,
+ buf->last = ngx_http_v2_write_uint16(buf->last,
+ NGX_HTTP_V2_MAX_STREAMS_SETTING);
+ buf->last = ngx_http_v2_write_uint32(buf->last,
+ h2scf->concurrent_streams);
+
+ buf->last = ngx_http_v2_write_uint16(buf->last,
NGX_HTTP_V2_INIT_WINDOW_SIZE_SETTING);
- buf->last = ngx_http_v2_write_uint32(buf->last, h2scf->preread_size);
+ buf->last = ngx_http_v2_write_uint32(buf->last, h2scf->preread_size);
- buf->last = ngx_http_v2_write_uint16(buf->last,
- NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING);
- buf->last = ngx_http_v2_write_uint32(buf->last,
- NGX_HTTP_V2_MAX_FRAME_SIZE);
- }
+ buf->last = ngx_http_v2_write_uint16(buf->last,
+ NGX_HTTP_V2_MAX_FRAME_SIZE_SETTING);
+ buf->last = ngx_http_v2_write_uint32(buf->last,
+ NGX_HTTP_V2_MAX_FRAME_SIZE);
ngx_http_v2_queue_blocked_frame(h2c, frame);
@@ -3313,6 +3332,7 @@
static const u_char ending[] = " HTTP/2.0";
if (r->method_name.len == 0
+ || r->schema_start == NULL
|| r->unparsed_uri.len == 0)
{
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/v2/ngx_http_v2.h
^
|
@@ -261,6 +261,15 @@
}
+static ngx_inline void
+ngx_http_v2_queue_ordered_frame(ngx_http_v2_connection_t *h2c,
+ ngx_http_v2_out_frame_t *frame)
+{
+ frame->next = h2c->last_out;
+ h2c->last_out = frame;
+}
+
+
void ngx_http_v2_init(ngx_event_t *rev);
void ngx_http_v2_request_headers_init(void);
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/http/v2/ngx_http_v2_filter_module.c
^
|
@@ -50,13 +50,17 @@
#define NGX_HTTP_V2_SERVER_INDEX 54
#define NGX_HTTP_V2_VARY_INDEX 59
+#define NGX_HTTP_V2_NO_TRAILERS (ngx_http_v2_out_frame_t *) -1
+
static u_char *ngx_http_v2_string_encode(u_char *dst, u_char *src, size_t len,
u_char *tmp, ngx_uint_t lower);
static u_char *ngx_http_v2_write_int(u_char *pos, ngx_uint_t prefix,
ngx_uint_t value);
static ngx_http_v2_out_frame_t *ngx_http_v2_create_headers_frame(
- ngx_http_request_t *r, u_char *pos, u_char *end);
+ ngx_http_request_t *r, u_char *pos, u_char *end, ngx_uint_t fin);
+static ngx_http_v2_out_frame_t *ngx_http_v2_create_trailers_frame(
+ ngx_http_request_t *r);
static ngx_chain_t *ngx_http_v2_send_chain(ngx_connection_t *fc,
ngx_chain_t *in, off_t limit);
@@ -612,7 +616,7 @@
header[i].value.len, tmp);
}
- frame = ngx_http_v2_create_headers_frame(r, start, pos);
+ frame = ngx_http_v2_create_headers_frame(r, start, pos, r->header_only);
if (frame == NULL) {
return NGX_ERROR;
}
@@ -636,6 +640,118 @@
}
+static ngx_http_v2_out_frame_t *
+ngx_http_v2_create_trailers_frame(ngx_http_request_t *r)
+{
+ u_char *pos, *start, *tmp;
+ size_t len, tmp_len;
+ ngx_uint_t i;
+ ngx_list_part_t *part;
+ ngx_table_elt_t *header;
+
+ len = 0;
+ tmp_len = 0;
+
+ part = &r->headers_out.trailers.part;
+ header = part->elts;
+
+ for (i = 0; /* void */; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+
+ part = part->next;
+ header = part->elts;
+ i = 0;
+ }
+
+ if (header[i].hash == 0) {
+ continue;
+ }
+
+ if (header[i].key.len > NGX_HTTP_V2_MAX_FIELD) {
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
+ "too long response trailer name: \"%V\"",
+ &header[i].key);
+ return NULL;
+ }
+
+ if (header[i].value.len > NGX_HTTP_V2_MAX_FIELD) {
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
+ "too long response trailer value: \"%V: %V\"",
+ &header[i].key, &header[i].value);
+ return NULL;
+ }
+
+ len += 1 + NGX_HTTP_V2_INT_OCTETS + header[i].key.len
+ + NGX_HTTP_V2_INT_OCTETS + header[i].value.len;
+
+ if (header[i].key.len > tmp_len) {
+ tmp_len = header[i].key.len;
+ }
+
+ if (header[i].value.len > tmp_len) {
+ tmp_len = header[i].value.len;
+ }
+ }
+
+ if (len == 0) {
+ return NGX_HTTP_V2_NO_TRAILERS;
+ }
+
+ tmp = ngx_palloc(r->pool, tmp_len);
+ pos = ngx_pnalloc(r->pool, len);
+
+ if (pos == NULL || tmp == NULL) {
+ return NULL;
+ }
+
+ start = pos;
+
+ part = &r->headers_out.trailers.part;
+ header = part->elts;
+
+ for (i = 0; /* void */; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+
+ part = part->next;
+ header = part->elts;
+ i = 0;
+ }
+
+ if (header[i].hash == 0) {
+ continue;
+ }
+
+#if (NGX_DEBUG)
+ if (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP) {
+ ngx_strlow(tmp, header[i].key.data, header[i].key.len);
+
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http2 output trailer: \"%*s: %V\"",
+ header[i].key.len, tmp, &header[i].value);
+ }
+#endif
+
+ *pos++ = 0;
+
+ pos = ngx_http_v2_write_name(pos, header[i].key.data,
+ header[i].key.len, tmp);
+
+ pos = ngx_http_v2_write_value(pos, header[i].value.data,
+ header[i].value.len, tmp);
+ }
+
+ return ngx_http_v2_create_headers_frame(r, start, pos, 1);
+}
+
+
static u_char *
ngx_http_v2_string_encode(u_char *dst, u_char *src, size_t len, u_char *tmp,
ngx_uint_t lower)
@@ -686,7 +802,7 @@
static ngx_http_v2_out_frame_t *
ngx_http_v2_create_headers_frame(ngx_http_request_t *r, u_char *pos,
- u_char *end)
+ u_char *end, ngx_uint_t fin)
{
u_char type, flags;
size_t rest, frame_size;
@@ -707,12 +823,12 @@
frame->stream = stream;
frame->length = rest;
frame->blocked = 1;
- frame->fin = r->header_only;
+ frame->fin = fin;
ll = &frame->first;
type = NGX_HTTP_V2_HEADERS_FRAME;
- flags = r->header_only ? NGX_HTTP_V2_END_STREAM_FLAG : NGX_HTTP_V2_NO_FLAG;
+ flags = fin ? NGX_HTTP_V2_END_STREAM_FLAG : NGX_HTTP_V2_NO_FLAG;
frame_size = stream->connection->frame_size;
for ( ;; ) {
@@ -776,7 +892,7 @@
continue;
}
- b->last_buf = r->header_only;
+ b->last_buf = fin;
cl->next = NULL;
frame->last = cl;
@@ -798,7 +914,7 @@
ngx_http_request_t *r;
ngx_http_v2_stream_t *stream;
ngx_http_v2_loc_conf_t *h2lcf;
- ngx_http_v2_out_frame_t *frame;
+ ngx_http_v2_out_frame_t *frame, *trailers;
ngx_http_v2_connection_t *h2c;
r = fc->data;
@@ -872,6 +988,8 @@
frame_size = (h2lcf->chunk_size < h2c->frame_size)
? h2lcf->chunk_size : h2c->frame_size;
+ trailers = NGX_HTTP_V2_NO_TRAILERS;
+
#if (NGX_SUPPRESS_WARN)
cl = NULL;
#endif
@@ -934,19 +1052,39 @@
size -= rest;
}
- frame = ngx_http_v2_filter_get_data_frame(stream, frame_size, out, cl);
- if (frame == NULL) {
- return NGX_CHAIN_ERROR;
+ if (cl->buf->last_buf) {
+ trailers = ngx_http_v2_create_trailers_frame(r);
+ if (trailers == NULL) {
+ return NGX_CHAIN_ERROR;
+ }
+
+ if (trailers != NGX_HTTP_V2_NO_TRAILERS) {
+ cl->buf->last_buf = 0;
+ }
}
- ngx_http_v2_queue_frame(h2c, frame);
+ if (frame_size || cl->buf->last_buf) {
+ frame = ngx_http_v2_filter_get_data_frame(stream, frame_size,
+ out, cl);
+ if (frame == NULL) {
+ return NGX_CHAIN_ERROR;
+ }
+
+ ngx_http_v2_queue_frame(h2c, frame);
- h2c->send_window -= frame_size;
+ h2c->send_window -= frame_size;
- stream->send_window -= frame_size;
- stream->queued++;
+ stream->send_window -= frame_size;
+ stream->queued++;
+ }
if (in == NULL) {
+
+ if (trailers != NGX_HTTP_V2_NO_TRAILERS) {
+ ngx_http_v2_queue_frame(h2c, trailers);
+ stream->queued++;
+ }
+
break;
}
|
[-]
[+]
|
Changed |
_service:download_url:nginx-1.13.2.tar.gz/src/os/unix/ngx_udp_sendmsg_chain.c
^
|
@@ -206,13 +206,13 @@
#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
#if (NGX_HAVE_IP_SENDSRCADDR)
- u_char msg_control[CMSG_SPACE(sizeof(struct in_addr))];
+ u_char msg_control[CMSG_SPACE(sizeof(struct in_addr))];
#elif (NGX_HAVE_IP_PKTINFO)
- u_char msg_control[CMSG_SPACE(sizeof(struct in_pktinfo))];
+ u_char msg_control[CMSG_SPACE(sizeof(struct in_pktinfo))];
#endif
#if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO)
- u_char msg_control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+ u_char msg_control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
#endif
#endif
|