'If data is delivered to the L{Response} before a protocol is registered
with C{deliverBody}, that data is buffered until the protocol is
registered and then is delivered.'

def test_bufferEarlyData(self):

    bytes = []
    class ListConsumer(Protocol, ):
        def dataReceived(self, data):
            bytes.append(data)
    protocol = ListConsumer()
    response = justTransportResponse(StringTransport())
    response._bodyDataReceived('foo')
    response._bodyDataReceived('bar')
    response.deliverBody(protocol)
    response._bodyDataReceived('baz')
    self.assertEqual(bytes, ['foo', 'bar', 'baz'])
    self.assertIdentical(response._bodyBuffer, None)
