当前位置: 首页>>代码示例>>Python>>正文


Python xmlrpclib.Transport方法代码示例

本文整理汇总了Python中xmlrpclib.Transport方法的典型用法代码示例。如果您正苦于以下问题:Python xmlrpclib.Transport方法的具体用法?Python xmlrpclib.Transport怎么用?Python xmlrpclib.Transport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpclib的用法示例。


在下文中一共展示了xmlrpclib.Transport方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported B-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = xmlrpclib.SafeTransport()
            else:
                transport = xmlrpclib.Transport()
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:25,代码来源:brpclib.py

示例2: __init__

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def __init__(self, uri, transport=None, encoding=None, verbose=0,
                 allow_none=0):
        # establish a "logical" server connection

        # get the url
        import urllib
        type, uri = urllib.splittype(uri)
        if type not in ("http", "https"):
            raise IOError, "unsupported EB-RPC protocol"
        self.__host, self.__handler = urllib.splithost(uri)
        if not self.__handler:
            self.__handler = "/RPC2"

        if transport is None:
            if type == "https":
                transport = xmlrpclib.SafeTransport()
            else:
                transport = xmlrpclib.Transport()
        self.__transport = transport

        self.__encoding = encoding
        self.__verbose = verbose
        self.__allow_none = allow_none 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:25,代码来源:ebrpclib.py

示例3: parse_response

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def parse_response(self, response):
            self.response_length=int(response.getheader("content-length", 0))
            return xmlrpclib.Transport.parse_response(self, response) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_xmlrpc.py

示例4: send_content

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def send_content(self, connection, body):
            if self.fake_gzip:
                #add a lone gzip header to induce decode error remotely
                connection.putheader("Content-Encoding", "gzip")
            return xmlrpclib.Transport.send_content(self, connection, body) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_xmlrpc.py

示例5: test_gzip_request

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def test_gzip_request(self):
        t = self.Transport()
        t.encode_threshold = None
        p = xmlrpclib.ServerProxy(URL, transport=t)
        self.assertEqual(p.pow(6,8), 6**8)
        a = self.RequestHandler.content_length
        t.encode_threshold = 0 #turn on request encoding
        self.assertEqual(p.pow(6,8), 6**8)
        b = self.RequestHandler.content_length
        self.assertTrue(a>b) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_xmlrpc.py

示例6: test_bad_gzip_request

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def test_bad_gzip_request(self):
        t = self.Transport()
        t.encode_threshold = None
        t.fake_gzip = True
        p = xmlrpclib.ServerProxy(URL, transport=t)
        cm = self.assertRaisesRegexp(xmlrpclib.ProtocolError,
                                     re.compile(r"\b400\b"))
        with cm:
            p.pow(6, 8) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_xmlrpc.py

示例7: test_gzip_response

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def test_gzip_response(self):
        t = self.Transport()
        p = xmlrpclib.ServerProxy(URL, transport=t)
        old = self.requestHandler.encode_threshold
        self.requestHandler.encode_threshold = None #no encoding
        self.assertEqual(p.pow(6,8), 6**8)
        a = t.response_length
        self.requestHandler.encode_threshold = 0 #always encode
        self.assertEqual(p.pow(6,8), 6**8)
        b = t.response_length
        self.requestHandler.encode_threshold = old
        self.assertTrue(a>b) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_xmlrpc.py

示例8: make_connection

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def make_connection(self, host):
        conn = xmlrpclib.Transport.make_connection(self, host)
        conn.sock = self.fake_socket = FakeSocket()
        return conn 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_xmlrpc.py

示例9: test_custom_user_agent

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def test_custom_user_agent(self):
        class TestTransport(FakeTransport):

            def send_user_agent(self, conn):
                xmlrpclib.Transport.send_user_agent(self, conn)
                conn.putheader("X-Test", "test_custom_user_agent")

        req = self.issue_request(TestTransport)
        self.assertIn("X-Test: test_custom_user_agent\r\n", req) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_xmlrpc.py

示例10: test_send_host

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def test_send_host(self):
        class TestTransport(FakeTransport):

            def send_host(self, conn, host):
                xmlrpclib.Transport.send_host(self, conn, host)
                conn.putheader("X-Test", "test_send_host")

        req = self.issue_request(TestTransport)
        self.assertIn("X-Test: test_send_host\r\n", req) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_xmlrpc.py

示例11: test_send_request

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def test_send_request(self):
        class TestTransport(FakeTransport):

            def send_request(self, conn, url, body):
                xmlrpclib.Transport.send_request(self, conn, url, body)
                conn.putheader("X-Test", "test_send_request")

        req = self.issue_request(TestTransport)
        self.assertIn("X-Test: test_send_request\r\n", req) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_xmlrpc.py

示例12: test_send_content

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def test_send_content(self):
        class TestTransport(FakeTransport):

            def send_content(self, conn, body):
                conn.putheader("X-Test", "test_send_content")
                xmlrpclib.Transport.send_content(self, conn, body)

        req = self.issue_request(TestTransport)
        self.assertIn("X-Test: test_send_content\r\n", req) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_xmlrpc.py

示例13: test_gsip_response

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import Transport [as 别名]
def test_gsip_response(self):
        t = self.Transport()
        p = xmlrpclib.ServerProxy(URL, transport=t)
        old = self.requestHandler.encode_threshold
        self.requestHandler.encode_threshold = None #no encoding
        self.assertEqual(p.pow(6,8), 6**8)
        a = t.response_length
        self.requestHandler.encode_threshold = 0 #always encode
        self.assertEqual(p.pow(6,8), 6**8)
        b = t.response_length
        self.requestHandler.encode_threshold = old
        self.assertTrue(a>b)

#Test special attributes of the ServerProxy object 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:16,代码来源:test_xmlrpc.py


注:本文中的xmlrpclib.Transport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。