'L{Request.writeTo} uses chunked encoding to write data from the request
body producer to the given transport.  It registers the request body
producer with the transport.'

def test_sendChunkedRequestBody(self):

    producer = StringProducer(UNKNOWN_LENGTH)
    request = Request('POST', '/bar', _boringHeaders, producer)
    request.writeTo(self.transport)
    self.assertNotIdentical(producer.consumer, None)
    self.assertIdentical(self.transport.producer, producer)
    self.assertTrue(self.transport.streaming)
    self.assertEqual(self.transport.value(), 'POST    /bar    HTTP/1.1\r\nConnection:    close\r\nTransfer-Encoding:    chunked\r\nHost:    example.com\r\n\r\n')
    self.transport.clear()
    producer.consumer.write(('x' * 3))
    producer.consumer.write(('y' * 15))
    producer.finished.callback(None)
    self.assertIdentical(self.transport.producer, None)
    self.assertEqual(self.transport.value(), '3\r\nxxx\r\nf\r\nyyyyyyyyyyyyyyy\r\n0\r\n\r\n')
