self.client = client
self.hr = args[0]
print "on_query", reqtype, repr(self.hr.headers), str(self.hr.headers)
- if not hasattr(self.client, "proxy"):
- print "new proxy"
- self.client.proxy = ProxyConnection()
- self.client.proxy.connect()
+ session = self.client.session
+ p = self.proxies.get(session, None)
+ if not p:
+ proxy = ProxyConnection()
+ proxy.connect()
+ self.proxies[session] = proxy
multitask.add(self.proxy_relay(reqtype))
def proxy_relay(self, reqtype):
- p = self.client.proxy
+ session = self.client.session
+ p = self.proxies[session]
# send command
req = "%s %s %s\n" % (reqtype, self.hr.path, self.hr.request_version)
if self.hr.close_connection:
print 'proxy wants client to close_connection'
try:
+ raise httpd.ConnectionClosed
yield self.client.connectionClosed()
except httpd.ConnectionClosed:
print 'close_connection done'
import os, sys, time, struct, socket, traceback, multitask
import threading, Queue
import uuid
+import select
from string import strip
from BaseHTTPServer import BaseHTTPRequestHandler
# over to "standard" HTTPRequestHandler, the data's already
# there.
print "parseRequests"
- readok = (yield multitask.readable(self.stream.sock, 5000))
+ try:
+ readok = (yield multitask.readable(self.stream.sock, 5000))
+ except select.error:
+ print "select error: connection closed"
+ raise ConnectionClosed
+
print "readok", readok
print
raw_requestline = (yield self.stream.readline())
else:
print "cookies", str(msg.response_cookies)
session = msg.response_cookies['session'].value
+ client.session = session
name = msg.path
print "serverlistener", name
if '*' not in self.apps and name not in self.apps: