def test_get_chunk_by_chunk(self):
        chunks = ["hej %d" % i for i in range(0,10)]
        self.startTestServer(chunks,0)
        received_chunks = []

        def verify():
            nt.assert_equal(chunks, received_chunks)

        def handleChunk(result):
            if result is None:
                verify()
                return
            (chunk, nextChunkDeferred) = result
            received_chunks.append(chunk)
            return nextChunkDeferred.addCallback(handleChunk)

        return txhttpstream.getStreamedPages("http://localhost:8080") \
                .addCallback(handleChunk)
 def test_handles_timeouts(self):
     self.startTestServer([""],1)
     d = txhttpstream.getStreamedPages("http://localhost:8080", timeout=0.01) \
             .addCallbacks(lambda ign: nt.assert_true(False))
     self.assertFailure(d, defer.TimeoutError)
     return d
 def test_handles_early_connection_failure(self):
     d = txhttpstream.getStreamedPages("http://idontexislkjlkjljs") \
             .addCallbacks(lambda ign: nt.assert_true(False))
     self.assertFailure(d, error.DNSLookupError)
     return d