Python xmlrpc.client.Transport() Examples
The following are 22
code examples of xmlrpc.client.Transport().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xmlrpc.client
, or try the search function
.
Example #1
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
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")()
Example #2
Source File: xmlrpc.py From gandi.cli with GNU General Public License v3.0 | 5 votes |
def __init__(self, use_datetime=0, host=None): xmlrpclib.Transport.__init__(self, use_datetime) if host: self.use_https = 'https' in host
Example #3
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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
Example #4
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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")()
Example #5
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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")()
Example #6
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)
Example #7
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def parse_response(self, response): self.response_length=int(response.getheader("content-length", 0)) return xmlrpclib.Transport.parse_response(self, response)
Example #8
Source File: test_xmlrpc.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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==')], {}))
Example #9
Source File: requests_xmlrpclib.py From patzilla with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #10
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
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
Example #11
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
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")()
Example #12
Source File: dokuwiki.py From python-dokuwiki with MIT License | 5 votes |
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()
Example #13
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
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)
Example #14
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
def parse_response(self, response): self.response_length=int(response.getheader("content-length", 0)) return xmlrpclib.Transport.parse_response(self, response)
Example #15
Source File: test_xmlrpc.py From ironpython3 with Apache License 2.0 | 5 votes |
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==')], {}))
Example #16
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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
Example #17
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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")()
Example #18
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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")()
Example #19
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)
Example #20
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def parse_response(self, response): self.response_length=int(response.getheader("content-length", 0)) return xmlrpclib.Transport.parse_response(self, response)
Example #21
Source File: test_xmlrpc.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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==')], {}))
Example #22
Source File: xmlrpc.py From pdm with MIT License | 5 votes |
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