comparison src/http/ngx_http_upstream.c @ 8023:08b3ea81ff5f

Combining unknown headers during variables lookup (ticket #1316). Previously, $http_*, $sent_http_*, $sent_trailer_*, $upstream_http_*, and $upstream_trailer_* variables returned only the first header (with a few specially handled exceptions: $http_cookie, $http_x_forwarded_for, $sent_http_cache_control, $sent_http_link). With this change, all headers are returned, combined together. For example, $http_foo variable will be "a, b" if there are "Foo: a" and "Foo: b" headers in the request. Note that $upstream_http_set_cookie will also return all "Set-Cookie" headers (ticket #1843), though this might not be what one want, since the "Set-Cookie" header does not follow the list syntax (see RFC 7230, section 3.2.2).
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 30 May 2022 21:25:32 +0300
parents a7a77549265e
children ef6a3a99a81a
comparison
equal deleted inserted replaced
8022:8b7a96fdd54c 8023:08b3ea81ff5f
5701 if (r->upstream == NULL) { 5701 if (r->upstream == NULL) {
5702 v->not_found = 1; 5702 v->not_found = 1;
5703 return NGX_OK; 5703 return NGX_OK;
5704 } 5704 }
5705 5705
5706 return ngx_http_variable_unknown_header(v, (ngx_str_t *) data, 5706 return ngx_http_variable_unknown_header(r, v, (ngx_str_t *) data,
5707 &r->upstream->headers_in.headers.part, 5707 &r->upstream->headers_in.headers.part,
5708 sizeof("upstream_http_") - 1); 5708 sizeof("upstream_http_") - 1);
5709 } 5709 }
5710 5710
5711 5711
5716 if (r->upstream == NULL) { 5716 if (r->upstream == NULL) {
5717 v->not_found = 1; 5717 v->not_found = 1;
5718 return NGX_OK; 5718 return NGX_OK;
5719 } 5719 }
5720 5720
5721 return ngx_http_variable_unknown_header(v, (ngx_str_t *) data, 5721 return ngx_http_variable_unknown_header(r, v, (ngx_str_t *) data,
5722 &r->upstream->headers_in.trailers.part, 5722 &r->upstream->headers_in.trailers.part,
5723 sizeof("upstream_trailer_") - 1); 5723 sizeof("upstream_trailer_") - 1);
5724 } 5724 }
5725 5725
5726 5726