Multiple message-header fields handling

Manlio Perillo manlio_perillo at libero.it
Wed Oct 3 19:07:35 MSD 2007


Igor Sysoev ha scritto:
> On Wed, Oct 03, 2007 at 04:09:49PM +0200, Manlio Perillo wrote:
> 
>> Igor Sysoev ha scritto:
>>> On Tue, Oct 02, 2007 at 10:02:38PM +0200, Manlio Perillo wrote:
>>>
>>>> I have found a "problem" with multiple message-header fields handling in 
>>>> Nginx.
>>>>
>>> [...]
>>>> Igor, do you plan to add this feature in a future version?
>>> nginx does not join headers as Apache does.
>> Ok.
>>
>>> However, all headers are passed to a proxied server/etc as is if they
>>> are not overwritten.
>> The problem is that a WSGI application receives the headers in a Python 
>> dictionary (an associative array).
>> This means that I MUST fold the headers.
> 
> All headers are available in r->headers_in.headers list.
> 

In fact I iterate over this list doing (pseudo Python code):

environ = {}
for key, value in r->headers_in.headers list:
   environ[key] = value


The problem is that I only save the last multi line header.

A solution is to do:

environ = {}
for key, value in r->headers_in.headers list:
    # check if this is a multiline header
    old = environ.get(key, None)
    if old is None:
       environ[key] = value
    else:
       # fold the header value
       environ[key] = old + ", " + value


This is not very efficient, if I have to do many strings concatenations.

>>> As to the cookies nginx treats them specially and $http_cookie includes
>>> all Cookie header fields.
>>>
>> Cookies are a mess.
>> Does nginx apply some for of preprocessing?
> 
> I do not understand the question.
> 

http://kristol.org/cookie/errata.html



Thanks and regards   Manlio Perillo





More information about the nginx mailing list