From 0d338b944706e165c9cdb205a79075beaa48253b Mon Sep 17 00:00:00 2001 From: yvesf Date: Thu, 11 Mar 2010 22:07:36 +0100 Subject: a proof of concept --- proxy.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'proxy.py') diff --git a/proxy.py b/proxy.py index d666df1..0c4ea06 100644 --- a/proxy.py +++ b/proxy.py @@ -14,7 +14,7 @@ ENDPOINTS = [ #minimum entity size to start a paralel fetch MINIMAL_SIZE = 524288 -BLOCKSIZE_FETCH = 524288 +BLOCKSIZE_FETCH = 1048576 class Fetcher(asynchat.async_chat): def __init__(self, reader, proxy, url, header, range, content_length): @@ -93,7 +93,8 @@ class MultipleProxyReader(object): print "got body data at pos %s" % pos self.blocks[pos] = data - self.find_next_data() + while self.find_next_data(): + pass def handle_incoming_http_header(self, header): if self.header_sent: @@ -129,17 +130,19 @@ class MultipleProxyReader(object): self.next_endpoint = (self.next_endpoint+1) % len(ENDPOINTS) def find_next_data(self): + r = False print "expect at %s" % self.write_pos, self.blocks.keys() if self.write_pos in self.blocks.keys(): + r=True data = self.blocks.pop(self.write_pos) self.channel.push(data) self.write_pos += len(data) print "Send %s bytes" % len(data) - self.find_next_data() if self.write_pos + 1 >= self.content_length: print "done" self.channel.close_when_done() + return r class HTTPChannel(asynchat.async_chat): def __init__(self, server, sock, addr): -- cgit v1.2.1