當前位置: 首頁>>代碼示例>>Python>>正文


Python client.Transport方法代碼示例

本文整理匯總了Python中xmlrpc.client.Transport方法的典型用法代碼示例。如果您正苦於以下問題:Python client.Transport方法的具體用法?Python client.Transport怎麽用?Python client.Transport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xmlrpc.client的用法示例。


在下文中一共展示了client.Transport方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import Transport [as 別名]
def __init__(self, index_url, session, use_datetime=False):
        xmlrpc_client.Transport.__init__(self, use_datetime)
        index_parts = urllib_parse.urlparse(index_url)
        self._scheme = index_parts.scheme
        self._session = session 
開發者ID:frostming,項目名稱:pdm,代碼行數:7,代碼來源:xmlrpc.py

示例2: test_get_host_info

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import Transport [as 別名]
def test_get_host_info(self):
        # see bug #3613, this raised a TypeError
        transp = xmlrpc.client.Transport()
        self.assertEqual(transp.get_host_info("user@host.tld"),
                          ('host.tld',
                           [('Authorization', 'Basic dXNlcg==')], {})) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:8,代碼來源:test_xmlrpc.py

示例3: parse_response

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client 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:Microvellum,項目名稱:Fluid-Designer,代碼行數:5,代碼來源:test_xmlrpc.py

示例4: send_content

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client 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:Microvellum,項目名稱:Fluid-Designer,代碼行數:7,代碼來源:test_xmlrpc.py

示例5: test_gzip_request

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client 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)
        p("close")() 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:13,代碼來源:test_xmlrpc.py

示例6: test_bad_gzip_request

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client 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.assertRaisesRegex(xmlrpclib.ProtocolError,
                                    re.compile(r"\b400\b"))
        with cm:
            p.pow(6, 8)
        p("close")() 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:12,代碼來源:test_xmlrpc.py

示例7: test_transport

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import Transport [as 別名]
def test_transport(self):
        t = xmlrpclib.Transport()
        p = xmlrpclib.ServerProxy(self.url, transport=t)
        self.assertEqual(p('transport'), t)


# This is a contrived way to make a failure occur on the server side
# in order to test the _send_traceback_header flag on the server 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:10,代碼來源:test_xmlrpc.py

示例8: test_transport

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import Transport [as 別名]
def test_transport(self):
        t = xmlrpclib.Transport()
        p = xmlrpclib.ServerProxy(self.url, transport=t)
        self.assertEqual(p('transport'), t)

# This is a contrived way to make a failure occur on the server side
# in order to test the _send_traceback_header flag on the server 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:9,代碼來源:test_xmlrpc.py

示例9: __init__

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import Transport [as 別名]
def __init__(self, *args, **kwargs):
        self.session = None
        self.timeout = None
        if 'session' in kwargs:
            self.session = kwargs['session']
            del kwargs['session']
        if 'timeout' in kwargs:
            self.timeout = kwargs['timeout']
            del kwargs['timeout']
        return xmlrpc.Transport.__init__(self, *args, **kwargs) 
開發者ID:ip-tools,項目名稱:patzilla,代碼行數:12,代碼來源:requests_xmlrpclib.py

示例10: __init__

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import Transport [as 別名]
def __init__(self, use_datetime=0, host=None):
        xmlrpclib.Transport.__init__(self, use_datetime)
        if host:
            self.use_https = 'https' in host 
開發者ID:Gandi,項目名稱:gandi.cli,代碼行數:6,代碼來源:xmlrpc.py

示例11: CookiesTransport

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import Transport [as 別名]
def CookiesTransport(proto='https'):
    """Generate transport class when using cookie based authentication."""
    _TransportClass_ = Transport if proto == 'http' else SafeTransport

    class CookiesTransport(_TransportClass_):
        """A Python3 xmlrpc.client.Transport subclass that retains cookies."""
        def __init__(self):
            _TransportClass_.__init__(self)
            self._cookies = dict()

        def send_headers(self, connection, headers):
            if self._cookies:
                cookies = map(lambda x: x[0] + '=' + x[1], self._cookies.items())
                connection.putheader('Cookie', '; '.join(cookies))
            _TransportClass_.send_headers(self, connection, headers)

        def parse_response(self, response):
            """parse and store cookie"""
            try:
                for header in response.msg.get_all("Set-Cookie"):
                    cookie = header.split(";", 1)[0]
                    cookieKey, cookieValue = cookie.split("=", 1)
                    self._cookies[cookieKey] = cookieValue
            finally:
                return _TransportClass_.parse_response(self, response)

    class CookiesTransport2(_TransportClass_):
        """A Python2 xmlrpclib.Transport subclass that retains cookies."""
        def __init__(self):
            _TransportClass_.__init__(self)
            self._cookies = dict()

        def send_request(self, connection, handler, request_body):
            _TransportClass_.send_request(self, connection, handler, request_body)
            # set cookie below handler
            if self._cookies:
                cookies = map(lambda x: x[0] + '=' + x[1], self._cookies.items())
                connection.putheader("Cookie", "; ".join(cookies))

        def parse_response(self, response):
            """parse and store cookie"""
            try:
                for header in response.getheader("set-cookie").split(", "):
                    # filter 'expire' information
                    if not header.startswith("D"):
                        continue
                    cookie = header.split(";", 1)[0]
                    cookieKey, cookieValue = cookie.split("=", 1)
                    self._cookies[cookieKey] = cookieValue
            finally:
                return _TransportClass_.parse_response(self, response)

    return CookiesTransport2() if PY_VERSION == 2 else CookiesTransport() 
開發者ID:fmenabe,項目名稱:python-dokuwiki,代碼行數:55,代碼來源:dokuwiki.py


注:本文中的xmlrpc.client.Transport方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。