Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0aa7887f
Kaydet (Commit)
0aa7887f
authored
Eki 09, 2016
tarafından
Berker Peksag
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28389: Fix ProxiedTransport example in xmlrpc.client documentation
üst
e259267e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
22 deletions
+16
-22
xmlrpc.client.rst
Doc/library/xmlrpc.client.rst
+16
-22
No files found.
Doc/library/xmlrpc.client.rst
Dosyayı görüntüle @
0aa7887f
...
@@ -555,33 +555,27 @@ Example of Client Usage
...
@@ -555,33 +555,27 @@ Example of Client Usage
print("ERROR", v)
print("ERROR", v)
To access an XML-RPC server through a HTTP proxy, you need to define a custom
To access an XML-RPC server through a HTTP proxy, you need to define a custom
transport. The following example shows how:
transport. The following example shows how:
:
.. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html
import http.client
import xmlrpc.client
::
import xmlrpc.client, http.client
class ProxiedTransport(xmlrpc.client.Transport):
class ProxiedTransport(xmlrpc.client.Transport):
def set_proxy(self, proxy):
self.proxy = proxy
def make_connection(self, host):
def set_proxy(self, host, port=None, headers=None):
self.realhost = host
self.proxy = host, port
h = http.client.HTTPConnection(self.proxy)
self.proxy_headers = headers
return h
def send_request(self, connection, handler, request_body, debug):
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
def send_host(self, connection, host):
def make_connection(self, host):
connection.putheader('Host', self.realhost)
connection = http.client.HTTPConnection(*self.proxy)
connection.set_tunnel(host, headers=self.proxy_headers)
p = ProxiedTransport()
self._connection = host, connection
p.set_proxy('proxy-server:8080')
return connection
server = xmlrpc.client.ServerProxy('http://time.xmlrpc.com/RPC2', transport=p)
print(server.currentTime.getCurrentTime())
transport = ProxiedTransport()
transport.set_proxy('proxy-server', 8080)
server = xmlrpc.client.ServerProxy('http://betty.userland.com', transport=transport)
print(server.examples.getStateName(41))
Example of Client and Server Usage
Example of Client and Server Usage
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment