當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。