Python xmlrpclib.Transport() Examples
The following are 30
code examples of xmlrpclib.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
xmlrpclib
, or try the search function
.
Example #1
Source File: ebrpclib.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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
Example #2
Source File: brpclib.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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
Example #3
Source File: ebrpclib.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: brpclib.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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
Example #5
Source File: test_xmlrpc.py From CTFCrackTools 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)
Example #6
Source File: test_xmlrpc.py From CTFCrackTools-V2 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 CTFCrackTools-V2 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)
Example #8
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def make_connection(self, host): conn = xmlrpclib.Transport.make_connection(self, host) conn.sock = self.fake_socket = FakeSocket() return conn
Example #9
Source File: test_xmlrpc.py From CTFCrackTools 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 #10
Source File: utils.py From supervisoradmin with GNU General Public License v3.0 | 5 votes |
def __init__(self, timeout, use_datetime=0): self.timeout = timeout xmlrpclib.Transport.__init__(self, use_datetime)
Example #11
Source File: test_xmlrpc.py From CTFCrackTools 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.assertRaisesRegexp(xmlrpclib.ProtocolError, re.compile(r"\b400\b")) with cm: p.pow(6, 8)
Example #12
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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
Example #13
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #14
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #15
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: test_xmlrpc.py From CTFCrackTools 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 #17
Source File: test_xmlrpc.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #18
Source File: test_xmlrpc.py From CTFCrackTools-V2 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 #19
Source File: utils.py From supervisoradmin with GNU General Public License v3.0 | 5 votes |
def make_connection(self, host): connection = xmlrpclib.Transport.make_connection(self, host) connection.timeout = self.timeout return connection
Example #20
Source File: test_xmlrpc.py From CTFCrackTools-V2 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.assertRaisesRegexp(xmlrpclib.ProtocolError, re.compile(r"\b400\b")) with cm: p.pow(6, 8)
Example #21
Source File: transport.py From conary with Apache License 2.0 | 5 votes |
def parse_response(self, response): ctype = response.headers.get('content-type', '') ctype, pdict = cgi.parse_header(ctype) if ctype in self.contentTypes: return xmlrpclib.Transport.parse_response(self, response) elif ctype != self.mixedType: raise xmlrpclib.ResponseError( "Response has invalid or missing Content-Type") decoder = MultipartDecoder(response, pdict['boundary']) # Read XMLRPC response rpcHeaders, rpcBody = decoder.get() if (cgi.parse_header(rpcHeaders.get('content-type'))[0] not in self.contentTypes): raise xmlrpclib.ResponseError( "Response has invalid or missing Content-Type") rpcBody = StringIO.StringIO(rpcBody) result = xmlrpclib.Transport.parse_response(self, rpcBody) # Replace the URL in the XMLRPC response with a file-like object that # reads out the second part of the multipart response csResponse = decoder.getStream() if csResponse.headers.get('content-type') != ( 'application/x-conary-change-set'): raise xmlrpclib.ResponseError( "Response body has wrong Content-Type") result[0][1][0] = csResponse return result
Example #22
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #23
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #24
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #25
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #26
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def make_connection(self, host): conn = xmlrpclib.Transport.make_connection(self, host) conn.sock = self.fake_socket = FakeSocket() return conn
Example #27
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #28
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 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.assertRaisesRegexp(xmlrpclib.ProtocolError, re.compile(r"\b400\b")) with cm: p.pow(6, 8)
Example #29
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 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)
Example #30
Source File: test_xmlrpc.py From gcblue with BSD 3-Clause "New" or "Revised" License | 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)