summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Keck <thomas@macbook.macbook>2010-03-12 21:07:33 +0100
committerThomas Keck <thomas@macbook.macbook>2010-03-12 21:07:33 +0100
commitd3c3ad16098a143cad8ac88b4d45a3179f9a7920 (patch)
tree9c1dc1d962b6f036feb4fce32390d2243f9bf460
parent6385123d18dfec03d594b490ca265dfe8f4f631f (diff)
parentfc2385d1b3ced7f34b23bcce0bc48c6764fe12fa (diff)
downloadmagicproxy-d3c3ad16098a143cad8ac88b4d45a3179f9a7920.tar.gz
magicproxy-d3c3ad16098a143cad8ac88b4d45a3179f9a7920.zip
Merge branch 'master' of git://github.com/yvesf/magicproxy
Conflicts: proxy.py
-rw-r--r--proxy.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/proxy.py b/proxy.py
index 5be4387..93c1994 100644
--- a/proxy.py
+++ b/proxy.py
@@ -24,7 +24,7 @@ class Fetcher(asynchat.async_chat):
self.reader = reader
self.proxy = ENDPOINTS(endpoint)
self.url = url
- self.header = self.header
+ self.header = header
self.range = range
self.start_time = time.time()
@@ -37,7 +37,7 @@ class Fetcher(asynchat.async_chat):
self.http_header = ""
self.state = 0 #0=status, 1=header, 2=body
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
- self.connect(proxy)
+ self.connect(self.proxy)
#XXXshould include original request headers
def handle_connect (self):
@@ -80,11 +80,12 @@ class Fetcher(asynchat.async_chat):
class MultipleProxyReader(object):
def __init__(self, channel, url, header, content_length):
- print "MultipleProxyReader url=%s content_length=%s" % (url, content_length)
self.channel = channel
self.url = url
self.header = header
self.content_length = content_length
+
+ print self
self.header_sent = False
self.fetch_pos = 0
@@ -137,10 +138,11 @@ class MultipleProxyReader(object):
else:
self.fetch_pos = self.content_length
range = (start, self.fetch_pos-1)
- Fetcher(self, ENDPOINTS[endpoint], self.url, self.header, range, self.content_length)
+ Fetcher(self, ENDPOINTS[endpoint], self.url, self.header, range)
def find_next_data(self):
- if not self.channel.writeable(): # request-side closed the connection
+ if self.channel.is_closed:
+ print self, "request side closed the connection"
self.channel.close_when_done()
#XXX terminate all running fetcher
return False
@@ -160,7 +162,7 @@ class MultipleProxyReader(object):
return False
def __str__(self):
- return "<MultipleProxyReader >"
+ return "<MultipleProxyReader url=%s content_length=%s>" % (self.url, self.content_length)
class HTTPChannel(asynchat.async_chat):
def __init__(self, server, sock, addr):
@@ -169,6 +171,10 @@ class HTTPChannel(asynchat.async_chat):
self.set_terminator("\r\n\r\n")
self.request = None
self.data = StringIO.StringIO()
+ self.is_closed = False
+
+ def handle_close(self):
+ self.is_closed = True
def collect_incoming_data(self, data):
self.data.write(data)