Ticket #2970: 2970.diff

File 2970.diff, 1.4 KB (added by Philippe Raoult, 17 years ago)

refactoring using a basic python dict with lowercase keys

  • django/http/__init__.py

     
    246246        else:
    247247            self._container = [content]
    248248            self._is_string = True
    249         self.headers = {'Content-Type': content_type}
     249        self.headers = {'content-type': content_type}
    250250        self.cookies = SimpleCookie()
    251251        if status:
    252252            self.status_code = status
     
    258258            + '\n\n' + self.content
    259259
    260260    def __setitem__(self, header, value):
    261         self.headers[header] = value
     261        self.headers[header.lower()] = value
    262262
    263263    def __delitem__(self, header):
    264264        try:
    265             del self.headers[header]
     265            del self.headers[header.lower()]
    266266        except KeyError:
    267267            pass
    268268
    269269    def __getitem__(self, header):
    270         return self.headers[header]
     270        return self.headers[header.lower()]
    271271
    272272    def has_header(self, header):
    273273        "Case-insensitive check for a header"
    274         header = header.lower()
    275         for key in self.headers.keys():
    276             if key.lower() == header:
    277                 return True
    278         return False
     274        return self.headers.has_key(header.lower())
    279275
    280276    def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
    281277        self.cookies[key] = value
Back to Top