Ticket #5054: 5054-00-capitalize-headers-correctly.patch

File 5054-00-capitalize-headers-correctly.patch, 2.3 KB (added by ivank, 6 years ago)
  • twisted/web/http_headers.py

    diff --git a/twisted/web/http_headers.py b/twisted/web/http_headers.py
    index 0b93fcf..9663ac6 100644
    a b class Headers(object): 
    132132    @ivar _rawHeaders: A C{dict} mapping header names as C{str} to C{lists} of
    133133        header values as C{str}.
    134134    """
    135     _caseMappings = {'www-authenticate': 'WWW-Authenticate'}
     135    _caseMappings = {
     136        'content-md5': 'Content-MD5',
     137        'dnt': 'DNT',
     138        'etag': 'ETag',
     139        'p3p': 'P3P',
     140        'te': 'TE',
     141        'www-authenticate': 'WWW-Authenticate',
     142        'x-xss-protection': 'X-XSS-Protection'}
    136143
    137144    def __init__(self, rawHeaders=None):
    138145        self._rawHeaders = {}
  • twisted/web/test/test_http_headers.py

    diff --git a/twisted/web/test/test_http_headers.py b/twisted/web/test/test_http_headers.py
    index 1305478..713e840 100644
    a b class HeadersTests(TestCase): 
    138138        the given header.
    139139        """
    140140        h = Headers()
    141         self.assertEqual(h._canonicalNameCaps("test"), "Test")
    142         self.assertEqual(h._canonicalNameCaps("test-stuff"), "Test-Stuff")
    143         self.assertEqual(h._canonicalNameCaps("www-authenticate"),
     141        self.assertEquals(h._canonicalNameCaps("test"), "Test")
     142        self.assertEquals(h._canonicalNameCaps("test-stuff"), "Test-Stuff")
     143        self.assertEquals(h._canonicalNameCaps("content-md5"), "Content-MD5")
     144        self.assertEquals(h._canonicalNameCaps("dnt"), "DNT")
     145        self.assertEquals(h._canonicalNameCaps("etag"), "ETag")
     146        self.assertEquals(h._canonicalNameCaps("p3p"), "P3P")
     147        self.assertEquals(h._canonicalNameCaps("te"), "TE")
     148        self.assertEquals(h._canonicalNameCaps("www-authenticate"),
    144149                          "WWW-Authenticate")
     150        self.assertEquals(h._canonicalNameCaps("x-xss-protection"),
     151                          "X-XSS-Protection")
    145152
    146153
    147154    def test_getAllRawHeaders(self):
  • new file twisted/web/topfiles/5054.bugfix

    diff --git a/twisted/web/topfiles/5054.bugfix b/twisted/web/topfiles/5054.bugfix
    new file mode 100644
    index 0000000..a63c28e
    - +  
     1twisted.web.http_headers.Headers now correctly capitalizes the header names
     2Content-MD5, DNT, ETag, P3P, TE, and X-XSS-Protection.