Ticket #2970: http_response_insensitive.patch

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

Here's the patch

  • 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
     
    166167        else:
    167168            self._container = [content]
    168169            self._is_string = True
    169         self.headers = {'Content-Type': mimetype}
     170        self.headers = CaseInsensitiveDict({'Content-Type': mimetype})
    170171        self.cookies = SimpleCookie()
    171172        self.status_code = 200
    172173
     
    190191
    191192    def has_header(self, header):
    192193        "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
     194        return self.headers.has_key(header)
    198195
    199196    def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
    200197        self.cookies[key] = value
Back to Top