From 170cc2e532974da7ae55e8b56f99c0b40ef17855 Mon Sep 17 00:00:00 2001 From: yvesf Date: Thu, 11 Mar 2010 21:53:51 +0100 Subject: Still not parallel --- proxy.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'proxy.py') diff --git a/proxy.py b/proxy.py index a0f5c6b..d666df1 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 = 131072 +BLOCKSIZE_FETCH = 524288 class Fetcher(asynchat.async_chat): def __init__(self, reader, proxy, url, header, range, content_length): @@ -53,7 +53,7 @@ class Fetcher(asynchat.async_chat): self.pos += len(data) if self.pos >= self.range[1]: self.reader.finished() - print "finished" + print "fetcher finished" self.close_when_done() elif self.state ==1: #header self.http_header += data @@ -86,7 +86,8 @@ class MultipleProxyReader(object): self.blocks = dict() self.next_endpoint = 0 - self.finished() #bad-named XXX + for i in range(0,len(ENDPOINTS)): + self.finished() #bad-named XXX def handle_incoming_data(self, pos, data): print "got body data at pos %s" % pos @@ -116,7 +117,7 @@ class MultipleProxyReader(object): def finished(self): self.find_next_data() - if self.fetch_pos != self.content_length: + if self.fetch_pos +1 = self.content_length: + print "done" + self.channel.close_when_done() class HTTPChannel(asynchat.async_chat): def __init__(self, server, sock, addr): @@ -213,7 +208,7 @@ class HTTPProxyServer(asyncore.dispatcher): MultipleProxyReader(channel, url, header, content_length) def _bypass_request(self, channel, method, url): - print "_bypass request" + print "_bypass request hostname=%s port=%s path=%s" % (url.hostname, url.port or 80, url.path) #XXX hier sollte nicht proxy gespielt werden sondern #die daten 1-zu-1 durchgereicht werden. #Weiterhin sollte sichergestellt werden, dass die requests @@ -225,7 +220,7 @@ class HTTPProxyServer(asyncore.dispatcher): channel.push("HTTP/1.0 200 OK\r\nX-Proxy: Magicproxy (superpower disabled)\r\n") channel.push( "\r\n".join(map(lambda k: "%s: %s" % (k[0],k[1]), resp.getheaders())) ) channel.push("\r\n\r\n") - channel.push_with_producer( HTTPResponseProducer(resp) ) + channel.push(resp.read()) channel.close_when_done() if __name__ == "__main__": -- cgit v1.2.1