'If the response headers indicate the response body is encoded with the
I{chunked} transfer encoding, the body is decoded according to that
transfer encoding before being passed to L{Response._bodyDataReceived}.'

def test_chunkedResponseBody(self):

    finished = []
    protocol = HTTPClientParser(Request('GET', '/', _boringHeaders, None), finished.append)
    protocol.makeConnection(StringTransport())
    protocol.dataReceived('HTTP/1.1    200    OK\r\n')
    body = []
    protocol.response._bodyDataReceived = body.append
    protocol.dataReceived('Transfer-Encoding:    chunked\r\n')
    protocol.dataReceived('\r\n')
    self.assertEqual(body, [])
    self.assertIdentical(protocol.response.length, UNKNOWN_LENGTH)
    protocol.dataReceived('3\r\na')
    self.assertEqual(body, ['a'])
    protocol.dataReceived('bc\r\n')
    self.assertEqual(body, ['a', 'bc'])
    protocol.dataReceived('0\r\n\r\nextra')
    self.assertEqual(finished, ['extra'])
