Skip to content

Commit

Permalink
Merged with the default branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
pluknet committed Jun 22, 2022
2 parents 854e41f + 1009f55 commit c64e2ec
Show file tree
Hide file tree
Showing 46 changed files with 1,281 additions and 1,277 deletions.
1 change: 1 addition & 0 deletions .hgtags
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,4 @@ bfbc52374adcbf2f9060afd62de940f6fab3bba5 release-1.21.2
39be8a682c58308d9399cddd57e37f9fdb7bdf3e release-1.21.4
d986378168fd4d70e0121cabac274c560cca9bdf release-1.21.5
714eb4b2c09e712fb2572a2164ce2bf67638ccac release-1.21.6
5da2c0902e8e2aa4534008a582a60c61c135960e release-1.23.0
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Experimental QUIC support for nginx

The code is developed in a separate "quic" branch available
at https://hg.nginx.org/nginx-quic. Currently it is based
on nginx mainline 1.21.x. We merge new nginx releases into
on nginx mainline 1.23.x. We merge new nginx releases into
this branch regularly.

The project code base is under the same BSD license as nginx.
Expand Down
2 changes: 1 addition & 1 deletion auto/os/conf
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ case "$NGX_MACHINE" in
NGX_MACH_CACHE_LINE=64
;;

aarch64 )
aarch64 | arm64)
have=NGX_ALIGNMENT value=16 . auto/define
NGX_MACH_CACHE_LINE=64
;;
Expand Down
1,012 changes: 264 additions & 748 deletions contrib/vim/syntax/nginx.vim

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions docs/xml/nginx/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,107 @@
<change_log title="nginx">


<changes ver="1.23.0" date="2022-06-21">

<change>
<para lang="ru">
Изменение во внутреннем API:
теперь строки заголовков представлены связными списками.
</para>
<para lang="en">
Change in internal API:
now header lines are represented as linked lists.
</para>
</change>

<change type="change">
<para lang="ru">
теперь nginx объединяет произвольные строки заголовков с одинаковыми именами
при отправке на FastCGI-, SCGI- и uwsgi-бэкенды,
в методе $r->header_in() модуля ngx_http_perl_module,
и при доступе через переменные "$http_...", "$sent_http_...",
"$sent_trailer_...", "$upstream_http_..." и "$upstream_trailer_...".
</para>
<para lang="en">
now nginx combines arbitrary header lines with identical names
when sending to FastCGI, SCGI, and uwsgi backends,
in the $r->header_in() method of the ngx_http_perl_module,
and during lookup of the "$http_...", "$sent_http_...",
"$sent_trailer_...", "$upstream_http_...", and "$upstream_trailer_..."
variables.
</para>
</change>

<change type="bugfix">
<para lang="ru">
если в заголовке ответа бэкенда было несколько строк "Vary",
при кэшировании nginx учитывал только последнюю из них.
</para>
<para lang="en">
if there were multiple "Vary" header lines in the backend response,
nginx only used the last of them when caching.
</para>
</change>

<change type="bugfix">
<para lang="ru">
если в заголовке ответа бэкенда было несколько строк "WWW-Authenticate"
и использовался перехват ошибок с кодом 401 от бэкенда
или директива auth_request,
nginx пересылал клиенту только первую из этих строк.
</para>
<para lang="en">
if there were multiple "WWW-Authenticate" header lines in the backend response
and errors with code 401 were intercepted
or the "auth_request" directive was used,
nginx only sent the first of the header lines to the client.
</para>
</change>

<change type="change">
<para lang="ru">
уровень логгирования ошибок SSL "application data after close notify"
понижен с уровня crit до info.
</para>
<para lang="en">
the logging level of the "application data after close notify" SSL errors
has been lowered from "crit" to "info".
</para>
</change>

<change type="bugfix">
<para lang="ru">
соединения могли зависать, если nginx был собран на Linux 2.6.17 и новее,
а использовался на системах без поддержки EPOLLRDHUP, в частности, на
системах с эмуляцией epoll;
ошибка появилась в 1.17.5.<br/>
Спасибо Marcus Ball.
</para>
<para lang="en">
connections might hang if nginx was built on Linux 2.6.17 or newer,
but was used on systems without EPOLLRDHUP support, notably with epoll
emulation layers;
the bug had appeared in 1.17.5.<br/>
Thanks to Marcus Ball.
</para>
</change>

<change type="bugfix">
<para lang="ru">
nginx не кэшировал ответ,
если строка заголовка ответа "Expires" запрещала кэширование,
а последующая строка заголовка "Cache-Control" разрешала кэширование.
</para>
<para lang="en">
nginx did not cache the response
if the "Expires" response header line disabled caching,
but following "Cache-Control" header line enabled caching.
</para>
</change>

</changes>


<changes ver="1.21.6" date="2022-01-25">

<change type="bugfix">
Expand Down
10 changes: 2 additions & 8 deletions misc/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@ TEMP = tmp

CC = cl
OBJS = objs.msvc8
OPENSSL = openssl-1.1.1m
ZLIB = zlib-1.2.11
OPENSSL = openssl-1.1.1p
ZLIB = zlib-1.2.12
PCRE = pcre2-10.39


release: export

mv $(TEMP)/$(NGINX)/auto/configure $(TEMP)/$(NGINX)

# delete incomplete sources
rm $(TEMP)/$(NGINX)/src/event/ngx_event_acceptex.c
rm $(TEMP)/$(NGINX)/src/event/ngx_event_connectex.c
rm $(TEMP)/$(NGINX)/src/event/modules/ngx_iocp_module.*
rm -r $(TEMP)/$(NGINX)/src/os/win32

mv $(TEMP)/$(NGINX)/docs/text/LICENSE $(TEMP)/$(NGINX)
mv $(TEMP)/$(NGINX)/docs/text/README $(TEMP)/$(NGINX)
mv $(TEMP)/$(NGINX)/docs/html $(TEMP)/$(NGINX)
Expand Down
4 changes: 2 additions & 2 deletions src/core/nginx.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_


#define nginx_version 1021007
#define NGINX_VERSION "1.21.7"
#define nginx_version 1023000
#define NGINX_VERSION "1.23.0"
#define NGINX_VER "nginx/" NGINX_VERSION

#ifdef NGX_BUILD
Expand Down
7 changes: 5 additions & 2 deletions src/core/ngx_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ typedef struct {
} ngx_hash_keys_arrays_t;


typedef struct {
typedef struct ngx_table_elt_s ngx_table_elt_t;

struct ngx_table_elt_s {
ngx_uint_t hash;
ngx_str_t key;
ngx_str_t value;
u_char *lowcase_key;
} ngx_table_elt_t;
ngx_table_elt_t *next;
};


void *ngx_hash_find(ngx_hash_t *hash, ngx_uint_t key, u_char *name, size_t len);
Expand Down
1 change: 1 addition & 0 deletions src/core/ngx_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,7 @@ ngx_resolver_send_tcp_query(ngx_resolver_t *r, ngx_resolver_connection_t *rec,

rec->tcp->data = rec;
rec->tcp->write->handler = ngx_resolver_tcp_write;
rec->tcp->write->cancelable = 1;
rec->tcp->read->handler = ngx_resolver_tcp_read;
rec->tcp->read->resolver = 1;

Expand Down
1 change: 1 addition & 0 deletions src/http/modules/ngx_http_auth_basic_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ ngx_http_auth_basic_set_realm(ngx_http_request_t *r, ngx_str_t *realm)
*p = '"';

r->headers_out.www_authenticate->hash = 1;
r->headers_out.www_authenticate->next = NULL;
ngx_str_set(&r->headers_out.www_authenticate->key, "WWW-Authenticate");
r->headers_out.www_authenticate->value.data = basic;
r->headers_out.www_authenticate->value.len = len;
Expand Down
12 changes: 9 additions & 3 deletions src/http/modules/ngx_http_auth_request_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ngx_module_t ngx_http_auth_request_module = {
static ngx_int_t
ngx_http_auth_request_handler(ngx_http_request_t *r)
{
ngx_table_elt_t *h, *ho;
ngx_table_elt_t *h, *ho, **ph;
ngx_http_request_t *sr;
ngx_http_post_subrequest_t *ps;
ngx_http_auth_request_ctx_t *ctx;
Expand Down Expand Up @@ -147,15 +147,21 @@ ngx_http_auth_request_handler(ngx_http_request_t *r)
h = sr->upstream->headers_in.www_authenticate;
}

if (h) {
ph = &r->headers_out.www_authenticate;

while (h) {
ho = ngx_list_push(&r->headers_out.headers);
if (ho == NULL) {
return NGX_ERROR;
}

*ho = *h;
ho->next = NULL;

*ph = ho;
ph = &ho->next;

r->headers_out.www_authenticate = ho;
h = h->next;
}

return ctx->status;
Expand Down
1 change: 1 addition & 0 deletions src/http/modules/ngx_http_dav_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ ngx_http_dav_location(ngx_http_request_t *r)
}

r->headers_out.location->hash = 1;
r->headers_out.location->next = NULL;
ngx_str_set(&r->headers_out.location->key, "Location");

escape = 2 * ngx_escape_uri(NULL, r->uri.data, r->uri.len, NGX_ESCAPE_URI);
Expand Down
74 changes: 61 additions & 13 deletions src/http/modules/ngx_http_fastcgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,14 +835,14 @@ static ngx_int_t
ngx_http_fastcgi_create_request(ngx_http_request_t *r)
{
off_t file_pos;
u_char ch, *pos, *lowcase_key;
u_char ch, sep, *pos, *lowcase_key;
size_t size, len, key_len, val_len, padding,
allocated;
ngx_uint_t i, n, next, hash, skip_empty, header_params;
ngx_buf_t *b;
ngx_chain_t *cl, *body;
ngx_list_part_t *part;
ngx_table_elt_t *header, **ignored;
ngx_table_elt_t *header, *hn, **ignored;
ngx_http_upstream_t *u;
ngx_http_script_code_pt code;
ngx_http_script_engine_t e, le;
Expand Down Expand Up @@ -900,7 +900,11 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
allocated = 0;
lowcase_key = NULL;

if (params->number) {
if (ngx_http_link_multi_headers(r) != NGX_OK) {
return NGX_ERROR;
}

if (params->number || r->headers_in.multi) {
n = 0;
part = &r->headers_in.headers.part;

Expand Down Expand Up @@ -930,6 +934,12 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
i = 0;
}

for (n = 0; n < header_params; n++) {
if (&header[i] == ignored[n]) {
goto next_length;
}
}

if (params->number) {
if (allocated < header[i].key.len) {
allocated = header[i].key.len + 16;
Expand Down Expand Up @@ -959,15 +969,23 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
ignored[header_params++] = &header[i];
continue;
}
}

n += sizeof("HTTP_") - 1;
key_len = sizeof("HTTP_") - 1 + header[i].key.len;

} else {
n = sizeof("HTTP_") - 1 + header[i].key.len;
val_len = header[i].value.len;

for (hn = header[i].next; hn; hn = hn->next) {
val_len += hn->value.len + 2;
ignored[header_params++] = hn;
}

len += ((n > 127) ? 4 : 1) + ((header[i].value.len > 127) ? 4 : 1)
+ n + header[i].value.len;
len += ((key_len > 127) ? 4 : 1) + key_len
+ ((val_len > 127) ? 4 : 1) + val_len;

next_length:

continue;
}
}

Expand Down Expand Up @@ -1109,7 +1127,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)

for (n = 0; n < header_params; n++) {
if (&header[i] == ignored[n]) {
goto next;
goto next_value;
}
}

Expand All @@ -1125,6 +1143,11 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
}

val_len = header[i].value.len;

for (hn = header[i].next; hn; hn = hn->next) {
val_len += hn->value.len + 2;
}

if (val_len > 127) {
*b->last++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80);
*b->last++ = (u_char) ((val_len >> 16) & 0xff);
Expand All @@ -1150,13 +1173,34 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
*b->last++ = ch;
}

b->last = ngx_copy(b->last, header[i].value.data, val_len);
b->last = ngx_copy(b->last, header[i].value.data,
header[i].value.len);

if (header[i].next) {

if (header[i].key.len == sizeof("Cookie") - 1
&& ngx_strncasecmp(header[i].key.data, (u_char *) "Cookie",
sizeof("Cookie") - 1)
== 0)
{
sep = ';';

} else {
sep = ',';
}

for (hn = header[i].next; hn; hn = hn->next) {
*b->last++ = sep;
*b->last++ = ' ';
b->last = ngx_copy(b->last, hn->value.data, hn->value.len);
}
}

ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"fastcgi param: \"%*s: %*s\"",
key_len, b->last - (key_len + val_len),
val_len, b->last - val_len);
next:
next_value:

continue;
}
Expand Down Expand Up @@ -1963,8 +2007,12 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
hh = ngx_hash_find(&umcf->headers_in_hash, h->hash,
h->lowcase_key, h->key.len);

if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
return NGX_ERROR;
if (hh) {
rc = hh->handler(r, h, hh->offset);

if (rc != NGX_OK) {
return rc;
}
}

ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
Expand Down
Loading

0 comments on commit c64e2ec

Please sign in to comment.