test_http.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码
def test_requestBodyDefaultTimeout(self):
        """
        L{HTTPChannel}'s default timeout is 60 seconds.
        """
        clock = Clock()
        transport = StringTransport()
        factory = http.HTTPFactory()
        protocol = factory.buildProtocol(None)

        # This is a terrible violation of the abstraction later of
        # _genericHTTPChannelProtocol, but we need to do it because
        # policies.TimeoutMixin doesn't accept a reactor on the object.
        # See https://twistedmatrix.com/trac/ticket/8488
        protocol._channel.callLater = clock.callLater
        protocol.makeConnection(transport)
        protocol.dataReceived(b'POST / HTTP/1.0\r\nContent-Length: 2\r\n\r\n')
        clock.advance(59)
        self.assertFalse(transport.disconnecting)
        clock.advance(1)
        self.assertTrue(transport.disconnecting)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号