multiproxy.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:slidoc 作者: mitotic 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号