def testClose(self): req = OutgoingRequest(self.connection, "Ping") req.response.onComplete = self.handleResponse req.send() asyncore.loop(timeout=0, count=5) # give things time to send self.connection.close() asyncore.loop()
def sendRequest(self): size = random.randint(0,32767) io = StringIO() for i in xrange(0,size): io.write( chr(i % 256) ) body = io.getvalue() io.close req = OutgoingRequest(self.connection, body,{'Content-Type': 'application/octet-stream', 'User-Agent': 'PyBLIP', 'Date': datetime.now(), 'Size': size}) req.compressed = randbool() req.urgent = (random.randint(0,kUrgentEvery-1)==0) req.response.onComplete = self.gotResponse return req.send()