Exemplo n.º 1
0
 def test_afterFinished(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} raises L{RuntimeError} if it
     is called after it has seen the last chunk.
     """
     p = http._ChunkedTransferEncoding(None, lambda bytes: None)
     p.dataReceived('0\r\n\r\n')
     self.assertRaises(RuntimeError, p.dataReceived, 'hello')
Exemplo n.º 2
0
 def test_afterFinished(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} raises L{RuntimeError} if it
     is called after it has seen the last chunk.
     """
     p = http._ChunkedTransferEncoding(None, lambda bytes: None)
     p.dataReceived('0\r\n\r\n')
     self.assertRaises(RuntimeError, p.dataReceived, 'hello')
Exemplo n.º 3
0
 def test_extra(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} passes any bytes which come
     after the terminating zero-length chunk to the completion callback.
     """
     finished = []
     p = http._ChunkedTransferEncoding(None, finished.append)
     p.dataReceived('0\r\n\r\nhello')
     self.assertEqual(finished, ['hello'])
Exemplo n.º 4
0
 def test_extensions(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} disregards chunk-extension
     fields.
     """
     L = []
     p = http._ChunkedTransferEncoding(L.append, None)
     p.dataReceived('3; x-foo=bar\r\nabc\r\n')
     self.assertEqual(L, ['abc'])
Exemplo n.º 5
0
 def test_newlines(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} doesn't treat CR LF pairs
     embedded in chunk bodies specially.
     """
     L = []
     p = http._ChunkedTransferEncoding(L.append, None)
     p.dataReceived('2\r\n\r\n\r\n')
     self.assertEqual(L, ['\r\n'])
Exemplo n.º 6
0
 def test_extra(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} passes any bytes which come
     after the terminating zero-length chunk to the completion callback.
     """
     finished = []
     p = http._ChunkedTransferEncoding(None, finished.append)
     p.dataReceived('0\r\n\r\nhello')
     self.assertEqual(finished, ['hello'])
Exemplo n.º 7
0
 def test_extensions(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} disregards chunk-extension
     fields.
     """
     L = []
     p = http._ChunkedTransferEncoding(L.append, None)
     p.dataReceived('3; x-foo=bar\r\nabc\r\n')
     self.assertEqual(L, ['abc'])
Exemplo n.º 8
0
 def test_newlines(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} doesn't treat CR LF pairs
     embedded in chunk bodies specially.
     """
     L = []
     p = http._ChunkedTransferEncoding(L.append, None)
     p.dataReceived('2\r\n\r\n\r\n')
     self.assertEqual(L, ['\r\n'])
Exemplo n.º 9
0
 def test_finish(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} interprets a zero-length
     chunk as the end of the chunked data stream and calls the completion
     callback.
     """
     finished = []
     p = http._ChunkedTransferEncoding(None, finished.append)
     p.dataReceived('0\r\n\r\n')
     self.assertEqual(finished, [''])
Exemplo n.º 10
0
 def test_decoding(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} decodes chunked-encoded data
     and passes the result to the specified callback.
     """
     L = []
     p = http._ChunkedTransferEncoding(L.append, None)
     p.dataReceived('3\r\nabc\r\n5\r\n12345\r\n')
     p.dataReceived('a\r\n0123456789\r\n')
     self.assertEqual(L, ['abc', '12345', '0123456789'])
Exemplo n.º 11
0
 def test_finish(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} interprets a zero-length
     chunk as the end of the chunked data stream and calls the completion
     callback.
     """
     finished = []
     p = http._ChunkedTransferEncoding(None, finished.append)
     p.dataReceived('0\r\n\r\n')
     self.assertEqual(finished, [''])
Exemplo n.º 12
0
 def test_decoding(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} decodes chunked-encoded data
     and passes the result to the specified callback.
     """
     L = []
     p = http._ChunkedTransferEncoding(L.append, None)
     p.dataReceived('3\r\nabc\r\n5\r\n12345\r\n')
     p.dataReceived('a\r\n0123456789\r\n')
     self.assertEqual(L, ['abc', '12345', '0123456789'])
Exemplo n.º 13
0
 def test_short(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} decodes chunks broken up and
     delivered in multiple calls.
     """
     L = []
     finished = []
     p = http._ChunkedTransferEncoding(L.append, finished.append)
     for s in '3\r\nabc\r\n5\r\n12345\r\n0\r\n\r\n':
         p.dataReceived(s)
     self.assertEqual(L, ['a', 'b', 'c', '1', '2', '3', '4', '5'])
     self.assertEqual(finished, [''])
Exemplo n.º 14
0
 def test_short(self):
     """
     L{_ChunkedTransferEncoding.dataReceived} decodes chunks broken up and
     delivered in multiple calls.
     """
     L = []
     finished = []
     p = http._ChunkedTransferEncoding(L.append, finished.append)
     for s in '3\r\nabc\r\n5\r\n12345\r\n0\r\n\r\n':
         p.dataReceived(s)
     self.assertEqual(L, ['a', 'b', 'c', '1', '2', '3', '4', '5'])
     self.assertEqual(finished, [''])