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

Sergey Kandaurov pluknet at nginx.com
Fri May 13 14:01:28 UTC 2022



> On 13 May 2022, at 02:32, Maxim Dounin <mdounin at mdounin.ru> wrote:
> 
> Hello!
> 
> On Wed, May 11, 2022 at 07:32:32PM +0400, Sergey Kandaurov wrote:
> 
>> On Thu, Apr 21, 2022 at 01:18:42AM +0300, Maxim Dounin wrote:
>>> # HG changeset patch
>>> # User Maxim Dounin <mdounin at mdounin.ru>
>>> # Date 1650492316 -10800
>>> #      Thu Apr 21 01:05:16 2022 +0300
>>> # Node ID 61b29233a55216c6fa72e23b93a4a28d76a9fb94
>>> # Parent  e70fb0fdfbc0fb7b7e9f493cc2eb65de617b115a
>>> FastCGI: combining headers with identical names (ticket #1724).

[..]

>>> 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
>>> @@ -2802,6 +2802,78 @@ ngx_http_get_forwarded_addr_internal(ngx
>>> }
>>> 
>>> 
>>> +ngx_int_t
>>> +ngx_http_link_multi_headers(ngx_http_request_t *r)
>>> +{
>>> +    ngx_uint_t        i, j;
>>> +    ngx_list_part_t  *part, *ppart;
>>> +    ngx_table_elt_t  *header, *pheader, **ph;
>>> +
>>> +    if (r->headers_in.multi_linked) {
>>> +        return NGX_OK;
>>> +    }
>> 
>> multi_linked is never set, was the intension to avoid doing the work
>> twice on repetitive invocation? it doesn't seem to be possible.
>> I'd just axe it.
> 
> Yes, thanks, missed this somehow.  It should be set right after 
> the test, updated with the following change:
> 
> 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
> @@ -2813,6 +2813,8 @@ ngx_http_link_multi_headers(ngx_http_req
>         return NGX_OK;
>     }
> 
> +    r->headers_in.multi_linked = 1;
> +
>     part = &r->headers_in.headers.part;
>     header = part->elts;
> 
> 
> Not sure what do you mean by "doesn't seem to be possible".  The 
> request headers are never changed after parsing, so it is enough 
> to link them just once.

Nevermind, the point was the function itself is called just once.
But it's not so as part of internal redirect to another upstream.

[..]

-- 
Sergey Kandaurov



More information about the nginx-devel mailing list