Opened 16 years ago

Closed 16 years ago

#6775 closed (invalid)

request.META should be a MultiValueDict

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

Description

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

http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

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

Change History (1)

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

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/

mod_python

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.

#python
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

WSGI response was very similar:

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

Summary

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