'L{http.Request.finish} will notify the channel that it is finished, and
will put the transport back in the producing state so that the reactor
can close the connection.'

def test_finishCleansConnection(self):

    factory = http.HTTPFactory()
    factory.timeOut = None
    factory._logDateTime = 'sometime'
    factory._logDateTimeCall = True
    factory.startFactory()
    factory.logFile = BytesIO()
    proto = factory.buildProtocol(None)
    proto._channel._optimisticEagerReadSize = 0
    val = ['GET    /path    HTTP/1.1\r\n', '\r\n\r\n']
    trans = StringTransport()
    proto.makeConnection(trans)
    self.assertEqual(trans.producerState, 'producing')
    for x in val:
        proto.dataReceived(x)
    proto.dataReceived('GET    ')
    self.assertEqual(trans.producerState, 'paused')
    proto._channel.requests[0].finish()
    self.assertEqual(trans.producerState, 'producing')
