Welcome! Log In Create A New Profile

Advanced

[PATCH 13 of 20] All known output headers can be linked lists now

Maxim Dounin
April 20, 2022 07:02PM
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1650492333 -10800
# Thu Apr 21 01:05:33 2022 +0300
# Node ID 618f9f39e9ad53fd84e94d0c2a0f1b7f82bfcca5
# Parent 1231bff732696207842fa66b71ca63b951ac5c06
All known output headers can be linked lists now.

The h->next pointer properly provided as NULL in all cases where known
output headers are added.

Note that there are 3rd party modules which might not do this, and it
might be risky to rely on this for arbitrary headers.

diff --git a/src/http/modules/ngx_http_auth_basic_module.c b/src/http/modules/ngx_http_auth_basic_module.c
--- a/src/http/modules/ngx_http_auth_basic_module.c
+++ b/src/http/modules/ngx_http_auth_basic_module.c
@@ -339,6 +339,7 @@ ngx_http_auth_basic_set_realm(ngx_http_r
*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;
diff --git a/src/http/modules/ngx_http_auth_request_module.c b/src/http/modules/ngx_http_auth_request_module.c
--- a/src/http/modules/ngx_http_auth_request_module.c
+++ b/src/http/modules/ngx_http_auth_request_module.c
@@ -154,6 +154,7 @@ ngx_http_auth_request_handler(ngx_http_r
}

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

r->headers_out.www_authenticate = ho;
}
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -1082,6 +1082,7 @@ ngx_http_dav_location(ngx_http_request_t
}

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);
diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c
--- a/src/http/modules/ngx_http_gzip_filter_module.c
+++ b/src/http/modules/ngx_http_gzip_filter_module.c
@@ -280,6 +280,7 @@ ngx_http_gzip_header_filter(ngx_http_req
}

h->hash = 1;
+ h->next = NULL;
ngx_str_set(&h->key, "Content-Encoding");
ngx_str_set(&h->value, "gzip");
r->headers_out.content_encoding = h;
diff --git a/src/http/modules/ngx_http_gzip_static_module.c b/src/http/modules/ngx_http_gzip_static_module.c
--- a/src/http/modules/ngx_http_gzip_static_module.c
+++ b/src/http/modules/ngx_http_gzip_static_module.c
@@ -242,6 +242,7 @@ ngx_http_gzip_static_handler(ngx_http_re
}

h->hash = 1;
+ h->next = NULL;
ngx_str_set(&h->key, "Content-Encoding");
ngx_str_set(&h->value, "gzip");
r->headers_out.content_encoding = h;
diff --git a/src/http/modules/ngx_http_headers_filter_module.c b/src/http/modules/ngx_http_headers_filter_module.c
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -362,6 +362,7 @@ ngx_http_set_expires(ngx_http_request_t
}

r->headers_out.expires = e;
+ e->next = NULL;

e->hash = 1;
ngx_str_set(&e->key, "Expires");
@@ -621,6 +622,7 @@ ngx_http_set_response_header(ngx_http_re
}

*old = h;
+ h->next = NULL;
}

h->hash = 1;
diff --git a/src/http/modules/ngx_http_memcached_module.c b/src/http/modules/ngx_http_memcached_module.c
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -401,6 +401,7 @@ found:
}

h->hash = 1;
+ h->next = NULL;
ngx_str_set(&h->key, "Content-Encoding");
ngx_str_set(&h->value, "gzip");
r->headers_out.content_encoding = h;
diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -258,6 +258,7 @@ next_filter:
}

r->headers_out.accept_ranges->hash = 1;
+ r->headers_out.accept_ranges->next = NULL;
ngx_str_set(&r->headers_out.accept_ranges->key, "Accept-Ranges");
ngx_str_set(&r->headers_out.accept_ranges->value, "bytes");

@@ -427,6 +428,7 @@ ngx_http_range_singlepart_header(ngx_htt
r->headers_out.content_range = content_range;

content_range->hash = 1;
+ content_range->next = NULL;
ngx_str_set(&content_range->key, "Content-Range");

content_range->value.data = ngx_pnalloc(r->pool,
@@ -599,6 +601,7 @@ ngx_http_range_not_satisfiable(ngx_http_
r->headers_out.content_range = content_range;

content_range->hash = 1;
+ content_range->next = NULL;
ngx_str_set(&content_range->key, "Content-Range");

content_range->value.data = ngx_pnalloc(r->pool,
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -195,6 +195,7 @@ ngx_http_static_handler(ngx_http_request
}

r->headers_out.location->hash = 1;
+ r->headers_out.location->next = NULL;
ngx_str_set(&r->headers_out.location->key, "Location");
r->headers_out.location->value.len = len;
r->headers_out.location->value.data = location;
diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -573,6 +573,7 @@ header_out(r, key, value)
}

header->hash = 1;
+ header->next = NULL;

if (ngx_http_perl_sv2str(aTHX_ r, &header->key, key) != NGX_OK) {
header->hash = 0;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1007,6 +1007,7 @@ ngx_http_core_find_config_phase(ngx_http
}

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

if (r->args.len == 0) {
@@ -1687,6 +1688,7 @@ ngx_http_set_etag(ngx_http_request_t *r)
}

etag->hash = 1;
+ etag->next = NULL;
ngx_str_set(&etag->key, "ETag");

etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);
@@ -1781,6 +1783,7 @@ ngx_http_send_response(ngx_http_request_
}

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

diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -1243,6 +1243,7 @@ ngx_http_script_regex_end_code(ngx_http_
}

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

diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -649,6 +649,7 @@ ngx_http_send_error_page(ngx_http_reques
}

location->hash = 1;
+ location->next = NULL;
ngx_str_set(&location->key, "Location");
location->value = uri;

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2681,6 +2681,7 @@ ngx_http_upstream_intercept_errors(ngx_h
}

*h = *u->headers_in.www_authenticate;
+ h->next = NULL;

r->headers_out.www_authenticate = h;
}
@@ -5075,6 +5076,7 @@ ngx_http_upstream_copy_header_line(ngx_h
if (offset) {
ph = (ngx_table_elt_t **) ((char *) &r->headers_out + offset);
*ph = ho;
+ ho->next = NULL;
}

return NGX_OK;
@@ -5169,6 +5171,7 @@ ngx_http_upstream_copy_last_modified(ngx
}

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

r->headers_out.last_modified = ho;
r->headers_out.last_modified_time =
@@ -5191,6 +5194,7 @@ ngx_http_upstream_rewrite_location(ngx_h
}

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

if (r->upstream->rewrite_redirect) {
rc = r->upstream->rewrite_redirect(r, ho, 0);
@@ -5236,6 +5240,7 @@ ngx_http_upstream_rewrite_refresh(ngx_ht
}

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

if (r->upstream->rewrite_redirect) {

@@ -5281,6 +5286,7 @@ ngx_http_upstream_rewrite_set_cookie(ngx
}

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

if (r->upstream->rewrite_cookie) {
rc = r->upstream->rewrite_cookie(r, ho);
@@ -5334,6 +5340,7 @@ ngx_http_upstream_copy_allow_ranges(ngx_
}

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

r->headers_out.accept_ranges = ho;


_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH 00 of 20] multiple headers handling

Maxim Dounin 1004 April 20, 2022 06:38PM

[PATCH 03 of 20] SCGI: combining headers with identical names (ticket #1724)

Maxim Dounin 265 April 20, 2022 06:40PM

[PATCH 02 of 20] FastCGI: combining headers with identical names (ticket #1724)

Maxim Dounin 208 April 20, 2022 06:42PM

Re: [PATCH 02 of 20] FastCGI: combining headers with identical names (ticket #1724)

Sergey Kandaurov 264 May 11, 2022 11:36AM

Re: [PATCH 02 of 20] FastCGI: combining headers with identical names (ticket #1724)

Maxim Dounin 182 May 12, 2022 06:34PM

Re: [PATCH 02 of 20] FastCGI: combining headers with identical names (ticket #1724)

Sergey Kandaurov 274 May 13, 2022 10:06AM

Re: [PATCH 02 of 20] FastCGI: combining headers with identical names (ticket #1724)

Sergey Kandaurov 176 May 13, 2022 10:06AM

[PATCH 04 of 20] Uwsgi: combining headers with identical names (ticket #1724)

Maxim Dounin 223 April 20, 2022 06:44PM

[PATCH 08 of 20] Perl: all known input headers are handled identically

Maxim Dounin 295 April 20, 2022 06:44PM

[PATCH 10 of 20] Upstream: style

Maxim Dounin 259 April 20, 2022 06:46PM

[PATCH 07 of 20] All non-unique input headers are now linked lists

Maxim Dounin 343 April 20, 2022 06:48PM

Re: [PATCH 07 of 20] All non-unique input headers are now linked lists

Sergey Kandaurov 334 May 11, 2022 03:44PM

Re: [PATCH 07 of 20] All non-unique input headers are now linked lists

Maxim Dounin 188 May 12, 2022 07:56PM

[PATCH 09 of 20] Perl: combining unknown headers during $r->header_in() lookup

Maxim Dounin 206 April 20, 2022 06:50PM

[PATCH 12 of 20] Upstream: simplified Accept-Ranges handling

Maxim Dounin 351 April 20, 2022 06:52PM

[PATCH 11 of 20] Upstream: simplified Content-Encoding handling

Maxim Dounin 258 April 20, 2022 06:54PM

Re: [PATCH 11 of 20] Upstream: simplified Content-Encoding handling

Sergey Kandaurov 221 May 11, 2022 04:02PM

Re: [PATCH 11 of 20] Upstream: simplified Content-Encoding handling

Maxim Dounin 207 May 12, 2022 08:20PM

[PATCH 05 of 20] Combining unknown headers during variables lookup (ticket #1316)

Maxim Dounin 191 April 20, 2022 06:56PM

Re: [PATCH 05 of 20] Combining unknown headers during variables lookup (ticket #1316)

Sergey Kandaurov 227 May 11, 2022 12:12PM

Re: [PATCH 05 of 20] Combining unknown headers during variables lookup (ticket #1316)

Maxim Dounin 285 May 12, 2022 07:18PM

[PATCH 06 of 20] Reworked multi headers to use linked lists

Maxim Dounin 285 April 20, 2022 06:58PM

Re: [PATCH 06 of 20] Reworked multi headers to use linked lists

Sergey Kandaurov 201 May 11, 2022 03:24PM

Re: [PATCH 06 of 20] Reworked multi headers to use linked lists

Maxim Dounin 223 May 12, 2022 07:44PM

Re: [PATCH 06 of 20] Reworked multi headers to use linked lists

Sergey Kandaurov 368 June 13, 2022 01:08PM

Re: [PATCH 06 of 20] Reworked multi headers to use linked lists

Maxim Dounin 210 June 13, 2022 06:52PM

[PATCH 14 of 20] Upstream: all known headers in u->headers_in are linked lists now

Maxim Dounin 257 April 20, 2022 07:00PM

[PATCH 13 of 20] All known output headers can be linked lists now

Maxim Dounin 189 April 20, 2022 07:02PM

[PATCH 15 of 20] Upstream: header handlers can now return parsing errors

Maxim Dounin 182 April 20, 2022 07:04PM

Re: [PATCH 15 of 20] Upstream: header handlers can now return parsing errors

Sergey Kandaurov 206 May 11, 2022 04:30PM

Re: [PATCH 15 of 20] Upstream: header handlers can now return parsing errors

Maxim Dounin 195 May 12, 2022 08:26PM

[PATCH 17 of 20] Upstream: handling of multiple Vary headers (ticket #1423)

Maxim Dounin 221 April 20, 2022 07:06PM

Re: [PATCH 17 of 20] Upstream: handling of multiple Vary headers (ticket #1423)

Sergey Kandaurov 207 May 11, 2022 04:48PM

Re: [PATCH 17 of 20] Upstream: handling of multiple Vary headers (ticket #1423)

Maxim Dounin 169 May 12, 2022 08:52PM

[PATCH 18 of 20] Upstream: multiple WWW-Authenticate headers (ticket #485)

Maxim Dounin 181 April 20, 2022 07:08PM

Re: [PATCH 18 of 20] Upstream: multiple WWW-Authenticate headers (ticket #485)

Sergey Kandaurov 216 May 11, 2022 05:06PM

Re: [PATCH 18 of 20] Upstream: multiple WWW-Authenticate headers (ticket #485)

Maxim Dounin 191 May 12, 2022 10:00PM

Re: [PATCH 18 of 20] Upstream: multiple WWW-Authenticate headers (ticket #485)

Sergey Kandaurov 215 May 20, 2022 09:56AM

Re: [PATCH 18 of 20] Upstream: multiple WWW-Authenticate headers (ticket #485)

Maxim Dounin 191 May 20, 2022 05:10PM

[PATCH 16 of 20] Upstream: duplicate headers ignored or properly linked

Maxim Dounin 249 April 20, 2022 07:10PM

Re: [PATCH 16 of 20] Upstream: duplicate headers ignored or properly linked

Sergey Kandaurov 187 May 11, 2022 04:36PM

Re: [PATCH 16 of 20] Upstream: duplicate headers ignored or properly linked

Maxim Dounin 582 May 12, 2022 08:36PM

[PATCH 20 of 20] Headers filter: improved memory allocation error handling

Maxim Dounin 233 April 20, 2022 07:12PM

[PATCH 19 of 20] Auth request: multiple WWW-Authenticate headers (ticket #485)

Maxim Dounin 231 April 20, 2022 07:14PM

[PATCH 00 of 10] multiple headers tests

Maxim Dounin 229 April 20, 2022 07:16PM

[PATCH 01 of 10] Tests: tests for passing Date and Server headers

Maxim Dounin 180 April 20, 2022 07:18PM

[PATCH 02 of 10] Tests: fastcgi tests for combining headers

Maxim Dounin 248 April 20, 2022 07:20PM

[PATCH 03 of 10] Tests: scgi tests for combining headers

Maxim Dounin 193 April 20, 2022 07:20PM

[PATCH 04 of 10] Tests: uwsgi tests for combining headers

Maxim Dounin 168 April 20, 2022 07:22PM

[PATCH 07 of 10] Tests: perl $r->header_in() combining headers test

Maxim Dounin 175 April 20, 2022 07:24PM

[PATCH 09 of 10] Tests: tests for multiple Vary headers (ticket #1423)

Maxim Dounin 179 April 20, 2022 07:26PM

[PATCH 06 of 10] Tests: perl $r->header_in("Connection") test

Maxim Dounin 176 April 20, 2022 07:28PM

[PATCH 05 of 10] Tests: tests for various http header variables

Maxim Dounin 230 April 20, 2022 07:30PM

[PATCH 08 of 10] Tests: tests for duplicate response headers

Maxim Dounin 197 April 20, 2022 07:32PM

[PATCH 10 of 10] Tests: tests for multiple WWW-Authenticate headers (ticket #485)

Maxim Dounin 213 April 20, 2022 07:34PM

Re: [PATCH 00 of 10] multiple headers tests

Sergey Kandaurov 232 May 31, 2022 07:14PM

Re: [PATCH 00 of 10] multiple headers tests

Maxim Dounin 165 June 03, 2022 07:26PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 145
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready