Ticket #2970: http_response_insensitive.2.patch

File http_response_insensitive.2.patch, 1.2 KB (added by Chris Beaven, 18 years ago)

more backwardsly-compatible

  • django/http/__init__.py

     
    33from pprint import pformat
    44from urllib import urlencode, quote
    55from django.utils.datastructures import MultiValueDict
     6from django.utils.case_insensitive_dict import CaseInsensitiveDict
    67
    78RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
    89
     
    188189    def __getitem__(self, header):
    189190        return self.headers[header]
    190191
     192    def get_headers(self):
     193        return self._headers
     194   
     195    def set_headers(self, headers):
     196        self._headers = CaseInsensitiveDict(headers)
     197       
     198    headers = property(get_headers, set_headers)
     199
    191200    def has_header(self, header):
    192201        "Case-insensitive check for a header"
    193         header = header.lower()
    194         for key in self.headers.keys():
    195             if key.lower() == header:
    196                 return True
    197         return False
     202        return self.headers.has_key(header)
    198203
    199204    def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
    200205        self.cookies[key] = value
Back to Top