def handover_connection(self, handover):
# Handover connection
##print >> sys.stderr, "DEBUG handover_connection", handover, self.pipeline.host_spec, self.pipeline.relay_address
external_stream = self.read_stream
# Shutdown pipeline; pretend it is an external shutdown
self.pipeline.shutdown(external=True)
if handover == "localhandler":
http_connection = httpserver.HTTPConnection(external_stream,
self.pipeline.from_address,
self.local_request_callback,
xheaders=self.pipeline.xheaders)
return
assert isinstance(self.pipeline.relay_address, tuple)
host, port = self.pipeline.relay_address
port += self.pipeline.multiplex_params[1]
self.proxy_connection_id = self.pipeline.proxy_server.proxy_id + "," + ("%s:%s" % (host, port))
# Setup connection
conn = self.pipeline.multiplex_params[0].get_client(self.proxy_connection_id,
connect=(host, port))
if handover == "websocket":
http_connection = httpserver.HTTPConnection(external_stream,
self.pipeline.from_address,
self.ws_request_callback,
xheaders=self.pipeline.xheaders)
评论列表
文章目录