auto_open = 1
debuglevel = 0
strict = 0
+ serving = False
def __init__(self):
self.sock = None
def on_query(self, client, reqtype, *args):
"""Serve a request."""
+
self.client = client
self.hr = args[0]
print "on_query", reqtype, repr(self.hr.headers), str(self.hr.headers)
session = self.client.session
p = self.proxies[session]
+ #while p.serving:
+ # (yield multitask.sleep(0.01))
+ p.serving = True
+
# send command
- #req = "%s %s %s\n" % (reqtype, self.hr.path, self.hr.request_version)
req = "%s %s %s\n" % (reqtype, self.hr.path, "HTTP/1.1")
print "req", req
yield p.ss.write(req)
# now read response and write back
# HTTP/1.0 200 OK status line etc.
- line = (yield p.ss.readline())
- yield self.client.writeMessage(line)
+ responseline = (yield p.ss.readline())
+ yield self.client.writeMessage(responseline)
res = ''
try:
self.hr.response_cookies = rcooks
print "rcooks", str(rcooks)
+ # override connection: keep-alive hack
+ #responseline = responseline.split(" ")
+ #print "responseline:", responseline
+ #if responseline[1] != "200":
+ # respheaders['Connection'] = 'close'
+
# send all but Set-Cookie headers
del respheaders['Set-Cookie'] # being replaced
yield self.client.writeMessage(str(respheaders))
print 'close_connection done'
pass
+ p.serving = False
+
raise StopIteration