Beispiel #1
0
    def test_parse_headers(self):
        hdrs = ('', 'test: line\r\n', ' continue\r\n',
                'test2: data\r\n', '\r\n')

        headers, close, compression = protocol.parse_headers(
            hdrs, 8190, 32768, 8190)

        self.assertEqual(list(headers),
                         [('TEST', 'line\r\n continue'), ('TEST2', 'data')])
        self.assertIsNone(close)
        self.assertIsNone(compression)
    def test_parse_headers(self):
        hdrs = ('', 'test: line\r\n', ' continue\r\n', 'test2: data\r\n',
                '\r\n')

        headers, close, compression = protocol.parse_headers(
            hdrs, 8190, 32768, 8190)

        self.assertEqual(list(headers), [('TEST', 'line\r\n continue'),
                                         ('TEST2', 'data')])
        self.assertIsNone(close)
        self.assertIsNone(compression)
    def test_parse_headers_multi(self):
        hdrs = ('', 'Set-Cookie: c1=cookie1\r\n', 'Set-Cookie: c2=cookie2\r\n',
                '\r\n')

        headers, close, compression = protocol.parse_headers(
            hdrs, 8190, 32768, 8190)

        self.assertEqual(list(headers), [('SET-COOKIE', 'c1=cookie1'),
                                         ('SET-COOKIE', 'c2=cookie2')])
        self.assertIsNone(close)
        self.assertIsNone(compression)
Beispiel #4
0
    def test_parse_headers_multi(self):
        hdrs = ('',
                'Set-Cookie: c1=cookie1\r\n',
                'Set-Cookie: c2=cookie2\r\n', '\r\n')

        headers, close, compression = protocol.parse_headers(
            hdrs, 8190, 32768, 8190)

        self.assertEqual(list(headers),
                         [('SET-COOKIE', 'c1=cookie1'),
                          ('SET-COOKIE', 'c2=cookie2')])
        self.assertIsNone(close)
        self.assertIsNone(compression)
Beispiel #5
0
 def test_compression_unknown(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'content-encoding: compress\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertIsNone(compression)
Beispiel #6
0
 def test_compression_deflate(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'content-encoding: deflate\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertEqual('deflate', compression)
Beispiel #7
0
 def test_compression_gzip(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'content-encoding: gzip\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertEqual('gzip', compression)
Beispiel #8
0
 def test_conn_other(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'connection: test\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertIsNone(close)
Beispiel #9
0
 def test_conn_keep_alive(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'connection: keep-alive\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertFalse(close)
Beispiel #10
0
 def test_conn_close(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'connection: close\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertTrue(close)
Beispiel #11
0
 def test_conn_keep_alive(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'connection: keep-alive\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertFalse(close)
Beispiel #12
0
 def test_invalid_name(self):
     with self.assertRaises(ValueError) as cm:
         protocol.parse_headers(['', 'test[]: line\r\n', '\r\n'], 8190,
                                32768, 8190)
     self.assertIn("Invalid header name: TEST[]", str(cm.exception))
Beispiel #13
0
 def test_max_continuation_headers_size(self):
     with self.assertRaises(errors.LineTooLong) as cm:
         protocol.parse_headers(['', 'test: line\r\n', ' test\r\n', '\r\n'],
                                8190, 32768, 5)
     self.assertIn("limit request headers fields size", str(cm.exception))
Beispiel #14
0
 def test_compression_unknown(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'content-encoding: compress\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertIsNone(compression)
Beispiel #15
0
 def test_compression_deflate(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'content-encoding: deflate\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertEqual('deflate', compression)
Beispiel #16
0
 def test_compression_gzip(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'content-encoding: gzip\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertEqual('gzip', compression)
Beispiel #17
0
 def test_conn_other(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'connection: test\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertIsNone(close)
Beispiel #18
0
 def test_max_continuation_headers_size(self):
     with self.assertRaises(errors.LineTooLong) as cm:
         protocol.parse_headers(
             ['', 'test: line\r\n', ' test\r\n', '\r\n'], 8190, 32768, 5)
     self.assertIn("limit request headers fields size", str(cm.exception))
Beispiel #19
0
 def test_invalid_name(self):
     with self.assertRaises(ValueError) as cm:
         protocol.parse_headers(
             ['', 'test[]: line\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertIn("Invalid header name: TEST[]", str(cm.exception))
Beispiel #20
0
 def test_conn_close(self):
     headers, close, compression = protocol.parse_headers(
         ['', 'connection: close\r\n', '\r\n'], 8190, 32768, 8190)
     self.assertTrue(close)