Ticket #6119: 6119.2.patch

File 6119.2.patch, 1.5 KB (added by moijes12, 8 years ago)
  • twisted/web/test/test_http.py

     
    14811481        self.assertEqual(
    14821482            req.received_cookies, {b"test": b'"lemur"', b"test2": b'"panda"'})
    14831483
     1484    def test_parseCookiesNoCookie(self):
     1485        """
     1486        L{http.Request.parseCookies} returns None if the Cookies are not part
     1487        of the header.
     1488        """
     1489        req = http.Request(DummyChannel(), None)
     1490        self.assertEqual(req.parseCookies(), None)
    14841491
     1492
     1493    def test_parseCookiesMalformedCookie(self):
     1494        """
     1495        L{http.Request.parseCookies} ignores malformed cookie pairs. Cookies
     1496        set before or after the malformed cookie-pair are properly parsed.
     1497        """
     1498        req = http.Request(DummyChannel(), None)
     1499        req.requestHeaders.setRawHeaders(
     1500            b"cookie", [b'12345; test="lemur"; 12345; test2="panda"; 12345'])
     1501        req.parseCookies()
     1502        self.assertEqual(
     1503            req.received_cookies, {b"test": b'"lemur"', b"test2": b'"panda"'})
     1504        req.requestHeaders.setRawHeaders(
     1505            b"cookie", [b'12345', b'test="lemur"', b'12345',
     1506            b'test2="panda"', b'12345'])
     1507        req.parseCookies()
     1508        self.assertEqual(
     1509            req.received_cookies, {b"test": b'"lemur"', b"test2": b'"panda"'})
     1510
     1511
    14851512    def test_connectionLost(self):
    14861513        """
    14871514        L{http.Request.connectionLost} closes L{Request.content} and drops the