Opened 10 years ago

Closed 10 years ago

#6775 closed (invalid)

request.META should be a MultiValueDict

Reported by: Honza Král Owned by: nobody
Component: HTTP handling Version: master
Severity: Keywords: http multivaluedict querydict
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The RFC specifies that some headers in HTTP can appear more than once, we need to store the headers in MultiValueDict to reflect that.

Multiple message-header fields with the same field-name MAY be present in a message

Change History (1)

comment:1 in reply to:  description Changed 10 years ago by Piotr Lewandowski <django@…>

Resolution: invalid
Status: newclosed

This change would be backward incompatible. Let's see what RFC 2616 says:

Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma.

Let's check how will *mod_python* and *WSGI* act using curl:

curl -H 'Foo: spam' -H 'Foo: eggs' http://localhost:8000/


In case of mod_python handler request.META is populated with custom headers by following chunk of code:

            for key, value in self._req.headers_in.items():
                key = 'HTTP_' + key.upper().replace('-', '_')
                self._meta[key] = value

Notice that self._req.headers_in provider by mod_python is an ordinary dict.

mod_python seems to handle multiple headers occurrences in the RFC2616-way - by combining multiple header fields' values into the comma separated list.

print request.META['HTTP_FOO']
'spam, eggs'

I wonder if separating items using '<comma><space>' delimiter is the right thing but that's not Django's business.


WSGI response was very similar:

print request.META['HTTP_FOO']


It seems that it's correct behaviour and no changes in Django are required so I'm closing this ticket as invalid.

Note: See TracTickets for help on using tickets.
Back to Top