diff options
author | yvesf <yvesf@aurora.xapek.org> | 2010-03-11 22:07:36 +0100 |
---|---|---|
committer | yvesf <yvesf@aurora.xapek.org> | 2010-03-11 22:07:36 +0100 |
commit | 0d338b944706e165c9cdb205a79075beaa48253b (patch) | |
tree | 14583a34b820f8691e5e53805777f5b91f0ac462 | |
parent | 170cc2e532974da7ae55e8b56f99c0b40ef17855 (diff) | |
download | magicproxy-0d338b944706e165c9cdb205a79075beaa48253b.tar.gz magicproxy-0d338b944706e165c9cdb205a79075beaa48253b.zip |
a proof of concept
-rw-r--r-- | proxy.py | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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): |